yell 2.0.6 → 2.0.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3e19cff458ef6d40231f8f0e2096bb279649618d
4
- data.tar.gz: d78ed9263a83bc5e9b2b23aa58f351b8ded2b416
3
+ metadata.gz: c64ac6a01262ce703c70c306d55f565592b6b6e3
4
+ data.tar.gz: 0110f23e03b39c39d13cbf196738d00bf2ac09ad
5
5
  SHA512:
6
- metadata.gz: b80248ab8e02027cf36edc8ab49bdb3195c4af5abf60c0bcfac16da4810b753fb6c749004c00221c5bfbfe85ef553e93a822b53e907ba1bd5aeb629ff931f549
7
- data.tar.gz: 52967711166a7aa4e0c9a5df4dc99e01f75708b38c6847393dcf30036af9e55b409f74f3e043d78f2dd4d6316a860d78c75cdbf95616044d0e548b6e63d00114
6
+ metadata.gz: 21d0534e86efc9c1b136f8745edffa76b5b89e9883c13405075692bd982b7c5119ad4fa39fd7f46fff462d0ca6e7204a49a562e8ffd6d5f54d1af661f4d7d887
7
+ data.tar.gz: b1b3927d90714d0b5e91fe7cbbbd71aff6e4c6d45478674f9f0175ceb28ce5c3ef832c27da80c84edb9c191343e080644572c2650974f2c1971eff9d49ced466
@@ -1,18 +1,13 @@
1
+ sudo: false
1
2
  language: ruby
2
3
 
3
4
  script: "rspec"
4
5
 
5
6
  rvm:
6
- - 1.8.7
7
- - 1.9.3
8
- - 2.0.0
9
- - 2.1.1
10
- - jruby-18mode
11
- - jruby-19mode
12
- - rbx-2
13
- - ree
7
+ - ruby-head
8
+ - 2.3.1
9
+ - 2.2.5
14
10
 
15
11
  notifications:
16
- email:
17
- - me@rudionrails.com
18
-
12
+ on_success: change
13
+ on_failure: change
data/Gemfile CHANGED
@@ -7,9 +7,9 @@ group :development, :test do
7
7
  gem "rake"
8
8
 
9
9
  gem 'rspec-core', '~> 3'
10
- gem 'rspec-expectations', '~> 3'
10
+ gem 'rspec-expectations'
11
+ gem 'rspec-mocks'
11
12
  gem 'rspec-its'
12
- gem "rr"
13
13
 
14
14
  if RUBY_VERSION < "1.9"
15
15
  gem 'timecop', '0.6.0'
@@ -18,7 +18,7 @@ group :development, :test do
18
18
  gem 'timecop'
19
19
  gem 'activesupport'
20
20
 
21
- gem 'pry'
21
+ gem 'byebug'
22
22
  end
23
23
 
24
24
  gem 'simplecov', :require => false, :platform => :ruby_20
@@ -22,7 +22,6 @@
22
22
  # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
23
 
24
24
  module Yell #:nodoc:
25
-
26
25
  # Holds all Yell severities
27
26
  Severities = ['DEBUG', 'INFO', 'WARN', 'ERROR', 'FATAL', 'UNKNOWN'].freeze
28
27
 
@@ -112,9 +111,7 @@ module Yell #:nodoc:
112
111
 
113
112
  value.nil? ? options[:default] : value
114
113
  end
115
-
116
114
  end
117
-
118
115
  end
119
116
 
120
117
  # helpers
@@ -147,5 +144,3 @@ Yell.register :file, Yell::Adapters::File
147
144
  Yell.register :datefile, Yell::Adapters::Datefile
148
145
  Yell.register :stdout, Yell::Adapters::Stdout
149
146
  Yell.register :stderr, Yell::Adapters::Stderr
150
-
151
-
@@ -1,6 +1,5 @@
1
1
  # encoding: utf-8
2
2
  module Yell #:nodoc:
3
-
4
3
  # AdapterNotFound is raised whenever you want to instantiate an
5
4
  # adapter that does not exist.
6
5
  class AdapterNotFound < StandardError; end
@@ -9,7 +8,6 @@ module Yell #:nodoc:
9
8
  # the logger. You should not have to call the corresponding classes
10
9
  # directly.
11
10
  module Adapters
12
-
13
11
  class Collection
14
12
  def initialize( options = {} )
15
13
  @options = options
@@ -61,19 +59,18 @@ module Yell #:nodoc:
61
59
  #
62
60
  # @example A simple file adapter
