My tests work fine when I'm testing them individually,
rake cucumber FEATURE = 'path/to/feature'
but when I try to run
rake cucumber
They fail with the following error
undefined method `password_confirmation=' for #<User:0x1069545f0> (NoMethodError)
This comes up when I try to create a user using Factory.build(:user). I have a factories file that defines a :user.
I don't really know how to confirm this, but its as though authlogic is not present and the User model does not have the added methods yet. When I look at the User methods (User.new.methods.include?("password_confirmation=")) at the time the Factory tries to build a new user, there is a method defined by that name.
I've done a lot of searching on this, and I don't see anything related, so I'm assuming that it's something else that I am doing.
EDIT:
A little more information - I've been able to reproduce this in a simple case:
------- .feature
Background:
Given user "Bad Admin" with email address "[email protected]" and password "password" exists with "admin" credentials
Given user "Good Admin" with email address "[email protected]" and password "password" exists with "edit" credentials
Scenario: valid log in with authorization
When I go to the login page
Scenario: invalid login
When I go to the login page
---- factories.rb
Factory.define :user do |u|
u.first_name "Arthur"
u.last_name "Dent"
u.email { Factory.next(:user_email) }
u.password "default"
u.password_confirmation "default"
end
---- steps.rb
Given /^user "([^"]*)" with email "([^"]*)", password "([^"]*)" and credentials "([^"]*)" exists$/ do |name, email, password, role|
names = name.split(' ')
user = Factory(:user, :first_name => names.first, :last_name => names.last, :email => email, :password => password, :password_confirmation => password)
user.has_role! role.downcase.gsub(' ', '_')
end