routing - how to do testing of rails layouts, when they call url_for -
i have test case tests layout. looks see if links present or absent different kinds of users (admin links, instance). worked fine until started localize of our interface.
describe "layouts/application" include devise::testhelpers fixtures :users "renders admin link admin user" @admin = users(:admin) sign_in(@admin) @locale = 'en' render rendered.should match(/administration/) end end
the layout contains call <%= toggle_language %>, uses url_for generate url current one, :locale parameter changed:
def toggle_language case locale when :fr other=:en when :en other=:fr else other=:fr end link_to t(:other_language), url_for(:locale => other) end
the problem since have no controller called "layouts", url_for can't generate needs.
1) layouts/application renders admin link admin user failure/error: render actionview::template::error: no route matches {:controller=>"layouts", :locale=>:fr, :action=>"application"}
i've looked see if perhaps rspec render command take :controller,:action, point @ valid route. haven't found such thing yet.
yes, stubbing out works well.
Comments
Post a Comment