Assert_template fails?


#1

Hi All,

I have a seemingly simple problem - but can’t figure out the problem. I
have a simple functional test like so:

def test_should_show_search_dropdown
get :index
assert_response :success
assert_template :search
end

Inspite of having search.rhtml in /app/views/layout, it fails with an
error:

  1. Error:
    test_should_show_search_dropdown(SearchControllerTest):
    NoMethodError: undefined method `include?’ for :search:Symbol

/usr/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/assertions.rb:109:in
`assert_template’

/usr/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/assertions.rb:313:in
`clean_backtrace’

/usr/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/assertions.rb:108:in
assert_template' test/functional/search_controller_test.rb:17:intest_should_show_search_dropdown’

1 tests, 1 assertions, 0 failures, 1 errors

Anybody can tell me where I’m going wrong?

Thanks,
Vamsee.


#2

instead of using a symbol, use a string:

assert_template ‘search’

http://manuals.rubyonrails.com/read/chapter/28