rack-berater 0.3.2 → 0.4.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
  SHA256:
3
- metadata.gz: d9e1b9ca0c696948b6d7ec973e1855c71a73fe9ca59d0833107e57295d2d9f21
4
- data.tar.gz: fcbbeef6465c6f7cefa0c110401e4c80d6462ea3adc69a7a1e3975e19e9f8355
3
+ metadata.gz: 5781e3d2d2b482f08801da66f94cda264ece7e1310bb0f5adaafefc12e5a61a5
4
+ data.tar.gz: b32888c349ced36fbdfb1b4c941dd32a45ba8a19a61c0cd553d3e208cbd39126
5
5
  SHA512:
6
- metadata.gz: 6d00a14d8136ac96cac236c4bb2ff55c98871dc32cb85b30d8800b4784526cb27c53e54979703f554cb1698ea99093ea77584222dab213f4cbbbe6aeba1b2e71
7
- data.tar.gz: 03b030982e003903461f929853138f7c4dcbffbfbcccb2aba1335ffac6e2aa9aeb0b265c4c13d3ebc6f1e04ef4acc1c942606c9d57f44cf2003c3a46e42b8c64
6
+ metadata.gz: 92bc69dd2604250f0cdda1f5ab28ea3af4bb1059d6e284b5e51f70e15b5011a7a5f9bb2429a843b4b361081d95076f9483181d072617d1695e281630455b8101
7
+ data.tar.gz: 8ff2a5d2f76aabcd7b6e3a84a79be08591d8deaf995bbd99490be2e4bd9094406403ca161cb67aa1e30cb74325743373a391091d4285b233ba0adf5dc8578fab
@@ -9,6 +9,8 @@ module Rack
9
9
  def initialize(app, options = {})
10
10
  @app = app
11
11
  @header = options[:header] || HEADER
12
+
13
+ synchronize { @@cache ||= {} }
12
14
  end
13
15
 
14
16
  def call(env)
@@ -57,7 +59,6 @@ module Rack
57
59
  ].join(':')
58
60
  end
59
61
 
60
- @@cache = {}
61
62
  def cache_get(key)
62
63
  synchronize { @@cache[key] }
63
64
  end
@@ -0,0 +1,9 @@
1
+ require 'rack/berater'
2
+ require 'rspec/core'
3
+
4
+ RSpec.configure do |config|
5
+ config.after do
6
+ Thread.current[Rack::Berater::Prioritizer::ENV_KEY] = nil
7
+ Rack::Berater::Prioritizer.class_variable_set(:@@cache, nil)
8
+ end
9
+ end
@@ -1,5 +1,5 @@
1
1
  module Rack
2
2
  class Berater
3
- VERSION = "0.3.2"
3
+ VERSION = "0.4.0"
4
4
  end
5
5
  end
@@ -1,9 +1,4 @@
1
1
  describe Rack::Berater::Prioritizer do
2
- after do
3
- cache.clear
4
- Thread.current[described_class::ENV_KEY] = nil
5
- end
6
-
7
2
  let(:cache) { described_class.class_variable_get(:@@cache) }
8
3
 
9
4
  describe '#call' do
@@ -30,6 +30,7 @@ describe Rack::Berater::RailsPrioritizer do
30
30
  get '/' => 'echo#index'
31
31
  get '/six' => 'echo#six'
32
32
  post '/nine' => 'echo#nine'
33
+ get '/redirect' => redirect('/')
33
34
  end
34
35
  end
35
36
 
@@ -37,8 +38,6 @@ describe Rack::Berater::RailsPrioritizer do
37
38
  let(:middleware) { described_class.new(app) }
38
39
 
39
40
  after do
40
- cache.clear
41
- Thread.current[described_class::ENV_KEY] = nil
42
41
  Rails.application = nil
43
42
  end
44
43
 
@@ -66,6 +65,12 @@ describe Rack::Berater::RailsPrioritizer do
66
65
  subject.call(Rack::MockRequest.env_for('/nine'))
67
66
  ).to match %r{get:/nine}
68
67
  end
68
+
69
+ it 'works with redirects' do
70
+ expect(
71
+ subject.call(Rack::MockRequest.env_for('/redirect'))
72
+ ).to match %r{get:/redirect}
73
+ end
69
74
  end
70
75
 
71
76
  context 'when a priority header is sent' do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-berater
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Pepper
@@ -147,6 +147,7 @@ files:
147
147
  - lib/rack/berater/prioritizer.rb
148
148
  - lib/rack/berater/rails_prioritizer.rb
149
149
  - lib/rack/berater/railtie.rb
150
+ - lib/rack/berater/rspec.rb
150
151
  - lib/rack/berater/version.rb
151
152
  - spec/limiter_spec.rb
152
153
  - spec/prioritizer_spec.rb