Skip to content

Instantly share code, notes, and snippets.

@skwp
Last active August 29, 2015 14:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save skwp/41778311b0581dddb4b4 to your computer and use it in GitHub Desktop.
Save skwp/41778311b0581dddb4b4 to your computer and use it in GitHub Desktop.
Logger that logs to a string
describe "something with a logger" do
let(:logger) { TestLogger.new }
before { Rails.logger = logger }
specify do
# ... call your code ...
logger.messages.should include("my message")
end
end
class TestLogger < Logger
def initialize
@strio = StringIO.new
super(@strio)
end
def messages
@strio.string
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment