Sha256: 9b97c794ea08b03750b167af608009986fcf70ff32383a4a600f17ea01c5d7f4

Contents?: true

Size: 802 Bytes

Versions: 2

Compression:

Stored size: 802 Bytes

Contents

require 'spec_helper'

require 'ostruct'
require 'flail/rack'

describe Flail::Rack do

  subject { Flail::Rack.new lambda {|env| "val: #{env.fetch(:required_key)}" } }

  context "when an exception is raised by the app" do
    let(:env) { {} }

    it "should make an instance of Flail::Exception from the exception" do
      stub_fe = OpenStruct.new(:"handle!" => nil)
      mock(Flail::Exception).new(env, is_a(KeyError)) { stub_fe }

      # catch the re-raised KeyError so the spec isn't wrecked
      begin
        subject.call(env)
      rescue KeyError
      end
    end

    it "should handle the new Flail::Exception" do
      stub.proxy(Flail::Exception).new do |fe|
        mock(fe).handle!
      end

      begin
        subject.call(env)
      rescue KeyError
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
flail-0.1.6 spec/rack_spec.rb
flail-0.1.5 spec/rack_spec.rb