I ran into a problem using:
This is what my Rspec configuration looked like:
RSpec.configure do |config|
config.include Capybara::DSL
config.before(:suite) do
DatabaseCleaner.strategy = :truncation
DatabaseCleaner.clean_with(:truncation)
end
config.before(:each) do
DatabaseCleaner.start
end
config.after(:each) do
DatabaseCleaner.clean
end
config.fixture_path = "#{::Rails.root}/spec/fixtures"
# If you're not using ActiveRecord, or you'd prefer not to run each of your
# examples within a transaction, remove the following line or assign false
# instead of true.
config.use_transactional_fixtures = true
I would create records in my before(:each)
block but I wouldn't see them in my application code.
This would cause problems as objects that I expected to be there weren't.
After many attempts, I finally found the answer to my problem.
The problem was that I was using
config.use_transactional_fixtures = true
After changing that to
config.use_transactional_fixtures = false
The problem stopped occurring and I could finally see records in my application code.