I'm trying to follow the railscasts on Integration Testing and am testing a password reset url. I am having a problem with NoMethodError and am not sure what is going on.
I have a user model that has a forgot_password value which is just a hash that will be emailed out.
This seems to be working
ruby-1.9.2-p290 :001 > u=User.find(1)
...
ruby-1.9.2-p290 :002 > u.forgot_password
=> "1280aceaf23f185a2d09a57b5534e7e3"
but I get the following error:
1) PasswordResets emails user when requesting password reset
Failure/Error: click_button "jt"
NoMethodError:
undefined method `forgot_password=' for #<User:0x007ff916b03da0>
# /Users/jt/rails-1/app/controllers/users_controller.rb:61:in `forgot_password_confirmation'
# (eval):2:in `click_button'
and here is the spec:
require 'spec_helper'
describe "PasswordResets" do
it "emails user when requesting password reset" do
user=Factory(:user)
visit log_in_path
click_link "password"
fill_in "email", :with => user.email
click_button "jt"
end
end
What does the the NoMethodError tell me? It looks as if from rails c, the forgot_password value exists. What am I missing?
thx
Just for future searchers:
When you see a no-method error with something like "attributename=" -- but you know active-record is adding that attr_accessor to the model, you should make sure you've run:
rake db:test:prepare
After your migration. Can't say how many times this has got me!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With