Skip to content

Commit

Permalink
Fix two rogue messages on tests
Browse files Browse the repository at this point in the history
These two messages would appear on some tests, on the console. With
this commit those messages are still caught but don’t show up on the
console anymore (in the middle of RSpec’s dots).

The messages were:
- You have to provide an email address. Usage: rake member:delete'[[email protected]]'
- Checking for expected text of nil is confusing and/or pointless since it will always
  match. Please specify a string or regexp instead.

Technically, the second one is not a message we display on the code,
but rather an RSpec warning telling us one of our variables was nil.
Adding content to the constructor was the solution.
  • Loading branch information
gnclmorais committed Sep 30, 2023
1 parent 7937df0 commit d083583
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions spec/fabricators/sponsor_fabricator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
Fabricator(:sponsor_full, from: :sponsor) do
description { Faker::Lorem.word }
level { 'gold' }
accessibility_info { 'Accessible parking spaces' }
end

Fabricator(:sponsor_with_member_contacts, from: :sponsor) do
Expand Down
4 changes: 3 additions & 1 deletion spec/lib/tasks/delete_member_rake_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
end

it 'when no email is provided' do
expect { task.invoke }.to raise_error(SystemExit, "You have to provide an email address. Usage: rake member:delete'[[email protected]]'")
regexed_msg = Regexp.quote("You have to provide an email address. Usage: rake member:delete'[[email protected]]'")
expect { task.invoke }.to output(/#{regexed_msg}\s*/).to_stderr
.and raise_error(SystemExit)
end

it 'anonymises member information' do
Expand Down

0 comments on commit d083583

Please sign in to comment.