I\'m building a setup screen for billing of individuals. The controller/views are in the Admin namespace.
When run the first test without :js => true I get one failure,
You probably have config.use_transactional_fixtures = true
in your spec_helper.rb. It doesn't work with Capybara javascript specs because the server and the browser client run on separate threads. Due to the fact that database transactions on the server are not visible to the client, the client has no clue about the user you created in the let!(), therefore the user cannot login to the system.
You need to turn off transactional fixtures and clean your database before/after each run (consider the gem database_cleaner) for your js specs.
RSpec.configure do |config|
config.use_transactional_fixtures = false
config.before(:suite) do
DatabaseCleaner.clean_with :truncation
end
config.before(:each) do
if example.metadata[:js]
DatabaseCleaner.strategy = :truncation
else
DatabaseCleaner.strategy = :transaction
end
DatabaseCleaner.start
end
config.after(:each) do
DatabaseCleaner.clean
end
end
The above code snippet is taken from the contact manager app readme and slightly modified