5

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

1
  • make sure you've run the rake db:test:prepare if you added fields in your migration. Commented Jan 23, 2012 at 2:29

1 Answer 1

17

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!

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.