Sha256: 3025d80d1adca556cd796ca136238c54c7cb0ecfa1db5b148df6a2ab077b59dd

Contents?: true

Size: 672 Bytes

Versions: 3

Compression:

Stored size: 672 Bytes

Contents

require 'minitest/autorun'

require 'request_store'

class RequestStoreTest < Minitest::Unit::TestCase
  def test_quacks_like_hash
    RequestStore.store[:foo] = 1
    assert_equal 1, RequestStore.store[:foo]
    assert_equal 1, RequestStore.store.fetch(:foo)
  end

  def test_delegates_to_thread
    RequestStore.store[:foo] = 1
    assert_equal 1, Thread.current[:request_store][:foo]
  end
end

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

    middleware.call({})
    middleware.call({})

    assert_equal 1, Thread.current[:request_store][:foo]
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
request_store-1.0.2 test/request_store_test.rb
request_store-1.0.1 test/request_store_test.rb
request_store-1.0.0 test/request_store_test.rb