You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to test a css class generated while using the current_page? helper:
RSpec.describe 'my_day/index.html.erb', type: :view do
it 'should have an active link to my_days' do
render template: 'my_day/index', layout: 'layouts/application'
expect(rendered).to have_css('li.active a', text: 'MyDays')
end
end
<li class="<%= 'active' if current_page?(controller: 'my_day', action: 'index') %>"><%= link_to('MyDays', my_day_index_path) %></li>
But this will never match.
So I tried setting the condition true:
<li class="<%= 'active' if true %>"><%= link_to('MyDays', my_day_index_path) %></li>
And this works. So I think that current_page? isn't evaluated correctly.
The text was updated successfully, but these errors were encountered:
RSpec view specs are intended to allow testing view templates in isolation. When working with a view template in isolation the idea is to treat it as detached from a controller, action, or request path.
The root of the issue is that current_page? doesn't use this information. Checking the current source shows this implementation of the helper only checks the request path.
I think we may be able to adjust things to accommodate this.
Hi There,
I'm trying to test a css class generated while using the current_page? helper:
But this will never match.
So I tried setting the condition true:
And this works. So I think that current_page? isn't evaluated correctly.
The text was updated successfully, but these errors were encountered: