yell 1.3.0 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +3 -1
  3. data/.travis.yml +1 -2
  4. data/Gemfile +5 -1
  5. data/README.md +67 -14
  6. data/examples/004.1-colorizing-the-log-output.rb +4 -4
  7. data/lib/yell.rb +19 -10
  8. data/lib/yell/adapters.rb +23 -26
  9. data/lib/yell/adapters/base.rb +8 -2
  10. data/lib/yell/adapters/datefile.rb +45 -42
  11. data/lib/yell/adapters/file.rb +10 -5
  12. data/lib/yell/adapters/io.rb +52 -48
  13. data/lib/yell/adapters/streams.rb +10 -2
  14. data/lib/yell/configuration.rb +1 -1
  15. data/lib/yell/event.rb +4 -4
  16. data/lib/yell/formatter.rb +11 -25
  17. data/lib/yell/helpers/adapters.rb +51 -0
  18. data/lib/yell/helpers/base.rb +19 -0
  19. data/lib/yell/helpers/formatter.rb +31 -0
  20. data/lib/yell/helpers/level.rb +36 -0
  21. data/lib/yell/helpers/silencer.rb +32 -0
  22. data/lib/yell/helpers/tracer.rb +48 -0
  23. data/lib/yell/level.rb +38 -47
  24. data/lib/yell/logger.rb +53 -73
  25. data/lib/yell/repository.rb +31 -29
  26. data/lib/yell/silencer.rb +69 -0
  27. data/lib/yell/version.rb +1 -1
  28. data/spec/spec_helper.rb +21 -9
  29. data/spec/yell/adapters/base_spec.rb +17 -34
  30. data/spec/yell/adapters/datefile_spec.rb +109 -66
  31. data/spec/yell/adapters/file_spec.rb +18 -18
  32. data/spec/yell/adapters/io_spec.rb +17 -13
  33. data/spec/yell/adapters/streams_spec.rb +7 -7
  34. data/spec/yell/adapters_spec.rb +18 -23
  35. data/spec/yell/configuration_spec.rb +7 -7
  36. data/spec/yell/event_spec.rb +25 -27
  37. data/spec/yell/formatter_spec.rb +89 -82
  38. data/spec/yell/level_spec.rb +119 -94
  39. data/spec/yell/loggable_spec.rb +6 -5
  40. data/spec/yell/logger_spec.rb +106 -66
  41. data/spec/yell/repository_spec.rb +23 -38
  42. data/spec/yell/silencer_spec.rb +49 -0
  43. data/spec/yell_spec.rb +24 -27
  44. metadata +16 -9
@@ -5,127 +5,139 @@ describe Yell::Level do
5
5
  context "default" do
6
6
  let(:level) { Yell::Level.new }
7
7
 
8
- it { level.at?(:debug).should be_true }
9
- it { level.at?(:info).should be_true }
10
- it { level.at?(:warn).should be_true }
11
- it { level.at?(:error).should be_true }
12
- it { level.at?(:fatal).should be_true }
8
+ it "should should return correctly" do
9
+ expect(level.at?(:debug)).to be_true
10
+ expect(level.at?(:info)).to be_true
11
+ expect(level.at?(:warn)).to be_true
12
+ expect(level.at?(:error)).to be_true
13
+ expect(level.at?(:fatal)).to be_true
14
+ end
13
15
  end
14
16
 
15
17
  context "given a Symbol" do
16
- let(:level) { Yell::Level.new(subject) }
18
+ let(:level) { Yell::Level.new(severity) }
17
19
 
18
- context :debug do
19
- subject { :debug }
20
+ context ":debug" do
21
+ let(:severity) { :debug }
20
22
 
21
- it { level.at?(:debug).should be_true }
22
- it { level.at?(:info).should be_true }
23
- it { level.at?(:warn).should be_true }
24
- it { level.at?(:error).should be_true }
25
- it { level.at?(:fatal).should be_true }
23
+ it "should should return correctly" do
24
+ expect(level.at?(:debug)).to be_true
25
+ expect(level.at?(:info)).to be_true
26
+ expect(level.at?(:warn)).to be_true
27
+ expect(level.at?(:error)).to be_true
28
+ expect(level.at?(:fatal)).to be_true
29
+ end
26
30
  end
27
31
 
28
- context :info do
29
- subject { :info }
32
+ context ":info" do
33
+ let(:severity) { :info }
30
34
 
