Last active
December 2, 2018 06:41
-
-
Save dpaluy/9f9d3982c1dab07d869564358734be16 to your computer and use it in GitHub Desktop.
Bullet in RSpec
This file contains hidden or 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 |
This file contains hidden or 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/rails_helper.rb | |
| require_relative "support" | |
| config.alias_example_to :bulletify, bullet: true |
This file contains hidden or 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/support.rb | |
| shared_context "bullet", bullet: true 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment