[rspec-users] "assign" to variable in view seems to give nil object
mulder.patrick at gmail.com
Wed Sep 29 15:56:52 EDT 2010
I am doing my first steps with rspec and did the following
I wanted to write a spec for a standard scaffold index view.
Now, my view spec looks like:
describe "/a_details/index.html.erb" do
it "should list all the details of as in an unordered list" do
assign[:a_details] = ['test']
response.should have_tag("ul") do
Can someone show me a direction and/or has a solution to this ?
When I run this I get:
ActionView::TemplateError in '/a_details/index.html.erb should list
all the details of shoes in an unordered list'
You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.each
On line #15 of app/views/shoe_details/index.html.erb
12: <th>Photo quality</th>
15: <% @a_details.each do |shoe_detail| %>
17: <td><%=h a_detail.brand %></td>
18: <td><%=h a_detail.city_photo %></td>
haml (3.0.18) rails/./lib/haml/helpers/action_view_mods.rb:13:in
rspec (1.3.0) lib/spec/example/example_methods.rb:40:in
rspec (1.3.0) lib/spec/example/example_methods.rb:40:in `execute'
More information about the rspec-users