31
- it { level.at?(:debug).should be_false }
32
- it { level.at?(:info).should be_true }
33
- it { level.at?(:warn).should be_true }
34
- it { level.at?(:error).should be_true }
35
- it { level.at?(:fatal).should be_true }
35
+ it "should should return correctly" do
36
+ expect(level.at?(:debug)).to be_false
37
+ expect(level.at?(:info)).to be_true
38
+ expect(level.at?(:warn)).to be_true
39
+ expect(level.at?(:error)).to be_true
40
+ expect(level.at?(:fatal)).to be_true
41
+ end
36
42
  end
37
43
 
38
- context :warn do
39
- subject { :warn }
44
+ context ":warn" do
45
+ let(:severity) { :warn }
40
46
 
41
- it { level.at?(:debug).should be_false }
42
- it { level.at?(:info).should be_false }
43
- it { level.at?(:warn).should be_true }
44
- it { level.at?(:error).should be_true }
45
- it { level.at?(:fatal).should be_true }
47
+ it "should should return correctly" do
48
+ expect(level.at?(:debug)).to be_false
49
+ expect(level.at?(:info)).to be_false
50
+ expect(level.at?(:warn)).to be_true
51
+ expect(level.at?(:error)).to be_true
52
+ expect(level.at?(:fatal)).to be_true
53
+ end
46
54
  end
47
55
 
48
- context :error do
49
- subject { :error }
56
+ context ":error" do
57
+ let(:severity) { :error }
50
58
 
51
- it { level.at?(:debug).should be_false }
52
- it { level.at?(:info).should be_false }
53
- it { level.at?(:warn).should be_false }
54
- it { level.at?(:error).should be_true }
55
- it { level.at?(:fatal).should be_true }
59
+ it "should should return correctly" do
60
+ expect(level.at?(:debug)).to be_false
61
+ expect(level.at?(:info)).to be_false
62
+ expect(level.at?(:warn)).to be_false
63
+ expect(level.at?(:error)).to be_true
64
+ expect(level.at?(:fatal)).to be_true
65
+ end
56
66
  end
57
67
 
58
- context :fatal do
59
- subject { :fatal }
68
+ context ":fatal" do
69
+ let(:severity) { :fatal }
60
70
 
61
- it { level.at?(:debug).should be_false }
62
- it { level.at?(:info).should be_false }
63
- it { level.at?(:warn).should be_false }
64
- it { level.at?(:error).should be_false }
65
- it { level.at?(:fatal).should be_true }
71
+ it "should should return correctly" do
72
+ expect(level.at?(:debug)).to be_false
73
+ expect(level.at?(:info)).to be_false
74
+ expect(level.at?(:warn)).to be_false
75
+ expect(level.at?(:error)).to be_false
76
+ expect(level.at?(:fatal)).to be_true
77
+ end
66
78
  end
67
79
  end
68
80
 
69
81
  context "given a String" do
70
- let(:level) { Yell::Level.new(subject) }
82
+ let(:level) { Yell::Level.new(severity) }
71
83
 
72
84
  context "basic string" do
73
- subject { 'error' }
74
-
75
- it "should be valid" do
76
- level.at?(:debug).should be_false
77
- level.at?(:info).should be_false
78
- level.at?(:warn).should be_false
79
- level.at?(:error).should be_true
80
- level.at?(:fatal).should be_true
85
+ let(:severity) { 'error' }
86
+
87
+ it "should should return correctly" do
88
+ expect(level.at?(:debug)).to be_false
89
+ expect(level.at?(:info)).to be_false
90
+ expect(level.at?(:warn)).to be_false
91
+ expect(level.at?(:error)).to be_true
92
+ expect(level.at?(:fatal)).to be_true
81
93
  end
82
94
  end
83
95
 
84
96
  context "complex string with outer boundaries" do
85
- subject { 'gte.info lte.error' }
86
-
87
- it "should be valid" do
88
- level.at?(:debug).should be_false
89
- level.at?(:info).should be_true
90
- level.at?(:warn).should be_true
91
- level.at?(:error).should be_true
92
- level.at?(:fatal).should be_false
97
+ let(:severity) { 'gte.info lte.error' }
98
+
99
+ it "should should return correctly" do
100
+ expect(level.at?(:debug)).to be_false
101
+ expect(level.at?(:info)).to be_true
102
+ expect(level.at?(:warn)).to be_true
103
+ expect(level.at?(:error)).to be_true
104
+ expect(level.at?(:fatal)).to be_false
93
105
  end
94
106
  end
95
107
 
96
108
  context "complex string with inner boundaries" do
