forked from railslove/rack-tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhandler_spec.rb
More file actions
38 lines (32 loc) · 1.04 KB
/
handler_spec.rb
File metadata and controls
38 lines (32 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
RSpec.describe Rack::Tracker::Handler do
def env
{ misc: 'foobar' }
end
describe '#tracker_options' do
context 'without overriding allowed_tracker_options' do
subject { described_class.new(env, { some_option: 'value' }) }
it 'returns an empty hash' do
expect(subject.tracker_options).to eql ({})
end
end
context 'with overridden allowed_tracker_options' do
subject do
handler = described_class.new(env, {
static_option: 'value',
dynamic_option: lambda { |env| return env[:misc] },
dynamic_nil_option: lambda { |env| return env[:non_existent_key] },
non_allowed_option: 'value'
})
handler.allowed_tracker_options =
[:static_option, :dynamic_option, :dynamic_nil_option]
handler
end
it 'evaluates dynamic options, rejecting nonallowed and nil ones' do
expect(subject.tracker_options).to eql ({
static_option: 'value',
dynamic_option: 'foobar'
})
end
end
end
end