Sha256: 637dfa5bf7d5c11438e02fba6cbe37ec7d8f30bd78dd59dbe7d7878dd4203a6b

Contents?: true

Size: 695 Bytes

Versions: 9

Compression:

Stored size: 695 Bytes

Contents

require 'helper'
require 'rack/test'

describe Toy::Middleware::IdentityMap do
  include Rack::Test::Methods

  def app
    @app ||= Rack::Builder.new do
      use Toy::Middleware::IdentityMap
      map "/" do
        run lambda {|env| [200, {}, []] }
      end
      map "/fail" do
        run lambda {|env| raise "FAIL!" }
      end
    end.to_app
  end

  context "with a successful request" do
    it "clear the identity map" do
      Toy.identity_map.should_receive(:clear).twice
      get '/'
    end
  end

  context "when the request raises an error" do
    it "clear the identity map" do
      Toy.identity_map.should_receive(:clear).twice
      get '/fail' rescue nil
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
toystore-0.8.3 spec/toy/middleware/identity_map_spec.rb
toystore-0.8.2 spec/toy/middleware/identity_map_spec.rb
toystore-0.8.1 spec/toy/middleware/identity_map_spec.rb
toystore-0.8.0 spec/toy/middleware/identity_map_spec.rb
toystore-0.7.0 spec/toy/middleware/identity_map_spec.rb
toystore-0.6.6 spec/toy/middleware/identity_map_spec.rb
toystore-0.6.5 spec/toy/middleware/identity_map_spec.rb
toystore-0.6.4 spec/toy/middleware/identity_map_spec.rb
toystore-0.6.3 spec/toy/middleware/identity_map_spec.rb