Sha256: cd7e8f7709389d3c222b9d01d15271f8b28261dd1c68ae8051b8f9ac7ff7991a
Contents?: true
Size: 1.52 KB
Versions: 1
Compression:
Stored size: 1.52 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\":{\"server_side_app\":{\"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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
timber-1.1.0 | spec/timber/probes/action_dispatch_debug_exceptions_spec.rb |