Created
November 5, 2012 13:03
-
-
Save weilu/4017097 to your computer and use it in GitHub Desktop.
Turn off transactional fixtures only for Capybara javascript specs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# requests/edit_post_spec.rb | |
require 'spec_helper' | |
feature 'editing a post', js: true do | |
let(:post) { create :post } | |
let(:user) { post.creator } | |
before { sign_in user } | |
scenario 'creator attaches an image to a post' do | |
# user attaches image and expects to see it after submit | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# support/selenium_helper.rb | |
module SeleniumHelper | |
def self.included(base) | |
base.class_eval do | |
self.use_transactional_fixtures = false if metadata[:js] | |
end | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
RSpec.configure do |config| | |
config.use_transactional_fixtures = true | |
config.include SeleniumHelper, :type => :request | |
config.before(:suite) do | |
DatabaseCleaner.strategy = :truncation | |
end | |
config.before(:each, js: true) do | |
DatabaseCleaner.start | |
end | |
config.after(:each, js: true) do | |
DatabaseCleaner.clean | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment