File tree Expand file tree Collapse file tree 2 files changed +12
-6
lines changed
spec/datadog/appsec/api_security Expand file tree Collapse file tree 2 files changed +12
-6
lines changed Original file line number Diff line number Diff line change 47
47
let ( :lru_cache ) { described_class . new ( 3 ) }
48
48
49
49
it 'stores a key-value pair' do
50
- expect { lru_cache . store ( :key , 'value' ) } . to
51
- change { lru_cache [ :key ] } . from ( nil ) . to ( 'value' )
50
+ expect { lru_cache . store ( :key , 'value' ) } . to change { lru_cache [ :key ] }
51
+ . from ( nil ) . to ( 'value' )
52
52
end
53
53
54
54
it 'overwrites existing values' do
55
55
lru_cache . store ( :key , 'old-value' )
56
56
57
- expect { lru_cache . store ( :key , 'new-value' ) } . to
58
- change { lru_cache [ :key ] } . from ( 'old-value' ) . to ( 'new-value' )
57
+ expect { lru_cache . store ( :key , 'new-value' ) } . to change { lru_cache [ :key ] }
58
+ . from ( 'old-value' ) . to ( 'new-value' )
59
59
end
60
60
61
61
context 'when maximum size is reached' do
Original file line number Diff line number Diff line change 19
19
example . run
20
20
ensure
21
21
Datadog . configuration . reset!
22
+ described_class . reset!
22
23
end
23
24
24
25
context 'when called for the first time' do
25
26
it 'returns a new sampler instance' do
26
- expect { described_class . thread_local } . to change { Thread . current . thread_variable_get ( :__sampler_key__ ) }
27
- . from ( nil ) . to ( be_a ( described_class ) )
27
+ # NOTE: Isolating the sampler in a separate thread to avoid flakiness
28
+ thread = Thread . new do
29
+ expect { described_class . thread_local } . to change { Thread . current . thread_variable_get ( :__sampler_key__ ) }
30
+ . from ( nil ) . to ( be_a ( described_class ) )
31
+ end
32
+
33
+ thread . join
28
34
end
29
35
end
30
36
You can’t perform that action at this time.
0 commit comments