Sha256: 53770b28bd7f02ffd402c452ef8d58f6ad3ca6f2e978fe3c709d0aae4b6894e0

Contents?: true

Size: 753 Bytes

Versions: 12

Compression:

Stored size: 753 Bytes

Contents

require 'test_helper'
require 'rack/test'

class IdentityMapMiddlewareTest < Test::Unit::TestCase
  include Rack::Test::Methods

  def app
    @app ||= Rack::Builder.new do
      use MongoMapper::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
    should "clear the identity map" do
      MongoMapper::Plugins::IdentityMap.expects(:clear).twice
      get '/'
    end
  end

  context "when the request raises an error" do
    should "clear the identity map" do
      MongoMapper::Plugins::IdentityMap.expects(:clear).twice
      get '/fail' rescue nil
    end
  end


end

Version data entries

12 entries across 12 versions & 4 rubygems

Version Path
lookout-mongo_mapper-0.11.3 test/unit/test_identity_map_middleware.rb
mongo_mapper-0.11.2 test/unit/test_identity_map_middleware.rb
jamieorc-mongo_mapper-0.11.1.1 test/unit/test_identity_map_middleware.rb
mongo_mapper-0.11.1 test/unit/test_identity_map_middleware.rb
mongo_mapper-0.11.0 test/unit/test_identity_map_middleware.rb
mongo_mapper-0.10.1 test/unit/test_identity_map_middleware.rb
mongo_mapper-0.10.0 test/unit/test_identity_map_middleware.rb
mongo_mapper-0.9.2 test/unit/test_identity_map_middleware.rb
mongo_mapper-0.9.1 test/unit/test_identity_map_middleware.rb
mongo_mapper-0.9.0 test/unit/test_identity_map_middleware.rb
ign-mongo_mapper-0.8.6.2 test/unit/test_identity_map_middleware.rb
ign-mongo_mapper-0.8.6.1 test/unit/test_identity_map_middleware.rb