97
- subject { 'gt.info lt.error' }
109
+ let(:severity) { 'gt.info lt.error' }
98
110
 
99
111
  it "should be valid" do
100
- level.at?(:debug).should be_false
101
- level.at?(:info).should be_false
102
- level.at?(:warn).should be_true
103
- level.at?(:error).should be_false
104
- level.at?(:fatal).should be_false
112
+ expect(level.at?(:debug)).to be_false
113
+ expect(level.at?(:info)).to be_false
114
+ expect(level.at?(:warn)).to be_true
115
+ expect(level.at?(:error)).to be_false
116
+ expect(level.at?(:fatal)).to be_false
105
117
  end
106
118
  end
107
119
 
108
120
  context "complex string with precise boundaries" do
109
- subject { 'at.info at.error' }
121
+ let(:severity) { 'at.info at.error' }
110
122
 
111
123
  it "should be valid" do
112
- level.at?(:debug).should be_false
113
- level.at?(:info).should be_true
114
- level.at?(:warn).should be_false
115
- level.at?(:error).should be_true
116
- level.at?(:fatal).should be_false
124
+ expect(level.at?(:debug)).to be_false
125
+ expect(level.at?(:info)).to be_true
126
+ expect(level.at?(:warn)).to be_false
127
+ expect(level.at?(:error)).to be_true
128
+ expect(level.at?(:fatal)).to be_false
117
129
  end
118
130
  end
119
131
 
120
132
  context "complex string with combined boundaries" do
121
- subject { 'gte.error at.debug' }
133
+ let(:severity) { 'gte.error at.debug' }
122
134
 
123
135
  it "should be valid" do
124
- level.at?(:debug).should be_true
125
- level.at?(:info).should be_false
126
- level.at?(:warn).should be_false
127
- level.at?(:error).should be_true
128
- level.at?(:fatal).should be_true
136
+ expect(level.at?(:debug)).to be_true
137
+ expect(level.at?(:info)).to be_false
138
+ expect(level.at?(:warn)).to be_false
139
+ expect(level.at?(:error)).to be_true
140
+ expect(level.at?(:fatal)).to be_true
129
141
  end
130
142
  end
131
143
  end
@@ -133,43 +145,56 @@ describe Yell::Level do
133
145
  context "given an Array" do
134
146
  let(:level) { Yell::Level.new( [:debug, :warn, :fatal] ) }
135
147
 
136
- it { level.at?(:debug).should be_true }
137
- it { level.at?(:info).should be_false }
138
- it { level.at?(:warn).should be_true }
139
- it { level.at?(:error).should be_false }
140
- it { level.at?(:fatal).should be_true }
148
+ it "should return correctly" do
149
+ expect(level.at?(:debug)).to be_true
150
+ expect(level.at?(:info)).to be_false
151
+ expect(level.at?(:warn)).to be_true
152
+ expect(level.at?(:error)).to be_false
153
+ expect(level.at?(:fatal)).to be_true
154
+ end
141
155
  end
142
156
 
143
157
  context "given a Range" do
144
158
  let(:level) { Yell::Level.new( (1..3) ) }
145
159
 
146
- it { level.at?(:debug).should be_false }
147
- it { level.at?(:info).should be_true }
148
- it { level.at?(:warn).should be_true }
149
- it { level.at?(:error).should be_true }
150
- it { level.at?(:fatal).should be_false }
160
+ it "should return correctly" do
161
+ expect(level.at?(:debug)).to be_false
162
+ expect(level.at?(:info)).to be_true
163
+ expect(level.at?(:warn)).to be_true
164
+ expect(level.at?(:error)).to be_true
165
+ expect(level.at?(:fatal)).to be_false
166
+ end
151
167
  end
152
168
 
153
169
  context "given a Yell::Level instance" do
154
170
  let(:level) { Yell::Level.new(:warn) }
155
171
 
156
- it { level.at?(:debug).should be_false }
157
- it { level.at?(:info).should be_false }
158
- it { level.at?(:warn).should be_true }
159
- it { level.at?(:error).should be_true }
160
- it { level.at?(:fatal).should be_true }
172
+ it "should return correctly" do
173
+ expect(level.at?(:debug)).to be_false
174
+ expect(level.at?(:info)).to be_false
175
+ expect(level.at?(:warn)).to be_true
176
+ expect(level.at?(:error)).to be_true
177
+ expect(level.at?(:fatal)).to be_true
178
+ end
161
179
  end
162
180
 
163
181
  context "backwards compatibility" do
