Sha256: 989bad1f72211fc608533aca7896cd3b042d7bd370e8ab1e37f4ae357940f881

Contents?: true

Size: 1.62 KB

Versions: 5

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
    Ratchetio.configure do |config|
      config.access_token = 'aaaabbbbccccddddeeeeffff00001111'
      config.environment = ::Rails.env
      config.root = ::Rails.root
      config.framework = "Rails: #{::Rails::VERSION::STRING}"
      config.logger = logger_mock
    end
  end

  context "with broken request" do
    it "should report uncaught exceptions" do
      expect{ get 'current_user', nil, :cookie => '8%B' }.to raise_exception

      exception_info = Ratchetio.last_report[:body][:trace][:exception]
      exception_info[:class].should == 'ArgumentError'
      exception_info[:message].should == 'invalid %-encoding (8%B)'
    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

      exception_info = Ratchetio.last_report[:body][:trace][:exception]
      exception_info[:class].should == 'NoMethodError'
      # exception_info[:message].should == 'undefined method `-\' for "1":String'
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
ratchetio-0.7.1 spec/requests/home_spec.rb
ratchetio-0.7.0 spec/requests/home_spec.rb
ratchetio-0.6.3 spec/requests/home_spec.rb
ratchetio-0.6.1 spec/requests/home_spec.rb
ratchetio-0.6.0 spec/requests/home_spec.rb