Sha256: 03ac06c9d98f94bce0420017f6985c72474769e33db8163cd614b0b9680a742c
Contents?: true
Size: 1.51 KB
Versions: 5
Compression:
Stored size: 1.51 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 = ErrornotNotifier::Rack.new(app) response = stack.call(environment) assert_equal ['response', {}, environment], response end should "deliver an exception raised while calling an upstream app" do ErrornotNotifier.stubs(:notify_or_ignore) exception = build_exception environment = { 'key' => 'value' } app = lambda do |env| raise exception end begin stack = ErrornotNotifier::Rack.new(app) stack.call(environment) rescue Exception => raised assert_equal exception, raised else flunk "Didn't raise an exception" end assert_received(ErrornotNotifier, :notify_or_ignore) do |expect| expect.with(exception, :rack_env => environment) end end should "deliver an exception in rack.exception" do ErrornotNotifier.stubs(:notify_or_ignore) exception = build_exception environment = { 'key' => 'value' } response = [200, {}, ['okay']] app = lambda do |env| env['rack.exception'] = exception response end stack = ErrornotNotifier::Rack.new(app) actual_response = stack.call(environment) assert_equal response, actual_response assert_received(ErrornotNotifier, :notify_or_ignore) do |expect| expect.with(exception, :rack_env => environment) end end end
Version data entries
5 entries across 5 versions & 1 rubygems