I use integration specifications using Rspec and Capybara, and I clear records between specifications using Database Cleaner. If that matters, I automatically run my specs with Guard and Spork.
Be that as it may, in the middle of a test run, records are deleted from the database, which leads to their failure. Did I configure Datbase Cleaner incorrectly? Or am I doing something else wrong? I have already seen this post , but I do not think this is my problem.
Any help would be appreciated!
Here is spec_helper.rb
Spork.prefork do # ... RSpec.configure do |config| config.mock_with :rspec config.use_transactional_fixtures = true config.include(MailerMacros) config.treat_symbols_as_metadata_keys_with_true_values = true config.filter_run :focus => true config.run_all_when_everything_filtered = true config.before(:suite) { DatabaseCleaner.strategy = :truncation } config.before(:each) { DatabaseCleaner.start } config.after(:each) { DatabaseCleaner.clean } end end Spork.each_run do FactoryGirl.reload end
And here is my specification: (pay attention to 2 puts clauses)
feature "Claim Firm" do let(:firm) { Factory(:firm, :user_id => nil) } scenario "The details page should show a 'Claim' link", :focus => true do email = ' claimer@foo.com ' password = 'secretpass123' u = Factory(:user, :email => email, :password => password, :name => "Bob Claimer") puts "User Count: #{User.count}"
source share