You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am working through our test-suite to add bullet, I cannot turn it on for all tests and therefore want to turn it on manually per test case. It works great with Bullet.raise = true, but I would like to get all warnings at once, therefore I tried using a solution based on kerrizor's solution and it looks like:
moduleBulletTestingdefbullet_setupBullet.enable=trueBullet.bullet_logger=trueBullet.start_requestenddefbullet_teardown# With a Rack-request it has already called `Bullet.end_request` here.returnunlessBullet.start?Bullet.perform_out_of_channel_notificationsifBullet.notification?ifBullet.warnings.present?warnings=Bullet.warnings.map{ |_k,warning| warning}.flatten.map{ |warn| warn.body_with_caller}.join("\n-----\n\n")flunk(warnings)endBullet.end_requestBullet.enable=falseBullet.reset_whitelistendend
It works great for ActionController::TestCase, but for ActionDispatch::IntegrationTest the request has always ended when I reach the bullet_teardown method because Bullet.end_request has been called in lib/bullet/rack.rb#call.
Questions
Is there anyway for me to disable the rack-integration?
Would it make sense with an option to disable internal calls to start_request and end_request?
Maybe Bullet.manual_requests = true?
Thank you!
The text was updated successfully, but these errors were encountered:
It's not entirely the same, but for selective usage I'm using this:
RSpec.configure do |config|
config.before(:each, :use_bullet_detectors) do
Bullet.start_request
end
config.after(:each, :use_bullet_detectors) do
Bullet.perform_out_of_channel_notifications if Bullet.notification?
Bullet.end_request
end
end
and then tagging the describe|context|it with :use_bullet_detectors.
Background
I am working through our test-suite to add bullet, I cannot turn it on for all tests and therefore want to turn it on manually per test case. It works great with
Bullet.raise = true
, but I would like to get all warnings at once, therefore I tried using a solution based on kerrizor's solution and it looks like:It works great for
ActionController::TestCase
, but forActionDispatch::IntegrationTest
the request has always ended when I reach thebullet_teardown
method becauseBullet.end_request
has been called inlib/bullet/rack.rb#call
.Questions
start_request
andend_request
?Maybe
Bullet.manual_requests = true
?Thank you!
The text was updated successfully, but these errors were encountered: