I am stuck to test a specific view which contains a
request.path_parameters[:controller] variable as the example below
follows:
<%=link_to "Store", admin_stores_url, { :id => "tab-3" ,:class =>
(admin_stores_path == ‘/’ + request.path_parameters[:controller] &&
‘active’)} %>
The rspec view test file:
describe "displaying the index file" do
it "should have the #tab-3 selector id, for example" do
controller.request.path_parameters["controller"].should
eq(“admin/stores”)
render
rendered.should =~ /#tab-3/
end
end
The given error:
Failure/Error: render
ActionView::Template::Error:
can't convert nil into String
# ./app/views/admin/settings/_menu.html.erb:5:in `+'
# ./app/views/admin/settings/_menu.html.erb:5:in
_app_views_admin_settings__menu_html_erb__3443097722112408564_2172534220_4114188497869029268' # ./app/views/admin/stores/index.html.erb:6:in
block in
_app_views_admin_stores_index_html_erb___284062528844236588_2236860180__1529683073472994564’
# ./app/views/admin/stores/index.html.erb:5:in
_app_views_admin_stores_index_html_erb___284062528844236588_2236860180__1529683073472994564' # ./spec/views/admin/stores/index.html.erb_spec.rb:17:in
block
(3 levels) in <top (required)>’
Any ideas about how to stub or simulate the
request.path_parameters[:controller]?
Thanks.