164
182
  let(:level) { Yell::Level.new :warn }
165
183
 
166
- it { level.to_i.should == 2 }
167
- it { Integer(level).should == 2 }
184
+ it "should return correctly to :to_i" do
185
+ expect(level.to_i).to eq(2)
186
+ end
187
+
188
+ it "should typecast with Integer correctly" do
189
+ expect(Integer(level)).to eq(2)
190
+ end
168
191
 
169
192
  it "should be compatible when passing to array (https://github.com/rudionrails/yell/issues/1)" do
170
193
  severities = %w(FINE INFO WARNING SEVERE SEVERE INFO)
171
194
 
172
- severities[level].should == "WARNING"
195
+ expect(severities[level]).to eq("WARNING")
173
196
  end
174
197
  end
198
+
175
199
  end
200
+
@@ -5,14 +5,15 @@ class LoggableFactory
5
5
  end
6
6
 
7
7
  describe Yell::Loggable do
8
- subject { LoggableFactory.new }
8
+ let(:factory) { LoggableFactory.new }
9
+ subject { factory }
9
10
 
10
- it { should respond_to :logger }
11
+ it { should respond_to(:logger) }
11
12
 
12
- it ":logger should pass class name to the repository" do
13
- mock( Yell::Repository )[ LoggableFactory ]
13
+ it "should make a lookup in the Yell::Repository" do
14
+ mock(Yell::Repository)[LoggableFactory]
14
15
 
15
- subject.logger
16
+ factory.logger
16
17
  end
17
18
 
18
19
  end
@@ -15,112 +15,129 @@ end
15
15
  describe Yell::Logger do
16
16
  let(:filename) { fixture_path + '/logger.log' }
17
17
 
18
- context "a Logger instance" do
18
+ describe "a Logger instance" do
19
19
  let(:logger) { Yell::Logger.new }
20
+ subject { logger }
20
21
 
21
22
  its(:name) { should be_nil }
22
23
 
23
24
  context "log methods" do
24
- subject { logger }
25
+ it { should respond_to(:debug) }
26
+ it { should respond_to(:debug?) }
25
27
 
26
- it { should respond_to :debug }
27
- it { should respond_to :debug? }
28
+ it { should respond_to(:info) }
29
+ it { should respond_to(:info?) }
28
30
 
29
- it { should respond_to :info }
30
- it { should respond_to :info? }
31
+ it { should respond_to(:warn) }
32
+ it { should respond_to(:warn?) }
31
33
 
32
- it { should respond_to :warn }
33
- it { should respond_to :warn? }
34
+ it { should respond_to(:error) }
35
+ it { should respond_to(:error?) }
34
36
 
35
- it { should respond_to :error }
36
- it { should respond_to :error? }
37
+ it { should respond_to(:fatal) }
38
+ it { should respond_to(:fatal?) }
37
39
 
38
- it { should respond_to :fatal }
39
- it { should respond_to :fatal? }
40
-
41
- it { should respond_to :unknown }
42
- it { should respond_to :unknown? }
40
+ it { should respond_to(:unknown) }
41
+ it { should respond_to(:unknown?) }
43
42
  end
44
43
 
45
- context "default adapter" do
46
- let(:adapters) { logger.instance_variable_get(:@adapters) }
44
+ context "default #adapters" do
45
+ subject { logger.adapters }
47
46
 
48
- it { adapters.size.should == 1 }
49
- it { adapters.first.should be_kind_of(Yell::Adapters::File) }
47
+ its(:size) { should eq(1) }
48
+ its(:first) { should be_kind_of(Yell::Adapters::File) }
50
49
  end
51
50
 
52
- context "default :level" do
51
+ context "default #level" do
53
52
  subject { logger.level }
54
53
 
55
54
  it { should be_instance_of(Yell::Level) }
56
- its(:severities) { should == [true, true, true, true, true, true] }
55
+ its(:severities) { should eq([true, true, true, true, true, true]) }
57
56
  end
58
57
 
59
- context "default :trace" do
58
+ context "default #trace" do
60
59
  subject { logger.trace }
61
60
 
62
61
  it { should be_instance_of(Yell::Level) }
63
- its(:severities) { should == [false, false, false, true, true, true] } # from error onwards
62
+ its(:severities) { should eq([false, false, false, true, true, true]) } # from error onwards
64
63
  end
65
64
  end
66
65
 
67
- context "initialize with a :name" do
66
+ describe "initialize with #name" do
68
67
  let(:name) { 'test' }
