jeudi 28 mai 2015

ActionView::Template::Error: undefined method `[]' for nil:NilClass

Have the following error when I run my test

 6) Error:
StaticPagesControllerTest#test_should_get_help:
ActionView::Template::Error: undefined method `[]' for nil:NilClass
 (in/home/bastien/rails/myapp/app/assets/stylesheets/application.css)
 app/views/layouts/application.html.erb:5:in
`_app_views_layouts_application_html_erb__3455207115462205235_70087307924540'
test/controllers/static_pages_controller_test.rb:11:in `block in 
<class:StaticPagesControllerTest>'

I am not sure to understand how/why this error is triggered.

The file application.css is fully commented out

The test code is very straightforward

test "should get about" do
get :about
assert_response :success
assert_select "title", "About | Myapp"
end

Same for the controller...

def about
end

... the view (about.html.erb)...

<% provide(:title, "About") %>
<h1>About</h1>

and the route

  get 'about' => 'static_pages#about'

I suspect that the issue may come from somewhere else in the application but I have no idea. Could anyone give me a hint to help debug or a methodology to follow?

Aucun commentaire:

Enregistrer un commentaire