Sha256: 83e01f2a3827d3b2b170b8a90ab56205f07024f6cea2a6513dfa05e5264296d2

Contents?: true

Size: 607 Bytes

Versions: 4

Compression:

Stored size: 607 Bytes

Contents

require 'minitest/autorun'

require 'request_store'

class MiddlewareTest < Minitest::Unit::TestCase
  def setup
    @app = RackApp.new
    @middleware = RequestStore::Middleware.new(@app)
  end

  def test_middleware_resets_store
    2.times { @middleware.call({}) }

    assert_equal 1, @app.last_value
    assert_equal({}, RequestStore.store)
  end

  def test_middleware_resets_store_on_error
    errors = []
    begin
      @middleware.call({:error => true})
    rescue => e
      errors << e
    end

    assert_equal ['FAIL'], errors.map(&:message)
    assert_equal({}, RequestStore.store)
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
request_store-1.1.0 test/middleware_test.rb
request_store-1.0.8 test/middleware_test.rb
request_store-1.0.7 test/middleware_test.rb
request_store-1.0.6 test/middleware_test.rb