69
68
  let!(:logger) { Yell.new(:name => name) }
70
69
 
71
- it "should set the logger's name" do
72
- logger.name.should == name
73
- end
74
-
75
70
  it "should be added to the repository" do
76
- Yell::Repository[name].should == logger
71
+ expect(Yell::Repository[name]).to eq(logger)
77
72
  end
78
73
  end
79
74
 
80
- context "initialize with :trace" do
75
+ context "initialize with #level" do
76
+ let(:level) { :error }
77
+ let(:logger) { Yell.new(:level => level) }
78
+ subject { logger.level }
79
+
80
+ it { should be_instance_of(Yell::Level) }
81
+ its(:severities) { should eq([false, false, false, true, true, true]) }
82
+ end
83
+
84
+ context "initialize with #trace" do
85
+ let(:trace) { :info }
86
+ let(:logger) { Yell.new(:trace => trace) }
87
+ subject { logger.trace }
88
+
89
+ it { should be_instance_of(Yell::Level) }
90
+ its(:severities) { should eq([false, true, true, true, true, true]) }
91
+ end
92
+
93
+ context "initialize with #silence" do
94
+ let(:silence) { "test" }
95
+ let(:logger) { Yell.new(:silence => silence) }
96
+ subject { logger.silencer }
97
+
98
+ it { should be_instance_of(Yell::Silencer) }
99
+ its(:patterns) { should eq([silence]) }
81
100
  end
82
101
 
83
- context "initialize with a :filename" do
102
+ context "initialize with a #filename" do
84
103
  it "should call adapter with :file" do
85
- mock.proxy( Yell::Adapters::File ).new( :filename => 'test.log' )
104
+ mock.proxy(Yell::Adapters::File).new(:filename => filename)
86
105
 
87
- Yell::Logger.new 'test.log'
106
+ Yell::Logger.new(filename)
88
107
  end
89
108
  end
90
109
 
91
- context "initialize with a :filename of Pathname type" do
110
+ context "initialize with a #filename of Pathname type" do
111
+ let(:pathname) { Pathname.new(filename) }
112
+
92
113
  it "should call adapter with :file" do
93
- mock.proxy( Yell::Adapters::File ).new( :filename => Pathname.new('test.log') )
114
+ mock.proxy(Yell::Adapters::File).new(:filename => pathname)
94
115
 
95
- Yell::Logger.new Pathname.new('test.log')
116
+ Yell::Logger.new(pathname)
96
117
  end
97
118
  end
98
119
 
99
120
  context "initialize with a :stdout adapter" do
100
- before do
101
- mock.proxy( Yell::Adapters::Stdout ).new( anything )
102
- end
121
+ before { mock.proxy(Yell::Adapters::Stdout).new(anything) }
103
122
 
104
123
  it "should call adapter with STDOUT" do
105
- Yell::Logger.new STDOUT
124
+ Yell::Logger.new(STDOUT)
106
125
  end
107
126
 
108
127
  it "should call adapter with :stdout" do
109
- Yell::Logger.new :stdout
128
+ Yell::Logger.new(:stdout)
110
129
  end
111
130
  end
112
131
 
113
132
  context "initialize with a :stderr adapter" do
114
- before do
115
- mock.proxy( Yell::Adapters::Stderr ).new( anything )
116
- end
133
+ before { mock.proxy(Yell::Adapters::Stderr).new(anything) }
117
134
 
118
135
  it "should call adapter with STDERR" do
119
- Yell::Logger.new STDERR
136
+ Yell::Logger.new(STDERR)
120
137
  end
121
138
 
122
139
  it "should call adapter with :stderr" do
123
- Yell::Logger.new :stderr
140
+ Yell::Logger.new(:stderr)
124
141
  end
125
142
  end
126
143
 
@@ -134,8 +151,8 @@ describe Yell::Logger do
134
151
  Yell::Logger.new(:level => level) { |l| l.adapter(:stdout) }
135
152
  end
136
153
 
137
- its(:level) { should == level }
138
- its('adapters.size') { should == 1 }
154
+ its(:level) { should eq(level) }
155
+ its('adapters.size') { should eq(1) }
139
156
  its('adapters.first') { should be_instance_of(Yell::Adapters::Stdout) }
140
157
  end
141
158
 
@@ -144,32 +161,32 @@ describe Yell::Logger do
144
161
  Yell::Logger.new(:level => level) { adapter(:stdout) }
145
162
  end
146
163
 
