Created
May 12, 2011 10:23
-
-
Save nruth/968289 to your computer and use it in GitHub Desktop.
controller spec describing rails log contents
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
describe "logger" do | |
before(:each) do | |
@old_flush = controller.logger.auto_flushing | |
@old_level = controller.logger.level | |
controller.logger.auto_flushing=0 | |
controller.logger.level = ActiveSupport::BufferedLogger::Severity::ERROR | |
end | |
it "logs an error" do | |
#would prefer to test this with a test-spy / mock expectations but there's a lot of level-0 logging noise to ignore, so went with reading the log itself | |
post :create, valid_notification_params | |
controller.logger.send(:buffer).join.should include("expected log contents") | |
end | |
after(:each) do | |
controller.logger.auto_flushing= @old_flush | |
controller.logger.level = @old_level | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment