Sha256: dd8f58497e492206de47ad2e2d779b5b5d8f44f249515c5df9de409b5d4131b5
Contents?: true
Size: 1.52 KB
Versions: 19
Compression:
Stored size: 1.52 KB
Contents
require File.expand_path '../helper', __FILE__ 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 %w(rack.exception sinatra.error).each do |ex| should "deliver an exception in #{ex}" do Airbrake.stubs(:notify_or_ignore) exception = build_exception environment = { 'key' => 'value' } response = [200, {}, ['okay']] app = lambda do |env| env[ex] = 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 end
Version data entries
19 entries across 19 versions & 2 rubygems