63
61
  # Yell::Adapters.new( :file )
64
- def self.new( name, options = {}, &block )
65
- return name if name.is_a?(Yell::Adapters::Base)
62
+ def self.new( type, options = {}, &block )
63
+ return type if type.is_a?(Yell::Adapters::Base)
66
64
 
67
- adapter = case name
65
+ adapter = case type
68
66
  when STDOUT then @adapters[:stdout]
69
67
  when STDERR then @adapters[:stderr]
70
- else @adapters[name.to_sym]
68
+ else @adapters[type.to_sym]
71
69
  end
72
70
 
73
- raise AdapterNotFound.new(name) if adapter.nil?
71
+ raise AdapterNotFound.new(type) if adapter.nil?
74
72
  adapter.new(options, &block)
75
73
  end
76
-
77
74
  end
78
75
  end
79
76
 
@@ -2,7 +2,6 @@
2
2
 
3
3
  module Yell #:nodoc:
4
4
  module Adapters #:nodoc:
5
-
6
5
  class Io < Yell::Adapters::Base
7
6
  include Yell::Helpers::Formatter
8
7
 
@@ -94,9 +93,7 @@ module Yell #:nodoc:
94
93
  def inspectables
95
94
  super.concat [:formatter, :colors, :sync]
96
95
  end
97
-
98
96
  end
99
-
100
97
  end
101
98
  end
102
99
 
@@ -2,7 +2,6 @@
2
2
  module Yell #:nodoc:
3
3
  module Helpers #:nodoc:
4
4
  module Adapter #:nodoc:
5
-
6
5
  # Define an adapter to be used for logging.
7
6
  #
8
7
  # @example Standard adapter
@@ -31,7 +30,6 @@ module Yell #:nodoc:
31
30
  @__adapters__
32
31
  end
33
32
 
34
-
35
33
  private
36
34
 
37
35
  def reset!
@@ -39,8 +37,6 @@ module Yell #:nodoc:
39
37
 
40
38
  super
41
39
  end
42
-
43
40
  end
44
41
  end
45
42
  end
46
-
@@ -1,7 +1,6 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  module Yell #:nodoc:
4
-
5
4
  # Include this module to add a logger to any class.
6
5
  #
7
6
  # When including this module, your class will have a :logger instance method
@@ -17,7 +16,6 @@ module Yell #:nodoc:
17
16
  #
18
17
  # Foo.new.logger.info "Hello World"
19
18
  module Loggable
20
-
21
19
  def self.included(base)
22
20
  base.extend(ClassMethods)
23
21
  end
@@ -31,7 +29,5 @@ module Yell #:nodoc:
31
29
  def logger
32
30
  self.class.logger
33
31
  end
34
-
35
32
  end
36
33
  end
37
-
@@ -1,9 +1,7 @@
1
1
  # encoding: utf-8
2
-
3
2
  require 'pathname'
4
3
 
5
4
  module Yell #:nodoc:
6
-
7
5
  # The +Yell::Logger+ is your entrypoint. Anything onwards is derived from here.
8
6
  #
9
7
  # A +Yell::Logger+ instance holds all your adapters and sends the log events
@@ -144,11 +142,12 @@ module Yell #:nodoc:
144
142
  #
145
143
  # @example
146
144
  # extract!(:stdout => {:level => :info}, :stderr => {:level => :error})
147
- def extract!( *adapters )
148
- adapters.each do |a|
149
- case a
150
- when Hash then a.each { |t, o| adapter(t, o) }
151
- else adapter(a)
145
+ def extract!( *list )
146
+ list.each do |a|
147
+ if a.is_a?(Hash)
148
+ a.each { |t, o| adapter(t, o) }
149
+ else
150
+ adapter(a)
152
151
  end
153
152
  end
154
153
  end
@@ -157,7 +156,6 @@ module Yell #:nodoc:
157
156
  def inspectables
158
157
  [:name] | super
159
158
  end
160
-
161
159
  end
162
160
  end
163
161
 
@@ -1,7 +1,6 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  module Yell #:nodoc:
4
- VERSION = "2.0.6"
5
-
4
+ VERSION = "2.0.7"
6
5
  end
7
6
 
@@ -10,7 +10,8 @@ end
10
10
  #
11
11
  # We simulate the case when Rails 4 starts up its server
12
12
  # and wants to append the log output.
13
- describe "Compatibility to ActiveSupport::Logger", :pending => (!defined?(ActiveSupport) || ActiveSupport::VERSION::MAJOR < 4) do
13
+ describe "Compatibility to ActiveSupport::Logger",
14
+ :pending => (!defined?(ActiveSupport) || ActiveSupport::VERSION::MAJOR < 4) do
14
15
 
