On Sep 29, 2010, at 2:56 PM, poseid wrote:
> Hello,
>
> I am doing my first steps with rspec and did the following observation.
> 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']
This looks like Rails-2/RSpec-1. If that's correct, then you want to use
"assigns" instead of "assign".
HTH,
David
> render '/a_details/index.html.erb'
>
> response.should have_tag("ul") do
> with_tag("li") do
> with_tag("div", "Name")
> with_tag("div", "Details")
> end
> end
> end
> end
>
> Can someone show me a direction and/or has a solution to this ?
>
> When I run this I get:
>
>
> 1)
> 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>
> 13: </tr>
> 14:
> 15: <% @a_details.each do |shoe_detail| %>
> 16: <tr>
> 17: <td><%=h a_detail.brand %></td>
> 18: <td><%=h a_detail.city_photo %></td>
>
> app/views/a_details/index.html.erb:15
> haml (3.0.18) rails/./lib/haml/helpers/action_view_mods.rb:13:in
> `render_without_mock_proxy'
> spec/views/a_details/index_spec.rb:8
> rspec (1.3.0) lib/spec/example/example_methods.rb:40:in
> `instance_eval'
> rspec (1.3.0) lib/spec/example/example_methods.rb:40:in `execute'
> /opt/local/lib/ruby/1.8/timeout.rb:53:in `timeout'
_______________________________________________
rspec-users mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/rspec-users