[rspec-users] fills_in NoMethodError

Mark Thomson mark.thomson at ieee.org
Wed Oct 8 21:55:51 EDT 2008


I have an RSpec story with an overall structure that looks something 
like this -

----
Given the user is on the start page
When the user clicks the 'new' button
Then the 'new record' page should be displayed

When the user fills in the form
And the user submits the form
Then the updated form should be displayed

When the user fills in the updated form
And the user submits the form
Then a conformation message should be displayed
----

In the last When step, I have a fills_in call that is failing with the 
following:

----
NoMethodError: You have a nil object when you didn't expect it! You 
might have expected an instance of ActiveRecord::Base. The error 
occurred while evaluating nil.attributes.
----

I think the ActiveRecord thing is a red herring. Poking through the 
Webrat source code, it seems like the problem is more likely a failure 
to find any input fields. But I'm not sure why. Is there anything 
inappropriate with the way I've organized the story, stringing together 
multiple When-Then segments? One thing that seems curious is that I have 
a completely identical fills_in call in the When step that precedes the 
one that is failing and yet that one runs without any problem.

Does this ring any bells with anyone?

Mark.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20081008/29075353/attachment.html>


More information about the rspec-users mailing list