147
- its(:level) { should == level }
148
- its('adapters.size') { should == 1 }
164
+ its(:level) { should eq(level) }
165
+ its('adapters.size') { should eq(1) }
149
166
  its('adapters.first') { should be_instance_of(Yell::Adapters::Stdout) }
150
167
  end
151
168
  end
152
169
 
153
- context "initialize with :adapters option" do
170
+ context "initialize with #adapters option" do
154
171
  let(:logger) do
155
- Yell::Logger.new :adapters => [ :stdout, { :stderr => {:level => :error} } ]
172
+ Yell::Logger.new(:adapters => [:stdout, {:stderr => {:level => :error}}])
156
173
  end
157
174
 
158
- let(:adapters) { logger.instance_variable_get :@adapters }
175
+ let(:adapters) { logger.instance_variable_get(:@adapters) }
159
176
  let(:stdout) { adapters.first }
160
177
  let(:stderr) { adapters.last }
161
178
 
162
179
  it "should define those adapters" do
163
- adapters.size.should == 2
180
+ expect(adapters.size).to eq(2)
164
181
 
165
- stdout.should be_kind_of Yell::Adapters::Stdout
166
- stderr.should be_kind_of Yell::Adapters::Stderr
182
+ expect(stdout).to be_kind_of(Yell::Adapters::Stdout)
183
+ expect(stderr).to be_kind_of(Yell::Adapters::Stderr)
167
184
  end
168
185
 
169
186
  it "should pass :level to :stderr adapter" do
170
- stderr.level.at?(:warn).should be_false
171
- stderr.level.at?(:error).should be_true
172
- stderr.level.at?(:fatal).should be_true
187
+ expect(stderr.level.at?(:warn)).to be_false
188
+ expect(stderr.level.at?(:error)).to be_true
189
+ expect(stderr.level.at?(:fatal)).to be_true
173
190
  end
174
191
  end
175
192
 
@@ -181,8 +198,8 @@ describe Yell::Logger do
181
198
  factory = LoggerFactory.new
182
199
  factory.logger = logger
183
200
 
184
- mock( stdout.send(:stream) ).syswrite( "#{__FILE__}, 7: foo\n" )
185
- mock( stdout.send(:stream) ).syswrite( "#{__FILE__}, 11: bar\n" )
201
+ mock(stdout.send(:stream)).syswrite("#{__FILE__}, 7: foo\n")
202
+ mock(stdout.send(:stream)).syswrite("#{__FILE__}, 11: bar\n")
186
203
 
187
204
  factory.foo
188
205
  factory.bar
@@ -195,27 +212,50 @@ describe Yell::Logger do
195
212
 
196
213
  it "should output a single message" do
197
214
  logger.info "Hello World"
198
- line.should == "Hello World\n"
215
+
216
+ expect(line).to eq("Hello World\n")
199
217
  end
200
218
 
201
219
  it "should output multiple messages" do
202
220
  logger.info "Hello", "W", "o", "r", "l", "d"
203
- line.should == "Hello W o r l d\n"
221
+
222
+ expect(line).to eq("Hello W o r l d\n")
204
223
  end
205
224
 
206
225
  it "should output a hash and message" do
207
226
  logger.info "Hello World", :test => :message
208
- line.should == "Hello World test: message\n"
227
+
228
+ expect(line).to eq("Hello World test: message\n")
209
229
  end
210
230
 
211
231
  it "should output a hash and message" do
212
232
  logger.info( {:test => :message}, "Hello World" )
213
- line.should == "test: message Hello World\n"
233
+
234
+ expect(line).to eq("test: message Hello World\n")
214
235
  end
215
236
 
216
237
  it "should output a hash and block" do
217
238
  logger.info(:test => :message) { "Hello World" }
218
- line.should == "test: message Hello World\n"
239
+
240
+ expect(line).to eq("test: message Hello World\n")
241
+ end
242
+ end
243
+
244
+ context "logging with a silencer" do
245
+ let(:silence) { "this" }
246
+ let(:stdout) { Yell::Adapters::Stdout.new }
247
+ let(:logger) { Yell::Logger.new(stdout, :silence => silence) }
248
+
249
+ it "should not pass a matching message to any adapter" do
250
+ dont_allow(stdout).write
251
+
252
+ logger.info "this should not be logged"
253
+ end
254
+
255
+ it "should pass a non-matching message to any adapter" do
256
+ mock(stdout).write(is_a(Yell::Event))
257
+
258
+ logger.info "that should be logged"
219
259
  end
220
260
  end
221
261