Sha256: fb11b4e7d3db350d1fbd6cc4e976a7ea8c5de6124abc8119fbc4c2728efffaa7

Contents?: true

Size: 819 Bytes

Versions: 2

Compression:

Stored size: 819 Bytes

Contents

require 'minitest/autorun'

require 'request_store'

class RequestStoreTest < Minitest::Unit::TestCase
  def test_initial_state
    Thread.current[:request_store] = nil
    assert_equal RequestStore.store, Hash.new
  end

  def test_init_with_hash
    RequestStore.clear!
    assert_equal Hash.new, RequestStore.store
  end

  def test_clear
    RequestStore.clear!
    RequestStore.store[:foo] = 1
    RequestStore.clear!
    assert_equal Hash.new, RequestStore.store
  end

  def test_quacks_like_hash
    RequestStore.clear!
    RequestStore.store[:foo] = 1
    assert_equal 1, RequestStore.store[:foo]
    assert_equal 1, RequestStore.store.fetch(:foo)
  end

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
request_store-1.0.5 test/request_store_test.rb
request_store-1.0.3 test/request_store_test.rb