15
16
  let!(:yell) { Yell.new($stdout, :format => "%m") }
16
17
 
@@ -25,8 +26,8 @@ describe "Compatibility to ActiveSupport::Logger", :pending => (!defined?(Active
25
26
  end
26
27
 
27
28
  it "should behave correctly" do
28
- mock($stdout).syswrite("Hello World\n") # yell
29
- mock($stdout).write("Hello World\n") # logger
29
+ expect($stdout).to receive(:syswrite).with("Hello World\n") # yell
30
+ expect($stdout).to receive(:write).with("Hello World\n") # logger
30
31
 
31
32
  yell.info "Hello World"
32
33
  end
@@ -2,22 +2,20 @@ require 'spec_helper'
2
2
  require 'logger'
3
3
 
4
4
  describe "backwards compatible formatter" do
5
-
6
5
  let(:time) { Time.now }
7
6
  let(:formatter) { Yell::Formatter.new(Yell::DefaultFormat) }
8
7
  let(:logger) { Logger.new($stdout) }
9
8
 
10
9
  before do
11
10
  Timecop.freeze(time)
12
-
13
11
  logger.formatter = formatter
14
12
  end
15
13
 
16
14
  it "should format out the message correctly" do
17
- mock($stdout).write("#{time.iso8601} [ INFO] #{$$} : Hello World!\n")
15
+ expect($stdout).to(
16
+ receive(:write).with("#{time.iso8601} [ INFO] #{$$} : Hello World!\n")
17
+ )
18
18
 
19
19
  logger.info "Hello World!"
20
20
  end
21
-
22
21
  end
23
-
@@ -5,14 +5,10 @@ ENV['YELL_ENV'] = 'test'
5
5
 
6
6
  require 'rspec/core'
7
7
  require 'rspec/expectations'
8
+ require 'rspec/mocks'
8
9
  require 'rspec/its'
9
- require 'rr'
10
10
  require 'timecop'
11
-
12
- begin
13
- require 'pry'
14
- rescue LoadError
15
- end
11
+ require 'byebug'
16
12
 
17
13
  begin
18
14
  require 'coveralls'
@@ -34,8 +30,6 @@ end
34
30
  require 'yell'
35
31
 
36
32
  RSpec.configure do |config|
37
- config.mock_framework = :rr
38
-
39
33
  config.before :each do
40
34
  Yell::Repository.loggers.clear
41
35
 
@@ -22,20 +22,20 @@ describe Yell::Adapters::Base do
22
22
 
23
23
  context "#write" do
24
24
  let(:logger) { Yell::Logger.new }
25
- subject { Yell::Adapters::Base.new(:level => 1) }
25
+ let(:adapter) { Yell::Adapters::Base.new(:level => 1) }
26
26
 
27
27
  it "should delegate :event to :write!" do
28
28
  event = Yell::Event.new(logger, 1, "Hello World!")
29
- mock(subject).write!(event)
29
+ expect(adapter).to receive(:write!).with(event)
30
30
 
31
- subject.write(event)
31
+ adapter.write(event)
32
32
  end
33
33
 
34
34
  it "should not write when event does not have the right level" do
35
35
  event = Yell::Event.new(logger, 0, "Hello World!")
36
- dont_allow(subject).write!(event)
36
+ expect(adapter).to_not receive(:write!)
37
37
 
38
- subject.write(event)
38
+ adapter.write(event)
39
39
  end
40
40
  end
41
41
 
@@ -42,7 +42,7 @@ describe Yell::Adapters::Datefile do
42
42
  end
43
43
 
44
44
  it "should not open file handle again" do
45
- dont_allow(File).open(anything, anything)
45
+ expect(File).to_not receive(:open)
46
46
 
47
47
  adapter.write(event)
48
48
  end
@@ -4,7 +4,7 @@ describe Yell::Adapters::File do
4
4
  let(:devnull) { File.new('/dev/null', 'w') }
5
5
 
6
6
  before do
7
- stub(File).open(anything, anything) { devnull }
7
+ allow(File).to receive(:open) { devnull }
8
8
  end
9
9
 
10
10
  it { should be_kind_of(Yell::Adapters::Io) }
@@ -24,7 +24,10 @@ describe Yell::Adapters::File do
24
24
  let(:adapter) { Yell::Adapters::File.new }
25
25
 
26
26
  it "should print to file" do
27
- mock(File).open(filename, File::WRONLY|File::APPEND|File::CREAT) { devnull }
27
+ expect(File).to(
28
+ receive(:open).
29
+ with(filename, File::WRONLY|File::APPEND|File::CREAT) { devnull }
30
+ )
28
31
 
29
32
  adapter.write(event)
30
33
  end
@@ -35,7 +38,10 @@ describe Yell::Adapters::File do
35
38
  let(:adapter) { Yell::Adapters::File.new(:filename => filename) }
36
39
 
37
40
  it "should print to file" do
38
- mock(File).open(filename, File::WRONLY|File::APPEND|File::CREAT) { devnull }
41
+ expect(File).to(
42
+ receive(:open).
43
+ with(filename, File::WRONLY|File::APPEND|File::CREAT) { devnull }
44
+ )
39
45
 
40
46
  adapter.write(event)
41
47
  end
@@ -46,7 +52,10 @@ describe Yell::Adapters::File do
46
52
  let(:adapter) { Yell::Adapters::File.new( :filename => pathname ) }
47
53
 
48
54
  it "should accept pathanme as filename" do
49
- mock(File).open(pathname.to_s, File::WRONLY|File::APPEND|File::CREAT) { devnull }
55
+ expect(File).to(
56
+ receive(:open).
57
+ with(pathname.to_s, File::WRONLY|File::APPEND|File::CREAT) { devnull }
58
+ )
50
59
 
51
60
  adapter.write(event)
52
61
  end
@@ -56,7 +65,7 @@ describe Yell::Adapters::File do
56
65
  let(:adapter) { Yell::Adapters::File.new }
57
66
 
58
67
  it "should sync by default" do
59
- mock(devnull).sync=(true)
68
+ expect(devnull).to receive(:sync=).with(true)
60
69
 
61
70
  adapter.write(event)
62
71
  end
@@ -64,7 +73,7 @@ describe Yell::Adapters::File do
64
73
  it "pass the option to File" do
65
74
  adapter.sync = false
66
75
 
67
- mock(devnull).sync=(false)
76
+ expect(devnull).to receive(:sync=).with(false)
68
77
 
69
78
  adapter.write(event)
70
79
  end
@@ -1,7 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Yell::Adapters::Io do
4
-
5
4
  it { should be_kind_of Yell::Adapters::Base }
6
5
 
7
6
  context "initialize" do
@@ -51,22 +50,22 @@ describe Yell::Adapters::Io do
51
50
  let(:stream) { File.new('/dev/null', 'w') }
52
51
 
53
52
  before do
54
- stub(adapter).stream { stream }
53
+ allow(adapter).to receive(:stream) { stream }
55
54
  end
56
55
 
57
56
  it "should format the message" do
58
- mock.proxy(adapter.format).call( event )
57
+ expect(adapter.format).to(
58
+ receive(:call).with(event).and_call_original
59
+ )
59
60
 
60
61
  adapter.write(event)
61
62
  end
62
63
 
63
64
  it "should print formatted message to stream" do
64
65
  formatted = Yell::Formatter.new.call(event)
65
- mock(stream).syswrite(formatted)
66
+ expect(stream).to receive(:syswrite).with(formatted)
66
67
 
67
68
  adapter.write(event)
68
69
  end
69
70
  end
70
-
71
71
  end
72
-
@@ -11,35 +11,33 @@ describe Yell::Adapters do
11
11
  end
12
12
 
13
13
  it "should accept STDOUT" do
14
- mock.proxy(Yell::Adapters::Stdout).new(anything)
14
+ expect(Yell::Adapters::Stdout).to receive(:new).with(anything)
15
15
 
16
16
  Yell::Adapters.new(STDOUT)
17
17
  end
18
18
 
19
19
  it "should accept STDERR" do
20
- mock.proxy(Yell::Adapters::Stderr).new(anything)
20
+ expect(Yell::Adapters::Stderr).to receive(:new).with(anything)
21
21
 
22
22
  Yell::Adapters.new(STDERR)
23
23
  end
24
24
 
25
25
  it "should raise an unregistered adapter" do
26
26
  expect {
27
- Yell::Adapters.new :unknown
27
+ Yell::Adapters.new(:unknown)
28
28
  }.to raise_error(Yell::AdapterNotFound)
29
29
  end
30
30
  end
31
31
 
32
32
  context ".register" do
33
- let(:name) { :test }
34
- let(:klass) { mock }
35
-
36
- before { Yell::Adapters.register(name, klass) }
33
+ let(:type) { :test }
34
+ let(:klass) { double }
37
35
 
38
36
  it "should allow to being called from :new" do
39
- mock(klass).new(anything)
37
+ Yell::Adapters.register(type, klass)
38
+ expect(klass).to receive(:new).with(anything)
40
39
 
41
- Yell::Adapters.new(name)
40
+ Yell::Adapters.new(type)
42
41
  end
43
42
  end
44
-
45
43
  end
@@ -28,7 +28,7 @@ describe "Yell Adapter DSL spec" do
28
28
 
29
29
  it "should perform #write" do
30
30
  event = 'event'
31
- stub(event).level { 0 }
31
+ allow(event).to receive(:level) { 0 }
32
32
 
33
33
  adapter = DSLAdapter.new
34
34
  expect(adapter.test_write?).to be_falsey
@@ -1,17 +1,15 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Yell::Formatter do
4
-
5
4
  let(:logger) { Yell::Logger.new(:stdout, :name => 'Yell') }
6
5
  let(:message) { "Hello World!" }
7
6
  let(:event) { Yell::Event.new(logger, 1, message) }
7
+ let(:time) { Time.now }
8
8
 
9
9
  let(:pattern) { "%m" }
10
10
  let(:formatter) { Yell::Formatter.new(pattern) }
11
11
 
12
- let(:time) { Time.now }
13
-
14
- subject { formatter.call(event) }
12
+ let(:output) { formatter.call(event) }
15
13
 
16
14
  before do
17
15
  Timecop.freeze(time)
@@ -20,101 +18,150 @@ describe Yell::Formatter do
20
18
  describe "patterns" do
21
19
  context "%m" do
22
20
  let(:pattern) { "%m" }
23
- it { should eq("#{event.messages.join(' ')}\n") }
21
+
22
+ it "returns correctly" do
23
+ expect(output).to eq("#{event.messages.join(' ')}\n")
24
+ end
24
25
  end
25
26
 
26
27
  context "%l" do
27
28
  let(:pattern) { "%l" }
28
- it { should eq("#{Yell::Severities[event.level][0,1]}\n") }
29
+
30
+ it "returns correctly" do
31
+ expect(output).to eq("#{Yell::Severities[event.level][0,1]}\n")
32
+ end
29
33
  end
30
34
 
31
35
  context "%L" do
32
36
  let(:pattern) { "%L" }
33
- it { should eq("#{Yell::Severities[event.level]}\n") }
37
+
38
+ it "returns correctly" do
39
+ expect(output).to eq("#{Yell::Severities[event.level]}\n")
40
+ end
34
41
  end
35
42
 
36
43
  context "%d" do
37
44
  let(:pattern) { "%d" }
38
- it { should eq("#{event.time.iso8601}\n") }
45
+
46
+ it "returns correctly" do
47
+ expect(output).to eq("#{event.time.iso8601}\n")
48
+ end
39
49
  end
40
50
 
41
51
  context "%p" do
42
52
  let(:pattern) { "%p" }
43
- it { should eq("#{event.pid}\n") }
53
+
54
+ it "returns correctly" do
55
+ expect(output).to eq("#{event.pid}\n")
56
+ end
44
57
  end
45
58
 
46
59
  context "%P" do
47
60
  let(:pattern) { "%P" }
48
- it { should eq("#{event.progname}\n") }
61
+
62
+ it "returns correctly" do
63
+ expect(output).to eq("#{event.progname}\n")
64
+ end
49
65
  end
50
66
 
51
67
  context "%t" do
52
68
  let(:pattern) { "%t" }
53
- it { should eq("#{event.thread_id}\n") }
69
+
70
+ it "returns correctly" do
71
+ expect(output).to eq("#{event.thread_id}\n")
72
+ end
54
73
  end
55
74
 
56
75
  context "%h" do
57
76
  let(:pattern) { "%h" }
58
- it { should eq("#{event.hostname}\n") }
77
+
78
+ it "returns correctly" do
79
+ expect(output).to eq("#{event.hostname}\n")
80
+ end
59
81
  end
60
82
 
61
83
  context ":caller" do
62
84
  let(:_caller) { [nil, nil, "/path/to/file.rb:123:in `test_method'"] }
63
85
 
64
86
  before do
65
- any_instance_of(Yell::Event) do |e|
66
- stub(e).file { "/path/to/file.rb" }
67
- stub(e).line { "123" }
68
- stub(e).method { "test_method" }
69
- end
87
+ allow(event).to receive(:file) { "/path/to/file.rb" }
88
+ allow(event).to receive(:line) { "123" }
89
+ allow(event).to receive(:method) { "test_method" }
70
90
  end
71
91
 
72
92
  context "%F" do
73
93
  let(:pattern) { "%F" }
74
- it { should eq("/path/to/file.rb\n") }
94
+
95
+ it "returns correctly" do
96
+ expect(output).to eq("/path/to/file.rb\n")
97
+ end
75
98
  end
76
99
 
77
100
  context "%f" do
78
101
  let(:pattern) { "%f" }
79
- it { should eq("file.rb\n") }
102
+
103
+ it "returns correctly" do
104
+ expect(output).to eq("file.rb\n")
105
+ end
80
106
  end
81
107
 
82
108
  context "%M" do
83
109
  let(:pattern) { "%M" }
84
- it { should eq("test_method\n") }
110
+
111
+ it "returns correctly" do
112
+ expect(output).to eq("test_method\n")
113
+ end
85
114
  end
86
115
 
87
116
  context "%n" do
88
117
  let(:pattern) { "%n" }
89
- it { should eq("123\n") }
118
+
119
+ it "returns correctly" do
120
+ expect(output).to eq("123\n")
121
+ end
90
122
  end
91
123
  end
92
124
 
93
125
  context "%N" do
94
126
  let(:pattern) { "%N" }
95
- it { should eq("Yell\n") }
127
+
128
+ it "returns correctly" do
129
+ expect(output).to eq("Yell\n")
130
+ end
96
131
  end
97
132
  end
98
133
 
99
134
  describe "presets" do
100
135
  context "NoFormat" do
101
136
  let(:pattern) { Yell::NoFormat }
102
- it { should eq("Hello World!\n") }
137
+
138
+ it "Retrns correctly" do
139
+ expect(output).to eq("Hello World!\n")
140
+ end
103
141
  end
104
142
 
105
143
  context "DefaultFormat" do
106
144
  let(:pattern) { Yell::DefaultFormat }
107
- it { should eq("#{time.iso8601} [ INFO] #{$$} : Hello World!\n") }
145
+
146
+ it "returns correctly" do
147
+ expect(output).to eq("#{time.iso8601} [ INFO] #{$$} : Hello World!\n")
148
+ end
108
149
  end
109
150
 
110
151
  context "BasicFormat" do
111
152
  let(:pattern) { Yell::BasicFormat }
112
- it { should eq("I, #{time.iso8601} : Hello World!\n") }
153
+
154
+ it "returns correctly" do
155
+ expect(output).to eq("I, #{time.iso8601} : Hello World!\n")
156
+ end
113
157
  end
114
158
 
115
159
  context "ExtendedFormat" do
116
160
  let(:pattern) { Yell::ExtendedFormat }
117
- it { should eq("#{time.iso8601} [ INFO] #{$$} #{Socket.gethostname} : Hello World!\n") }
161
+
162
+ it "Returns correctly" do
163
+ expect(output).to eq("#{time.iso8601} [ INFO] #{$$} #{Socket.gethostname} : Hello World!\n")
164
+ end
118
165
  end
119
166
  end
120
167
 
@@ -122,16 +169,20 @@ describe Yell::Formatter do
122
169
  let(:message) { StandardError.new("This is an Exception") }
123
170
 
124
171
  before do
125
- stub(message).backtrace { ["backtrace"] }
172
+ allow(message).to receive(:backtrace) { ["backtrace"] }
126
173
  end
127
174
 
128
- it { should eq("StandardError: This is an Exception\n\tbacktrace\n") }
175
+ it "returns correctly" do
176
+ expect(output).to eq("StandardError: This is an Exception\n\tbacktrace\n")
177
+ end
129
178
  end
130
179
 
131
180
  describe "Hash" do
132
181
  let(:message) { {:test => 'message'} }
133
182
 
134
- it { should eq("test: message\n") }
183
+ it "Returns correctly" do
184
+ expect(output).to eq("test: message\n")
185
+ end
135
186
  end
136
187
 
137
188
  describe "custom message modifiers" do
@@ -139,8 +190,8 @@ describe Yell::Formatter do
139
190
  Yell::Formatter.new(pattern) { |f| f.modify(String) { |m| "Modified! #{m}" } }
140
191
  end
141
192
 
142
- it { should eq("Modified! #{message}\n") }
193
+ it "Returns correctly" do
194
+ expect(output).to eq("Modified! #{message}\n")
195
+ end
143
196
  end
144
-
145
197
  end
146
-
@@ -6,15 +6,16 @@ end
6
6
 
7
7
  describe Yell::Loggable do
8
8
  let(:factory) { LoggableFactory.new }
9
- subject { factory }
10
9
 
11
- it { should respond_to(:logger) }
10
+ it "responds with logger" do
11
+ expect(factory).to respond_to(:logger)
12
+ end
12
13
 
13
14
  it "should make a lookup in the Yell::Repository" do
14
- mock(Yell::Repository)[LoggableFactory]
15
+ expect(Yell::Repository).to(
16
+ receive(:[]).with(LoggableFactory)
17
+ )
15
18
 
16
19
  factory.logger
17
20
  end
18
-
19
21
  end
20
-
@@ -111,7 +111,9 @@ describe Yell::Logger do
111
111
 
112
112
  context "initialize with a #filename" do
113
113
  it "should call adapter with :file" do
114
- mock.proxy(Yell::Adapters::File).new(:filename => filename)
114
+ expect(Yell::Adapters::File).to(
115
+ receive(:new).with(:filename => filename).and_call_original
116
+ )
115
117
 
116
118
  Yell::Logger.new(filename)
117
119
  end
@@ -121,14 +123,18 @@ describe Yell::Logger do
121
123
  let(:pathname) { Pathname.new(filename) }
122
124
 
123
125
  it "should call adapter with :file" do
124
- mock.proxy(Yell::Adapters::File).new(:filename => pathname)
126
+ expect(Yell::Adapters::File).to(
127
+ receive(:new).with(:filename => pathname).and_call_original
128
+ )
125
129
 
126
130
  Yell::Logger.new(pathname)
127
131
  end
128
132
  end
129
133
 
130
134
  context "initialize with a :stdout adapter" do
131
- before { mock.proxy(Yell::Adapters::Stdout).new(anything) }
135
+ before do
136
+ expect(Yell::Adapters::Stdout).to receive(:new)
137
+ end
132
138
 
133
139
  it "should call adapter with STDOUT" do
134
140
  Yell::Logger.new(STDOUT)
@@ -140,7 +146,9 @@ describe Yell::Logger do
140
146
  end
141
147
 
142
148
  context "initialize with a :stderr adapter" do
143
- before { mock.proxy(Yell::Adapters::Stderr).new(anything) }
149
+ before do
150
+ expect(Yell::Adapters::Stderr).to receive(:new)
151
+ end
144
152
 
145
153
  it "should call adapter with STDERR" do
146
154
  Yell::Logger.new(STDERR)
@@ -186,12 +194,22 @@ describe Yell::Logger do
186
194
 
187
195
  context "initialize with #adapters option" do
188
196
  it "should set adapters in logger correctly" do
189
- any_instance_of(Yell::Logger) do |logger|
190
- mock.proxy(logger).adapter(:stdout)
191
- mock.proxy(logger).adapter(:stderr, :level => :error)
192
- end
193
-
194
- Yell::Logger.new(:adapters => [:stdout, {:stderr => {:level => :error}}])
197
+ expect(Yell::Adapters::Stdout).to(
198
+ receive(:new).
199
+ and_call_original
200
+ )
201
+ expect(Yell::Adapters::Stderr).to(
202
+ receive(:new).
203
+ with(hash_including(:level => :error)).
204
+ and_call_original
205
+ )
206
+
207
+ Yell::Logger.new(
208
+ :adapters => [
209
+ :stdout,
210
+ {:stderr => {:level => :error}}
211
+ ]
212
+ )
195
213
  end
196
214
  end
197
215
 
@@ -203,8 +221,12 @@ describe Yell::Logger do
203
221
  factory = LoggerFactory.new
204
222
  factory.logger = logger
205
223
 
206
- mock(stdout.send(:stream)).syswrite("#{__FILE__}, 7: info\n")
207
- mock(stdout.send(:stream)).syswrite("#{__FILE__}, 11: add\n")
224
+ expect(stdout.send(:stream)).to(
225
+ receive(:syswrite).with("#{__FILE__}, 7: info\n")
226
+ )
227
+ expect(stdout.send(:stream)).to(
228
+ receive(:syswrite).with("#{__FILE__}, 11: add\n")
229
+ )
208
230
 
209
231
  factory.info
210
232
  factory.add
@@ -252,13 +274,13 @@ describe Yell::Logger do
252
274
  let(:logger) { Yell::Logger.new(stdout, :silence => silence) }
253
275
 
254
276
  it "should not pass a matching message to any adapter" do
255
- dont_allow(stdout).write
277
+ expect(stdout).to_not receive(:write)
256
278
 
257
279
  logger.info "this should not be logged"
258
280
  end
259
281
 
260
282
  it "should pass a non-matching message to any adapter" do
261
- mock(stdout).write(is_a(Yell::Event))
283
+ expect(stdout).to receive(:write).with(kind_of(Yell::Event))
262
284
 
263
285
  logger.info "that should be logged"
264
286
  end
@@ -23,8 +23,13 @@ describe Yell::Repository do
23
23
  let!(:logger) { Yell.new(:stdout, :name => "Numeric") }
24
24
 
25
25
  it "should raise with the correct :name when logger not found" do
26
- mock.proxy(Yell::LoggerNotFound).new(String)
27
- expect{ Yell::Repository[String] }.to raise_error(Yell::LoggerNotFound)
26
+ expect(Yell::LoggerNotFound).to(
27
+ receive(:new).with(String).and_call_original
28
+ )
29
+
30
+ expect {
31
+ Yell::Repository[String]
32
+ }.to raise_error(Yell::LoggerNotFound)
28
33
  end
29
34
 
30
35
  it "should return the logger" do
@@ -33,7 +33,9 @@ describe Yell do
33
33
  subject { Yell.load!('yell.yml') }
34
34
 
35
35
  before do
36
- mock(Yell::Configuration).load!('yell.yml') { {} }
36
+ expect(Yell::Configuration).to(
37
+ receive(:load!).with('yell.yml') { {} }
38
+ )
37
39
  end
38
40
 
39
41
  it "should be_kind_of Yell::Logger" do
@@ -45,7 +47,7 @@ describe Yell do
45
47
  let(:name) { 'test' }
46
48
 
47
49
  it "should delegate to the repository" do
48
- mock(Yell::Repository)[name]
50
+ expect(Yell::Repository).to receive(:[]).with(name)
49
51
 
50
52
  Yell[name]
51
53
  end
@@ -55,7 +57,9 @@ describe Yell do
55
57
  let(:name) { 'test' }
56
58
 
57
59
  it "should delegate to the repository" do
58
- mock.proxy(Yell::Repository)[name] = logger
60
+ expect(Yell::Repository).to(
61
+ receive(:[]=).with(name, logger).and_call_original
62
+ )
59
63
 
60
64
  Yell[name] = logger
61
65
  end
@@ -70,8 +74,8 @@ describe Yell do
70
74
 
71
75
  context "fallback to RACK_ENV" do
72
76
  before do
73
- stub(ENV).key?('YELL_ENV') { false }
74
- mock(ENV).key?('RACK_ENV') { true }
77
+ expect(ENV).to receive(:key?).with('YELL_ENV') { false }
78
+ expect(ENV).to receive(:key?).with('RACK_ENV') { true }
75
79
 
76
80
  ENV['RACK_ENV'] = 'rack'
77
81
  end
@@ -85,9 +89,9 @@ describe Yell do
85
89
 
86
90
  context "fallback to RAILS_ENV" do
87
91
  before do
88
- stub(ENV).key?('YELL_ENV') { false }
89
- stub(ENV).key?('RACK_ENV') { false }
90
- mock(ENV).key?('RAILS_ENV') { true }
92
+ expect(ENV).to receive(:key?).with('YELL_ENV') { false }
93
+ expect(ENV).to receive(:key?).with('RACK_ENV') { false }
94
+ expect(ENV).to receive(:key?).with('RAILS_ENV') { true }
91
95
 
92
96
  ENV['RAILS_ENV'] = 'rails'
93
97
  end
@@ -101,9 +105,9 @@ describe Yell do
101
105
 
102
106
  context "fallback to development" do
103
107
  before do
104
- stub(ENV).key?('YELL_ENV') { false }
105
- stub(ENV).key?('RACK_ENV') { false }
106
- stub(ENV).key?('RAILS_ENV') { false }
108
+ expect(ENV).to receive(:key?).with('YELL_ENV') { false }
109
+ expect(ENV).to receive(:key?).with('RACK_ENV') { false }
110
+ expect(ENV).to receive(:key?).with('RAILS_ENV') { false }
107
111
  end
108
112
 
109
113
  it "should == 'development'" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yell
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.6
4
+ version: 2.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rudolf Schmidt
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-04-14 00:00:00.000000000 Z
11
+ date: 2016-10-23 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Yell - Your Extensible Logging Library. Define multiple adapters, various
14
14
  log level combinations or message formatting options like you've never done before