Skip to content

Instantly share code, notes, and snippets.

@girasquid
Created July 8, 2019 18:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save girasquid/937d8d0e9b13875307865775bc0324d0 to your computer and use it in GitHub Desktop.
Save girasquid/937d8d0e9b13875307865775bc0324d0 to your computer and use it in GitHub Desktop.
context "making sure we don't accidentally take the site down" do
EXPECTED_NUMBER_OF_WORKERS = 10 # copy this value from the other place it's defined; this shouldn't be dynamic, repeating yourself is better
it "reminds the user of side effects" do
begin
expect(MySystem::NUMBER_OF_WORKERS).to eq(EXPECTED_NUMBER_OF_WORKERS)
rescue RSpec::Expectations::ExpectationNotMetError => error
error.message << "\n"
error.message << <<~HEREDOC
📎 Oh hi there! It looks like you changed the value of MySystem::NUMBER_OF_WORKERS.
This constant is used to determine how many workers should process a job from the queue
at any given time, so changing it has some very meaningful side effects.
If this is what you intended - great! Update this test with the new value and you're good to go.
If it's not what you intended - please set the value back to #{EXPECTED_NUMBER_OF_WORKERS}.
HEREDOC
raise error
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment