-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathdata_redacter_spec.rb
61 lines (52 loc) · 1.61 KB
/
data_redacter_spec.rb
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
module ExceptionHunter
describe DataRedacter do
describe '.redact' do
subject { described_class.new(attributes, attributes_to_filter).redact }
let(:attributes_to_filter) { %i[class_name hide hide_this_too hide_this_hash] }
context 'when params with content' do
let(:attributes) do
{
class_name: 'SomeError',
message: 'Something went very wrong 123',
environment_data: {
hide: { value_to_hide: 'hide this value' },
"hide_this_too": { "hide_this": 'hide this' },
hide_this_hash: { "hide_this_hash": 'hide this' }
}
}
end
it 'hides the values' do
expect(subject).to eq(
class_name: '[FILTERED]',
message: 'Something went very wrong 123',
environment_data: {
hide: '[FILTERED]',
"hide_this_too": '[FILTERED]',
hide_this_hash: '[FILTERED]'
}
)
end
end
context 'when empty params' do
context 'when params is an empty hash' do
let(:attributes) { {} }
it 'returns empty hash' do
expect(subject).to eq({})
end
end
context 'when params is an empty string' do
let(:attributes) { '' }
it 'returns empty string' do
expect(subject).to eq('')
end
end
context 'when params is null' do
let(:attributes) { nil }
it 'returns nil' do
expect(subject).to eq(nil)
end
end
end
end
end
end