Skip to content

Commit

Permalink
Fix(Notification List Spec): Ensure matches in notifications
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisma committed Apr 26, 2019
1 parent cc97657 commit 1abc6ab
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion app/views/notifications/_list.html.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<% unless @notifications.empty? %>
<% @notifications.each do |notification| %>
<div class="card mb-3 <%= 'bg-primary-light' unless notification.read %>">
<div class="notification card mb-3 <%= 'bg-primary-light' unless notification.read %>">
<div class="card-body">
<%# Delete link %>
<%= link_to fa_icon('trash lg'), notification_path(notification),
Expand Down
16 changes: 12 additions & 4 deletions spec/views/notifications/_list.html.erb_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@
end

it 'renders an error icon' do
expect(rendered).to have_css('i', class: 'fa fa-exclamation-triangle')
expect(rendered).to have_css('.notification') do
have_css('i', class: 'fa fa-exclamation-triangle')
end
end
end

Expand All @@ -47,7 +49,9 @@
end

it 'does not render an error icon' do
expect(rendered).not_to have_css('i', class: 'fa fa-exclamation-triangle')
expect(rendered).to have_css('.notification') do
not_have_css('i', class: 'fa fa-exclamation-triangle')
end
end
end

Expand All @@ -60,15 +64,19 @@
let(:count) { 3 }

it 'displays the count' do
expect(rendered).to have_text("#{count} times")
expect(rendered).to have_css('.notification') do
have_text("#{count} times")
end
end
end

context 'when the notification occured once' do
let(:count) { 1 }

it 'does not display the count' do
expect(rendered).not_to have_text("#{count} times")
expect(rendered).to have_css('.notification') do
not_have_text("#{count} times")
end
end
end
end
Expand Down

0 comments on commit 1abc6ab

Please sign in to comment.