request_store 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f85cc719e97b2fd7d14f66225abf332e8f6a1248
4
- data.tar.gz: 8b850f88cdaff14f6150e8799a931d85935402e6
3
+ metadata.gz: 348deb2b9d7db6347123b67d18b5d4eb2c8001ed
4
+ data.tar.gz: 8296b65a72b085eec44e257b018340e392d787ee
5
5
  SHA512:
6
- metadata.gz: 6628a9dbf581592b306082f4782d44c0577b34eea89dbe3d231ece2b069a7b8b5b51dc9a6993df058dd989aeeda2a26e7dc35f5d7ca0f8353cbc1a918502322f
7
- data.tar.gz: d18615c3d9a6cd02bea10a119b549690d15cf87fbb0e9b3d62947ce7d004e55952124f5f7172a404b976bdaa7e2659ba135fca6ecc92563084d3edc3451d39df
6
+ metadata.gz: b7fe4a75ba1e5a5bd6c578c822b12d1982118178f95a391ac6a716e7364241e1b41e98eb4193032765c6a31103366fd497ccad181ee3d10aa44fbc4284175905
7
+ data.tar.gz: 645b2404581a8f991e38f4a83cf0fee31f4444ba7fddb2beaea8f0bd5e1f15ab16af281ee85acb105035e21308a011ecc1977ca35851b66d2f45411471ad8c54
@@ -1,4 +1,5 @@
1
1
  language: ruby
2
+ sudo: false
2
3
  rvm:
3
4
  - 1.8.7
4
5
  - 1.9.2
data/README.md CHANGED
@@ -81,6 +81,23 @@ You'll probably have to shove this somewhere:
81
81
  use RequestStore::Middleware
82
82
  ```
83
83
 
84
+ #### No Rails + Rack::Test
85
+
86
+ In order to have `RequestStore` storage cleared between requests, add it to the
87
+ `app`:
88
+
89
+ ```ruby
90
+ # spec_helper.rb
91
+
92
+ def app
93
+ Rack::Builder.new do
94
+ use RequestStore::Middleware
95
+ run MyApp
96
+ end
97
+ end
98
+ ```
99
+
100
+
84
101
  ## Contributing
85
102
 
86
103
  1. Fork it
@@ -6,6 +6,12 @@ module RequestStore
6
6
  else
7
7
  app.config.middleware.insert_after Rack::MethodOverride, RequestStore::Middleware
8
8
  end
9
+
10
+ if ActionDispatch.const_defined?(:Reloader) && ActionDispatch::Reloader.respond_to?(:to_cleanup)
11
+ ActionDispatch::Reloader.to_cleanup do
12
+ RequestStore.clear!
13
+ end
14
+ end
9
15
  end
10
16
  end
11
17
  end
@@ -1,3 +1,3 @@
1
1
  module RequestStore
2
- VERSION = "1.1.0"
2
+ VERSION = "1.2.0"
3
3
  end
@@ -18,5 +18,5 @@ Gem::Specification.new do |gem|
18
18
  gem.require_paths = ["lib"]
19
19
 
20
20
  gem.add_development_dependency "rake"
21
- gem.add_development_dependency 'minitest', '~> 3.0'
21
+ gem.add_development_dependency "minitest", "~> 5.0"
22
22
  end
@@ -1,8 +1,9 @@
1
+ require 'minitest/test'
1
2
  require 'minitest/autorun'
2
3
 
3
4
  require 'request_store'
4
5
 
5
- class MiddlewareTest < Minitest::Unit::TestCase
6
+ class MiddlewareTest < Minitest::Test
6
7
  def setup
7
8
  @app = RackApp.new
8
9
  @middleware = RequestStore::Middleware.new(@app)
@@ -16,14 +17,11 @@ class MiddlewareTest < Minitest::Unit::TestCase
16
17
  end
17
18
 
18
19
  def test_middleware_resets_store_on_error
19
- errors = []
20
- begin
20
+ e = assert_raises RuntimeError do
21
21
  @middleware.call({:error => true})
22
- rescue => e
23
- errors << e
24
22
  end
25
23
 
26
- assert_equal ['FAIL'], errors.map(&:message)
24
+ assert_equal 'FAIL', e.message
27
25
  assert_equal({}, RequestStore.store)
28
26
  end
29
27
  end
@@ -2,40 +2,39 @@ require 'minitest/autorun'
2
2
 
3
3
  require 'request_store'
4
4
 
5
- class RequestStoreTest < Minitest::Unit::TestCase
5
+ class RequestStoreTest < Minitest::Test
6
+ def setup
7
+ RequestStore.clear!
8
+ end
9
+
6
10
  def test_initial_state
7
11
  Thread.current[:request_store] = nil
8
12
  assert_equal RequestStore.store, Hash.new
9
13
  end
10
14
 
11
15
  def test_init_with_hash
12
- RequestStore.clear!
13
16
  assert_equal Hash.new, RequestStore.store
14
17
  end
15
18
 
16
19
  def test_clear
17
- RequestStore.clear!
18
20
  RequestStore.store[:foo] = 1
19
21
  RequestStore.clear!
20
22
  assert_equal Hash.new, RequestStore.store
21
23
  end
22
24
 
23
25
  def test_quacks_like_hash
24
- RequestStore.clear!
25
26
  RequestStore.store[:foo] = 1
26
27
  assert_equal 1, RequestStore.store[:foo]
27
28
  assert_equal 1, RequestStore.store.fetch(:foo)
28
29
  end
29
30
 
30
31
  def test_read
31
- RequestStore.clear!
32
32
  RequestStore.store[:foo] = 1
33
33
  assert_equal 1, RequestStore.read(:foo)
34
34
  assert_equal 1, RequestStore[:foo]
35
35
  end
36
36
 
37
37
  def test_write
38
- RequestStore.clear!
39
38
  RequestStore.write(:foo, 1)
40
39
  assert_equal 1, RequestStore.store[:foo]
41
40
  RequestStore[:foo] = 2
@@ -43,20 +42,17 @@ class RequestStoreTest < Minitest::Unit::TestCase
43
42
  end
44
43
 
45
44
  def test_fetch
46
- RequestStore.clear!
47
45
  assert_equal 2, RequestStore.fetch(:foo) { 1 + 1 }
48
46
  assert_equal 2, RequestStore.fetch(:foo) { 2 + 2 }
49
47
  end
50
48
 
51
49
  def test_delete
52
- RequestStore.clear!
53
50
  assert_equal 2, RequestStore.fetch(:foo) { 1 + 1 }
54
51
  assert_equal 2, RequestStore.delete(:foo) { 2 + 2 }
55
52
  assert_equal 4, RequestStore.delete(:foo) { 2 + 2 }
56
53
  end
57
54
 
58
55
  def test_delegates_to_thread
59
- RequestStore.clear!
60
56
  RequestStore.store[:foo] = 1
61
57
  assert_equal 1, Thread.current[:request_store][:foo]
62
58
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: request_store
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steve Klabnik
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-15 00:00:00.000000000 Z
11
+ date: 2015-07-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '3.0'
33
+ version: '5.0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '3.0'
40
+ version: '5.0'
41
41
  description: RequestStore gives you per-request global storage.
42
42
  email:
43
43
  - steve@steveklabnik.com