My Cucumber scenario is used to test authentication from a third party provider. What happens is when the facebook connect button is clicked on my registration page a redirect goes to Facebook, and when the credentials are authorized by Facebook, then a redirect happens back to my website.
In my selenium test, it is using the development database on redirect. I know this because its ending up on a page where there is data which shouldn’t be the case because the test database is empty.
features/authentication.feature:
@javascript
Scenario: Signup through Facebook
When I am on the signup page
And I click the Facebook authentication link
And I fill and submit the Facebook form
Then I should be on the Add additional information page
This fails on the I should be on the Add additional information page step because I never get there. This means a data row exists for the facebook user which means its using the development database. Is there a setting I’m missing?
features/support/env.rb
require 'cucumber/rails'
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path(File.dirname(__FILE__) + '/../../config/environment')
Capybara.default_selector = :css
Capybara.javascript_driver = :webkit
Capybara.app_host = "http://localhost:3000"
# factory_girl Factory definitions
Dir[(Rails.root + "spec/factories/**/*.rb").to_s].each {|factory| require factory}
ActionController::Base.allow_rescue = false
Cucumber::Rails::Database.javascript_strategy = :truncation
Cucumber::Rails::World.use_transactional_fixtures = true
Remove
Capybara.app_host = "http://localhost:3000"You’re running the server in development environment and making Capybara use it.