Created
September 7, 2020 17:00
-
-
Save palkan/1652e91e061afb9eeebdfc7ccce0c937 to your computer and use it in GitHub Desktop.
Bulletify: RSpec helpers to run Bullet in tests
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
RSpec.shared_context "bullet" do | |
before(:each) do | |
Bullet.enable = true | |
Bullet.bullet_logger = true | |
Bullet.raise = true # raise an error if N+1 query occurs | |
Bullet.start_request | |
end | |
after(:each) do | |
Bullet.perform_out_of_channel_notifications if Bullet.notification? | |
Bullet.end_request | |
Bullet.enable = false | |
Bullet.bullet_logger = false | |
Bullet.raise = false | |
end | |
end | |
RSpec.configure do |config| | |
config.include_context "bullet", bullet: true | |
config.alias_example_to :bulletify, bullet: true | |
end | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# spec/controllers/my_controller_spec.rb | |
context "N+1" do | |
bulletify { get :index } | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment