From d083583073f2854ec5cac613e7829a1bb5bc6025 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gon=C3=A7alo=20Morais?= Date: Sat, 15 Jul 2023 08:03:32 +0200 Subject: [PATCH] Fix two rogue messages on tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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@address.com]' - 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. --- spec/fabricators/sponsor_fabricator.rb | 1 + spec/lib/tasks/delete_member_rake_spec.rb | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/spec/fabricators/sponsor_fabricator.rb b/spec/fabricators/sponsor_fabricator.rb index 80f336a83..1c4327a93 100644 --- a/spec/fabricators/sponsor_fabricator.rb +++ b/spec/fabricators/sponsor_fabricator.rb @@ -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 diff --git a/spec/lib/tasks/delete_member_rake_spec.rb b/spec/lib/tasks/delete_member_rake_spec.rb index d7174fe75..173c6e032 100644 --- a/spec/lib/tasks/delete_member_rake_spec.rb +++ b/spec/lib/tasks/delete_member_rake_spec.rb @@ -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@address.com]'") + regexed_msg = Regexp.quote("You have to provide an email address. Usage: rake member:delete'[email@address.com]'") + expect { task.invoke }.to output(/#{regexed_msg}\s*/).to_stderr + .and raise_error(SystemExit) end it 'anonymises member information' do