Sha256: b1962f729a675c3d5c7ccf14b4e7274401e3104815fc013ba6d797da550ff5d1

Contents?: true

Size: 1.46 KB

Versions: 15

Compression:

Stored size: 1.46 KB

Contents

require File.dirname(__FILE__) + '/helper'

class RackTest < Test::Unit::TestCase

  should "call the upstream app with the environment" do
    environment = { 'key' => 'value' }
    app = lambda { |env| ['response', {}, env] }
    stack = Airbrake::Rack.new(app)

    response = stack.call(environment)

    assert_equal ['response', {}, environment], response
  end

  should "deliver an exception raised while calling an upstream app" do
    Airbrake.stubs(:notify_or_ignore)

    exception = build_exception
    environment = { 'key' => 'value' }
    app = lambda do |env|
      raise exception
    end

    begin
      stack = Airbrake::Rack.new(app)
      stack.call(environment)
    rescue Exception => raised
      assert_equal exception, raised
    else
      flunk "Didn't raise an exception"
    end

    assert_received(Airbrake, :notify_or_ignore) do |expect|
      expect.with(exception, :rack_env => environment)
    end
  end

  should "deliver an exception in rack.exception" do
    Airbrake.stubs(:notify_or_ignore)
    exception = build_exception
    environment = { 'key' => 'value' }

    response = [200, {}, ['okay']]
    app = lambda do |env|
      env['rack.exception'] = exception
      response
    end
    stack = Airbrake::Rack.new(app)

    actual_response = stack.call(environment)

    assert_equal response, actual_response
    assert_received(Airbrake, :notify_or_ignore) do |expect|
      expect.with(exception, :rack_env => environment)
    end
  end

end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
airbrake-3.1.2 test/rack_test.rb
airbrake-3.1.1 test/rack_test.rb
airbrake-3.1.0 test/rack_test.rb
airbrake-3.0.9 test/rack_test.rb
airbrake-3.0.8 test/rack_test.rb
airbrake-3.0.7 test/rack_test.rb
airbrake-3.0.6 test/rack_test.rb
airbrake-3.0.5 test/rack_test.rb
airbrake-3.0.4 test/rack_test.rb
airbrake-3.0.3 test/rack_test.rb
airbrake-3.0.2 test/rack_test.rb
airbrake-3.0.1 test/rack_test.rb
airbrake-3.0 test/rack_test.rb
airbrake-3.0.rc2 test/rack_test.rb
airbrake-3.0.rc1 test/rack_test.rb