Sha256: 0b051e932a7e71e9cd8688097aef26d0dc951b9c27553c37171b6b34fef13fdf

Contents?: true

Size: 1.62 KB

Versions: 20

Compression:

Stored size: 1.62 KB

Contents

require 'spec_helper'

describe HomeController do
  let(:logger_mock) { double("Rails.logger").as_null_object }

  before(:each) do
    reset_configuration
    reconfigure_notifier
  end

  context "with broken request" do
    it "should report uncaught exceptions" do
      # only seems to be relevant in 3.1 and 3.2
      if ::Rails::VERSION::STRING.starts_with? "3.1" or ::Rails::VERSION::STRING.starts_with? "3.2"
        expect { get '/current_user', nil, :cookie => '8%B' }.to raise_exception

        Rollbar.last_report.should_not be_nil

        exception_info = Rollbar.last_report[:body][:trace][:exception]
        exception_info[:class].should == 'ArgumentError'
        exception_info[:message].should == 'invalid %-encoding (8%B)'
      end
    end
  end

  context "with error hiding deep inside" do
    let!(:cookie_method_name){ :[] }
    let!(:original_cookie_method){ ActionDispatch::Cookies::CookieJar.instance_method(cookie_method_name) }
    let!(:broken_cookie_method){ Proc.new{ |name| "1" - 1 } }

    before(:each) do
      ActionDispatch::Cookies::CookieJar.send(:define_method, cookie_method_name, broken_cookie_method)
    end

    after do
      ActionDispatch::Cookies::CookieJar.send(:define_method, cookie_method_name, original_cookie_method)
    end

    it "should report uncaught exceptions" do
      expect { get '/current_user' }.to raise_exception(NoMethodError)

      body = Rollbar.last_report[:body]
      trace = body[:trace] && body[:trace] || body[:trace_chain][0]

      trace[:exception][:class].should == 'NoMethodError'
      trace[:exception][:message].should =~ /^undefined method `-'/
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
rollbar-2.18.2 spec/requests/home_spec.rb
rollbar-2.18.0 spec/requests/home_spec.rb
rollbar-2.17.0 spec/requests/home_spec.rb
rollbar-2.16.4 spec/requests/home_spec.rb
rollbar-2.16.3 spec/requests/home_spec.rb
rollbar-2.16.2 spec/requests/home_spec.rb
rollbar-2.16.0 spec/requests/home_spec.rb
rollbar-2.15.6 spec/requests/home_spec.rb
rollbar-2.15.5 spec/requests/home_spec.rb
rollbar-2.15.4 spec/requests/home_spec.rb
rollbar-2.15.3 spec/requests/home_spec.rb
rollbar-2.15.2 spec/requests/home_spec.rb
rollbar-2.15.1 spec/requests/home_spec.rb
rollbar-2.15.0 spec/requests/home_spec.rb
rollbar-2.14.1 spec/requests/home_spec.rb
rollbar-2.14.0 spec/requests/home_spec.rb
rollbar-2.13.3 spec/requests/home_spec.rb
rollbar-2.13.2 spec/requests/home_spec.rb
rollbar-2.13.1 spec/requests/home_spec.rb
rollbar-2.13.0 spec/requests/home_spec.rb