File tree 2 files changed +13
-12
lines changed
spec/integration/fluent_logger_rails
2 files changed +13
-12
lines changed Original file line number Diff line number Diff line change @@ -45,11 +45,10 @@ def format_severity(severity)
45
45
def tagged ( *tags )
46
46
tags = tags . flatten . compact if tags . is_a? ( Array )
47
47
48
- add_tags ( *tags ) if tags
49
-
48
+ add_tags ( *tags ) if tags . present?
50
49
yield ( self )
51
50
ensure
52
- remove_tags ( *tags ) if tags
51
+ remove_tags ( *tags ) if tags . present?
53
52
end
54
53
55
54
def add_tags ( *tags )
Original file line number Diff line number Diff line change 38
38
39
39
context 'nil tag' do
40
40
it 'does not attempt to process the tags' do
41
- expect ( formatter ) . not_to ( receive ( :remove_tags ) . with ( anything ) )
41
+ expect_any_instance_of ( described_class ) . not_to receive ( :remove_tags )
42
42
43
- formatter . tagged ( tags ) { expect ( formatter . current_tags ) . to ( eq ( { tags : [ ] } ) ) }
43
+ formatter . tagged ( tags ) { expect ( formatter . current_tags ) . to eq ( { } ) }
44
44
end
45
45
end
46
46
47
47
context 'with a nested array of nil tags' do
48
48
let ( :tags ) { [ nil ] }
49
49
50
50
it 'does not attempt to process the tags' do
51
- expect ( formatter ) . not_to ( receive ( :remove_tags ) . with ( anything ) )
51
+ expect_any_instance_of ( described_class ) . not_to receive ( :remove_tags )
52
52
53
- formatter . tagged ( [ tags ] ) { expect ( formatter . current_tags ) . to ( eq ( { tags : [ ] } ) ) }
53
+ formatter . tagged ( [ tags ] ) { expect ( formatter . current_tags ) . to eq ( { } ) }
54
54
end
55
55
end
56
56
57
57
context 'with a string tag' do
58
58
let ( :tags ) { 'tag' }
59
59
60
- it 'adds the tag' do
61
- formatter . tagged ( tags ) { expect ( formatter . current_tags ) . to ( eq ( { tags : [ tags ] } ) ) }
60
+ it 'adds and removes the tag' do
61
+ expect_any_instance_of ( described_class ) . to receive ( :remove_tags ) . with ( tags )
62
+
63
+ formatter . tagged ( tags ) { expect ( formatter . current_tags ) . to eq ( { tags : [ tags ] } ) }
62
64
end
63
65
end
64
66
65
67
context 'with a hash' do
66
68
let ( :tags ) { { port : 80 , host : '127.0.0.1' } }
67
69
68
70
it 'adds the tags' do
69
- formatter . tagged ( ** tags ) do
70
- expect ( formatter . current_tags ) . to ( eq ( tags ) )
71
- end
71
+ expect_any_instance_of ( described_class ) . to receive ( :remove_tags ) . with ( tags )
72
+
73
+ formatter . tagged ( ** tags ) { expect ( formatter . current_tags ) . to eq ( tags ) }
72
74
end
73
75
end
74
76
end
You can’t perform that action at this time.
0 commit comments