Skip to content

Instantly share code, notes, and snippets.

@weilu
Created November 5, 2012 13:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save weilu/4017097 to your computer and use it in GitHub Desktop.
Save weilu/4017097 to your computer and use it in GitHub Desktop.
Turn off transactional fixtures only for Capybara javascript specs
# 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
# 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
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