Sha256: 45e8c1c31358ee5d51c237a44d0af4cfd58176a128e223167c6320684e3b4fb8
Contents?: true
Size: 1.49 KB
Versions: 3
Compression:
Stored size: 1.49 KB
Contents
require "spec_helper" describe Timber::Probes::ActionDispatchDebugExceptions do describe "#{described_class}::*InstanceMethods" do describe "#log_error" do let(:time) { Time.utc(2016, 9, 1, 12, 0, 0) } let(:io) { StringIO.new } let(:logger) do logger = Timber::Logger.new(io) logger.level = ::Logger::DEBUG logger end around(:each) do |example| class ExceptionController < ActionController::Base layout nil def index raise "boom" end def method_for_action(action_name) action_name end end ::RailsApp.routes.draw do get 'exception' => 'exception#index' end Timecop.freeze(time) { example.run } Object.send(:remove_const, :ExceptionController) end it "should set the context" do mock_class dispatch_rails_request("/exception") # Because constantly updating the line numbers sucks :/ expect(io.string).to include("RuntimeError (boom):\n\n") expect(io.string).to include("@timber.io") expect(io.string).to include("\"event\":{\"exception\":{\"name\":\"RuntimeError\",\"message\":\"boom\",\"backtrace\":[\"") end def mock_class klass = defined?(::ActionDispatch::DebugExceptions) ? ::ActionDispatch::DebugExceptions : ::ActionDispatch::ShowExceptions allow_any_instance_of(klass).to receive(:logger).and_return(logger) end end end end
Version data entries
3 entries across 3 versions & 1 rubygems