Skip to content

Commit

Permalink
Merge pull request #734 from Uaitt/add-minitest-setup-in-readme
Browse files Browse the repository at this point in the history
Add Minitest setup in README.md
  • Loading branch information
flyerhzm authored Feb 17, 2025
2 parents 21028dc + 53e77e1 commit b34f34e
Showing 1 changed file with 25 additions and 3 deletions.
28 changes: 25 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ If your application generates a Content-Security-Policy via a separate middlewar

### Run in tests

First you need to enable Bullet in test environment.
First you need to enable Bullet in the test environment.

```ruby
# config/environments/test.rb
Expand All @@ -251,11 +251,13 @@ config.after_initialize do
end
```

Then wrap each test in Bullet api.
Then wrap each test in the Bullet api.

With RSpec:

```ruby
# spec/rails_helper.rb
if Bullet.enable?
RSpec.configure do |config|
config.before(:each) do
Bullet.start_request
end
Expand All @@ -267,6 +269,26 @@ if Bullet.enable?
end
```

With Minitest:

```ruby
# test/test_helper.rb
module ActiveSupport
class TestCase
def before_setup
Bullet.start_request
super
end

def after_teardown
super
Bullet.perform_out_of_channel_notifications if Bullet.notification?
Bullet.end_request
end
end
end
```

## Debug Mode

Bullet outputs some details info, to enable debug mode, set
Expand Down

0 comments on commit b34f34e

Please sign in to comment.