Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for notifiers which works on collections #665

Open
davidwessman opened this issue Aug 14, 2023 · 0 comments
Open

Add support for notifiers which works on collections #665

davidwessman opened this issue Aug 14, 2023 · 0 comments

Comments

@davidwessman
Copy link

Hello!

I would really like a raise_all mode when running Bullet in tests.

Instead of just raising the first error, I want it to raise all of them at once.
I cannot see how this could be implemented with the current pattern of the notifiers.

Currently we are using a custom bullet_teardown after each test and monkey-patched the Bullet::Rack middleware to combine all errors the same way:

def bullet_teardown
  return unless Bullet.start?

  Bullet.perform_out_of_channel_notifications if Bullet.notification?
  if Bullet.warnings.present?
    warnings = "[Bullet warnings]\n"
    warnings += Bullet.warnings
      .values.flatten
      .map do |warning|
        "#{warning.class.name}\n#{warning.body_with_caller}"
      end.join("\n-----\n\n")

    raise(StandardError, warnings)
  end
ensure
  Bullet.end_request
  Bullet.enable = false
  Bullet.reset_safelist
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant