Skip to content

Instantly share code, notes, and snippets.

@jaydorsey
Created August 21, 2024 13:33
Show Gist options
  • Save jaydorsey/a1e809faa72ba59cf332aa847128f046 to your computer and use it in GitHub Desktop.
Save jaydorsey/a1e809faa72ba59cf332aa847128f046 to your computer and use it in GitHub Desktop.
Rescueing a flakey spec to debug
RSpec.describe MyClass do
let(:my_value) { 1 }
let(:other_value) { 2 }
it 'does a thing' do
expect(my_value).to eq(other_value) # failure condition, something flakey though
rescue RSpec::Expectations::ExpectationNotMetError
$ERROR_INFO.message << <<~MSG
This spec is flakey in CI. Here is some debug information.
If it fails again and you don't know why, please feel free to add more debug information.
Sidekiq::Testing.inline?: #{Sidekiq::Testing.inline?}
Sidekiq::Testing.fake?: #{Sidekiq::Testing.fake?}
my_value: #{my_value}
other_value: #{other_value}
MSG
raise
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment