I am trying to run cucumber tests of my app over capybara with selenium driver. In the test steps i dynamically create users to login to the app . But the user login fails with the user i have created. I have set the user_transactional_fixture to false. Still the created records are not available to the selenium app.
Here is the code
Feature File
@browser Scenario: Admin alone can have access to admin pages Given "[email protected]" is a admin When I have logged in as "[email protected]" step definition file
Given /"([^\"]*)" is a admin/ do |email|
user = Email.active.find_by_address(email).try(:user) || User.new({}, :password =>
'Monkey_123', :password_confirmation => 'Monkey_123', :last_name => 'example', :first_name => 'admin')
user.update_attribute(:state, "active")
user.update_attribute(:terms_and_conditions_accepted, 1)
user.groups << Group.find(1)
user.primary_email ||= Email.new(:address => email, :state => Email::State::ACTIVE,
:email_type => Email::Type::PRIMARY)
user.save!
when i run the tests using capybara and selenium driveri am unable to login to my app using
the created user through the browser.
I tried using the ruby debugger, which showed the creation of the particular user.
Following is my config in the env.rb file
if defined?(ActiveRecord::Base)
begin
require 'database_cleaner'
DatabaseCleaner.strategy = :truncation
rescue LoadError => ignore_if_database_cleaner_not_present
end
end
Capybara.server_port = 9887 # Or whatever number you want?
Capybara.app_host = "http://localhost:#{Capybara.server_port}"
Capybara.default_wait_time = 4
Capybara.ignore_hidden_elements=false
Before('@browser') do Capybara.current_driver = :selenium end
Kindly suggest a solution for this. The gems versions are 1) cucumber -v 0.10.7
2)cucumber-rails 0.3.2
3)Capybara 0.4.1.2
4) database_cleaner 0.5.0
Thanks