Sha256: cc86c75dc83d823b0ccc84d1b0f4d0e43827ed6fea472b1cd048c1844f19acd9

Contents?: true

Size: 1.61 KB

Versions: 22

Compression:

Stored size: 1.61 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(:each) 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

      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

22 entries across 22 versions & 1 rubygems

Version Path
rollbar-2.9.1 spec/requests/home_spec.rb
rollbar-2.9.0 spec/requests/home_spec.rb
rollbar-2.8.3 spec/requests/home_spec.rb
rollbar-2.8.2 spec/requests/home_spec.rb
rollbar-2.8.1 spec/requests/home_spec.rb
rollbar-2.8.0 spec/requests/home_spec.rb
rollbar-2.7.1 spec/requests/home_spec.rb
rollbar-2.7.0 spec/requests/home_spec.rb
rollbar-2.6.3 spec/requests/home_spec.rb
rollbar-2.6.2 spec/requests/home_spec.rb
rollbar-2.6.1 spec/requests/home_spec.rb
rollbar-2.6.0 spec/requests/home_spec.rb
rollbar-2.5.2 spec/requests/home_spec.rb
rollbar-2.5.1 spec/requests/home_spec.rb
rollbar-2.5.0 spec/requests/home_spec.rb
rollbar-2.4.0 spec/requests/home_spec.rb
rollbar-2.3.0 spec/requests/home_spec.rb
rollbar-2.2.1 spec/requests/home_spec.rb
rollbar-2.2.0 spec/requests/home_spec.rb
rollbar-2.1.2 spec/requests/home_spec.rb