[DRE-commits] [ruby-yell] 01/01: New upstream version 2.0.7
Michael Crusoe
misterc-guest at moszumanska.debian.org
Mon Oct 24 16:45:10 UTC 2016
This is an automated email from the git hooks/post-receive script.
misterc-guest pushed a commit to annotated tag upstream/2.0.7
in repository ruby-yell.
commit 0c148cbc762c085251a9c6eba91232f309c77b8e
Author: Michael R. Crusoe <crusoe at ucdavis.edu>
Date: Mon Oct 24 06:50:40 2016 -0700
New upstream version 2.0.7
---
.travis.yml | 17 ++--
Gemfile | 6 +-
lib/yell.rb | 5 --
lib/yell/adapters.rb | 13 ++-
lib/yell/adapters/io.rb | 3 -
lib/yell/helpers/adapter.rb | 4 -
lib/yell/loggable.rb | 4 -
lib/yell/logger.rb | 14 ++-
lib/yell/version.rb | 3 +-
spec/compatibility/activesupport_logger_spec.rb | 7 +-
spec/compatibility/formatter_spec.rb | 8 +-
spec/spec_helper.rb | 10 +--
spec/yell/adapters/base_spec.rb | 10 +--
spec/yell/adapters/datefile_spec.rb | 2 +-
spec/yell/adapters/file_spec.rb | 21 +++--
spec/yell/adapters/io_spec.rb | 11 ++-
spec/yell/adapters_spec.rb | 18 ++--
spec/yell/dsl_spec.rb | 2 +-
spec/yell/formatter_spec.rb | 115 +++++++++++++++++-------
spec/yell/loggable_spec.rb | 11 +--
spec/yell/logger_spec.rb | 50 ++++++++---
spec/yell/repository_spec.rb | 9 +-
spec/yell_spec.rb | 26 +++---
23 files changed, 212 insertions(+), 157 deletions(-)
diff --git a/.travis.yml b/.travis.yml
index 1a83dfd..46a9ca4 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,18 +1,13 @@
+sudo: false
language: ruby
script: "rspec"
rvm:
- - 1.8.7
- - 1.9.3
- - 2.0.0
- - 2.1.1
- - jruby-18mode
- - jruby-19mode
- - rbx-2
- - ree
+ - ruby-head
+ - 2.3.1
+ - 2.2.5
notifications:
- email:
- - me at rudionrails.com
-
+ on_success: change
+ on_failure: change
diff --git a/Gemfile b/Gemfile
index 16a9656..c49a343 100644
--- a/Gemfile
+++ b/Gemfile
@@ -7,9 +7,9 @@ group :development, :test do
gem "rake"
gem 'rspec-core', '~> 3'
- gem 'rspec-expectations', '~> 3'
+ gem 'rspec-expectations'
+ gem 'rspec-mocks'
gem 'rspec-its'
- gem "rr"
if RUBY_VERSION < "1.9"
gem 'timecop', '0.6.0'
@@ -18,7 +18,7 @@ group :development, :test do
gem 'timecop'
gem 'activesupport'
- gem 'pry'
+ gem 'byebug'
end
gem 'simplecov', :require => false, :platform => :ruby_20
diff --git a/lib/yell.rb b/lib/yell.rb
index 5c681e7..20fe224 100644
--- a/lib/yell.rb
+++ b/lib/yell.rb
@@ -22,7 +22,6 @@
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
module Yell #:nodoc:
-
# Holds all Yell severities
Severities = ['DEBUG', 'INFO', 'WARN', 'ERROR', 'FATAL', 'UNKNOWN'].freeze
@@ -112,9 +111,7 @@ module Yell #:nodoc:
value.nil? ? options[:default] : value
end
-
end
-
end
# helpers
@@ -147,5 +144,3 @@ Yell.register :file, Yell::Adapters::File
Yell.register :datefile, Yell::Adapters::Datefile
Yell.register :stdout, Yell::Adapters::Stdout
Yell.register :stderr, Yell::Adapters::Stderr
-
-
diff --git a/lib/yell/adapters.rb b/lib/yell/adapters.rb
index 4de0260..1de1ee0 100644
--- a/lib/yell/adapters.rb
+++ b/lib/yell/adapters.rb
@@ -1,6 +1,5 @@
# encoding: utf-8
module Yell #:nodoc:
-
# AdapterNotFound is raised whenever you want to instantiate an
# adapter that does not exist.
class AdapterNotFound < StandardError; end
@@ -9,7 +8,6 @@ module Yell #:nodoc:
# the logger. You should not have to call the corresponding classes
# directly.
module Adapters
-
class Collection
def initialize( options = {} )
@options = options
@@ -61,19 +59,18 @@ module Yell #:nodoc:
#
# @example A simple file adapter
# Yell::Adapters.new( :file )
- def self.new( name, options = {}, &block )
- return name if name.is_a?(Yell::Adapters::Base)
+ def self.new( type, options = {}, &block )
+ return type if type.is_a?(Yell::Adapters::Base)
- adapter = case name
+ adapter = case type
when STDOUT then @adapters[:stdout]
when STDERR then @adapters[:stderr]
- else @adapters[name.to_sym]
+ else @adapters[type.to_sym]
end
- raise AdapterNotFound.new(name) if adapter.nil?
+ raise AdapterNotFound.new(type) if adapter.nil?
adapter.new(options, &block)
end
-
end
end
diff --git a/lib/yell/adapters/io.rb b/lib/yell/adapters/io.rb
index 904a873..8498016 100644
--- a/lib/yell/adapters/io.rb
+++ b/lib/yell/adapters/io.rb
@@ -2,7 +2,6 @@
module Yell #:nodoc:
module Adapters #:nodoc:
-
class Io < Yell::Adapters::Base
include Yell::Helpers::Formatter
@@ -94,9 +93,7 @@ module Yell #:nodoc:
def inspectables
super.concat [:formatter, :colors, :sync]
end
-
end
-
end
end
diff --git a/lib/yell/helpers/adapter.rb b/lib/yell/helpers/adapter.rb
index 8fbe01c..2fbed34 100644
--- a/lib/yell/helpers/adapter.rb
+++ b/lib/yell/helpers/adapter.rb
@@ -2,7 +2,6 @@
module Yell #:nodoc:
module Helpers #:nodoc:
module Adapter #:nodoc:
-
# Define an adapter to be used for logging.
#
# @example Standard adapter
@@ -31,7 +30,6 @@ module Yell #:nodoc:
@__adapters__
end
-
private
def reset!
@@ -39,8 +37,6 @@ module Yell #:nodoc:
super
end
-
end
end
end
-
diff --git a/lib/yell/loggable.rb b/lib/yell/loggable.rb
index 05ae0bf..8cd2d10 100644
--- a/lib/yell/loggable.rb
+++ b/lib/yell/loggable.rb
@@ -1,7 +1,6 @@
# encoding: utf-8
module Yell #:nodoc:
-
# Include this module to add a logger to any class.
#
# When including this module, your class will have a :logger instance method
@@ -17,7 +16,6 @@ module Yell #:nodoc:
#
# Foo.new.logger.info "Hello World"
module Loggable
-
def self.included(base)
base.extend(ClassMethods)
end
@@ -31,7 +29,5 @@ module Yell #:nodoc:
def logger
self.class.logger
end
-
end
end
-
diff --git a/lib/yell/logger.rb b/lib/yell/logger.rb
index 30bb7ee..8792013 100644
--- a/lib/yell/logger.rb
+++ b/lib/yell/logger.rb
@@ -1,9 +1,7 @@
# encoding: utf-8
-
require 'pathname'
module Yell #:nodoc:
-
# The +Yell::Logger+ is your entrypoint. Anything onwards is derived from here.
#
# A +Yell::Logger+ instance holds all your adapters and sends the log events
@@ -144,11 +142,12 @@ module Yell #:nodoc:
#
# @example
# extract!(:stdout => {:level => :info}, :stderr => {:level => :error})
- def extract!( *adapters )
- adapters.each do |a|
- case a
- when Hash then a.each { |t, o| adapter(t, o) }
- else adapter(a)
+ def extract!( *list )
+ list.each do |a|
+ if a.is_a?(Hash)
+ a.each { |t, o| adapter(t, o) }
+ else
+ adapter(a)
end
end
end
@@ -157,7 +156,6 @@ module Yell #:nodoc:
def inspectables
[:name] | super
end
-
end
end
diff --git a/lib/yell/version.rb b/lib/yell/version.rb
index 481fb5d..ccd6aa5 100644
--- a/lib/yell/version.rb
+++ b/lib/yell/version.rb
@@ -1,7 +1,6 @@
# encoding: utf-8
module Yell #:nodoc:
- VERSION = "2.0.6"
-
+ VERSION = "2.0.7"
end
diff --git a/spec/compatibility/activesupport_logger_spec.rb b/spec/compatibility/activesupport_logger_spec.rb
index 7ff24ae..f00c008 100644
--- a/spec/compatibility/activesupport_logger_spec.rb
+++ b/spec/compatibility/activesupport_logger_spec.rb
@@ -10,7 +10,8 @@ end
#
# We simulate the case when Rails 4 starts up its server
# and wants to append the log output.
-describe "Compatibility to ActiveSupport::Logger", :pending => (!defined?(ActiveSupport) || ActiveSupport::VERSION::MAJOR < 4) do
+describe "Compatibility to ActiveSupport::Logger",
+ :pending => (!defined?(ActiveSupport) || ActiveSupport::VERSION::MAJOR < 4) do
let!(:yell) { Yell.new($stdout, :format => "%m") }
@@ -25,8 +26,8 @@ describe "Compatibility to ActiveSupport::Logger", :pending => (!defined?(Active
end
it "should behave correctly" do
- mock($stdout).syswrite("Hello World\n") # yell
- mock($stdout).write("Hello World\n") # logger
+ expect($stdout).to receive(:syswrite).with("Hello World\n") # yell
+ expect($stdout).to receive(:write).with("Hello World\n") # logger
yell.info "Hello World"
end
diff --git a/spec/compatibility/formatter_spec.rb b/spec/compatibility/formatter_spec.rb
index 00a4484..d279233 100644
--- a/spec/compatibility/formatter_spec.rb
+++ b/spec/compatibility/formatter_spec.rb
@@ -2,22 +2,20 @@ require 'spec_helper'
require 'logger'
describe "backwards compatible formatter" do
-
let(:time) { Time.now }
let(:formatter) { Yell::Formatter.new(Yell::DefaultFormat) }
let(:logger) { Logger.new($stdout) }
before do
Timecop.freeze(time)
-
logger.formatter = formatter
end
it "should format out the message correctly" do
- mock($stdout).write("#{time.iso8601} [ INFO] #{$$} : Hello World!\n")
+ expect($stdout).to(
+ receive(:write).with("#{time.iso8601} [ INFO] #{$$} : Hello World!\n")
+ )
logger.info "Hello World!"
end
-
end
-
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index d1e21e8..ef07e41 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -5,14 +5,10 @@ ENV['YELL_ENV'] = 'test'
require 'rspec/core'
require 'rspec/expectations'
+require 'rspec/mocks'
require 'rspec/its'
-require 'rr'
require 'timecop'
-
-begin
- require 'pry'
-rescue LoadError
-end
+require 'byebug'
begin
require 'coveralls'
@@ -34,8 +30,6 @@ end
require 'yell'
RSpec.configure do |config|
- config.mock_framework = :rr
-
config.before :each do
Yell::Repository.loggers.clear
diff --git a/spec/yell/adapters/base_spec.rb b/spec/yell/adapters/base_spec.rb
index d0e62c0..f2ea412 100644
--- a/spec/yell/adapters/base_spec.rb
+++ b/spec/yell/adapters/base_spec.rb
@@ -22,20 +22,20 @@ describe Yell::Adapters::Base do
context "#write" do
let(:logger) { Yell::Logger.new }
- subject { Yell::Adapters::Base.new(:level => 1) }
+ let(:adapter) { Yell::Adapters::Base.new(:level => 1) }
it "should delegate :event to :write!" do
event = Yell::Event.new(logger, 1, "Hello World!")
- mock(subject).write!(event)
+ expect(adapter).to receive(:write!).with(event)
- subject.write(event)
+ adapter.write(event)
end
it "should not write when event does not have the right level" do
event = Yell::Event.new(logger, 0, "Hello World!")
- dont_allow(subject).write!(event)
+ expect(adapter).to_not receive(:write!)
- subject.write(event)
+ adapter.write(event)
end
end
diff --git a/spec/yell/adapters/datefile_spec.rb b/spec/yell/adapters/datefile_spec.rb
index 51480bb..18b2188 100644
--- a/spec/yell/adapters/datefile_spec.rb
+++ b/spec/yell/adapters/datefile_spec.rb
@@ -42,7 +42,7 @@ describe Yell::Adapters::Datefile do
end
it "should not open file handle again" do
- dont_allow(File).open(anything, anything)
+ expect(File).to_not receive(:open)
adapter.write(event)
end
diff --git a/spec/yell/adapters/file_spec.rb b/spec/yell/adapters/file_spec.rb
index 785cb80..6c33af8 100644
--- a/spec/yell/adapters/file_spec.rb
+++ b/spec/yell/adapters/file_spec.rb
@@ -4,7 +4,7 @@ describe Yell::Adapters::File do
let(:devnull) { File.new('/dev/null', 'w') }
before do
- stub(File).open(anything, anything) { devnull }
+ allow(File).to receive(:open) { devnull }
end
it { should be_kind_of(Yell::Adapters::Io) }
@@ -24,7 +24,10 @@ describe Yell::Adapters::File do
let(:adapter) { Yell::Adapters::File.new }
it "should print to file" do
- mock(File).open(filename, File::WRONLY|File::APPEND|File::CREAT) { devnull }
+ expect(File).to(
+ receive(:open).
+ with(filename, File::WRONLY|File::APPEND|File::CREAT) { devnull }
+ )
adapter.write(event)
end
@@ -35,7 +38,10 @@ describe Yell::Adapters::File do
let(:adapter) { Yell::Adapters::File.new(:filename => filename) }
it "should print to file" do
- mock(File).open(filename, File::WRONLY|File::APPEND|File::CREAT) { devnull }
+ expect(File).to(
+ receive(:open).
+ with(filename, File::WRONLY|File::APPEND|File::CREAT) { devnull }
+ )
adapter.write(event)
end
@@ -46,7 +52,10 @@ describe Yell::Adapters::File do
let(:adapter) { Yell::Adapters::File.new( :filename => pathname ) }
it "should accept pathanme as filename" do
- mock(File).open(pathname.to_s, File::WRONLY|File::APPEND|File::CREAT) { devnull }
+ expect(File).to(
+ receive(:open).
+ with(pathname.to_s, File::WRONLY|File::APPEND|File::CREAT) { devnull }
+ )
adapter.write(event)
end
@@ -56,7 +65,7 @@ describe Yell::Adapters::File do
let(:adapter) { Yell::Adapters::File.new }
it "should sync by default" do
- mock(devnull).sync=(true)
+ expect(devnull).to receive(:sync=).with(true)
adapter.write(event)
end
@@ -64,7 +73,7 @@ describe Yell::Adapters::File do
it "pass the option to File" do
adapter.sync = false
- mock(devnull).sync=(false)
+ expect(devnull).to receive(:sync=).with(false)
adapter.write(event)
end
diff --git a/spec/yell/adapters/io_spec.rb b/spec/yell/adapters/io_spec.rb
index 5f26642..b7dab24 100644
--- a/spec/yell/adapters/io_spec.rb
+++ b/spec/yell/adapters/io_spec.rb
@@ -1,7 +1,6 @@
require 'spec_helper'
describe Yell::Adapters::Io do
-
it { should be_kind_of Yell::Adapters::Base }
context "initialize" do
@@ -51,22 +50,22 @@ describe Yell::Adapters::Io do
let(:stream) { File.new('/dev/null', 'w') }
before do
- stub(adapter).stream { stream }
+ allow(adapter).to receive(:stream) { stream }
end
it "should format the message" do
- mock.proxy(adapter.format).call( event )
+ expect(adapter.format).to(
+ receive(:call).with(event).and_call_original
+ )
adapter.write(event)
end
it "should print formatted message to stream" do
formatted = Yell::Formatter.new.call(event)
- mock(stream).syswrite(formatted)
+ expect(stream).to receive(:syswrite).with(formatted)
adapter.write(event)
end
end
-
end
-
diff --git a/spec/yell/adapters_spec.rb b/spec/yell/adapters_spec.rb
index bbb1495..f009007 100644
--- a/spec/yell/adapters_spec.rb
+++ b/spec/yell/adapters_spec.rb
@@ -11,35 +11,33 @@ describe Yell::Adapters do
end
it "should accept STDOUT" do
- mock.proxy(Yell::Adapters::Stdout).new(anything)
+ expect(Yell::Adapters::Stdout).to receive(:new).with(anything)
Yell::Adapters.new(STDOUT)
end
it "should accept STDERR" do
- mock.proxy(Yell::Adapters::Stderr).new(anything)
+ expect(Yell::Adapters::Stderr).to receive(:new).with(anything)
Yell::Adapters.new(STDERR)
end
it "should raise an unregistered adapter" do
expect {
- Yell::Adapters.new :unknown
+ Yell::Adapters.new(:unknown)
}.to raise_error(Yell::AdapterNotFound)
end
end
context ".register" do
- let(:name) { :test }
- let(:klass) { mock }
-
- before { Yell::Adapters.register(name, klass) }
+ let(:type) { :test }
+ let(:klass) { double }
it "should allow to being called from :new" do
- mock(klass).new(anything)
+ Yell::Adapters.register(type, klass)
+ expect(klass).to receive(:new).with(anything)
- Yell::Adapters.new(name)
+ Yell::Adapters.new(type)
end
end
-
end
diff --git a/spec/yell/dsl_spec.rb b/spec/yell/dsl_spec.rb
index 3c38829..4d22386 100644
--- a/spec/yell/dsl_spec.rb
+++ b/spec/yell/dsl_spec.rb
@@ -28,7 +28,7 @@ describe "Yell Adapter DSL spec" do
it "should perform #write" do
event = 'event'
- stub(event).level { 0 }
+ allow(event).to receive(:level) { 0 }
adapter = DSLAdapter.new
expect(adapter.test_write?).to be_falsey
diff --git a/spec/yell/formatter_spec.rb b/spec/yell/formatter_spec.rb
index ffac567..7b86491 100644
--- a/spec/yell/formatter_spec.rb
+++ b/spec/yell/formatter_spec.rb
@@ -1,17 +1,15 @@
require 'spec_helper'
describe Yell::Formatter do
-
let(:logger) { Yell::Logger.new(:stdout, :name => 'Yell') }
let(:message) { "Hello World!" }
let(:event) { Yell::Event.new(logger, 1, message) }
+ let(:time) { Time.now }
let(:pattern) { "%m" }
let(:formatter) { Yell::Formatter.new(pattern) }
- let(:time) { Time.now }
-
- subject { formatter.call(event) }
+ let(:output) { formatter.call(event) }
before do
Timecop.freeze(time)
@@ -20,101 +18,150 @@ describe Yell::Formatter do
describe "patterns" do
context "%m" do
let(:pattern) { "%m" }
- it { should eq("#{event.messages.join(' ')}\n") }
+
+ it "returns correctly" do
+ expect(output).to eq("#{event.messages.join(' ')}\n")
+ end
end
context "%l" do
let(:pattern) { "%l" }
- it { should eq("#{Yell::Severities[event.level][0,1]}\n") }
+
+ it "returns correctly" do
+ expect(output).to eq("#{Yell::Severities[event.level][0,1]}\n")
+ end
end
context "%L" do
let(:pattern) { "%L" }
- it { should eq("#{Yell::Severities[event.level]}\n") }
+
+ it "returns correctly" do
+ expect(output).to eq("#{Yell::Severities[event.level]}\n")
+ end
end
context "%d" do
let(:pattern) { "%d" }
- it { should eq("#{event.time.iso8601}\n") }
+
+ it "returns correctly" do
+ expect(output).to eq("#{event.time.iso8601}\n")
+ end
end
context "%p" do
let(:pattern) { "%p" }
- it { should eq("#{event.pid}\n") }
+
+ it "returns correctly" do
+ expect(output).to eq("#{event.pid}\n")
+ end
end
context "%P" do
let(:pattern) { "%P" }
- it { should eq("#{event.progname}\n") }
+
+ it "returns correctly" do
+ expect(output).to eq("#{event.progname}\n")
+ end
end
context "%t" do
let(:pattern) { "%t" }
- it { should eq("#{event.thread_id}\n") }
+
+ it "returns correctly" do
+ expect(output).to eq("#{event.thread_id}\n")
+ end
end
context "%h" do
let(:pattern) { "%h" }
- it { should eq("#{event.hostname}\n") }
+
+ it "returns correctly" do
+ expect(output).to eq("#{event.hostname}\n")
+ end
end
context ":caller" do
let(:_caller) { [nil, nil, "/path/to/file.rb:123:in `test_method'"] }
before do
- any_instance_of(Yell::Event) do |e|
- stub(e).file { "/path/to/file.rb" }
- stub(e).line { "123" }
- stub(e).method { "test_method" }
- end
+ allow(event).to receive(:file) { "/path/to/file.rb" }
+ allow(event).to receive(:line) { "123" }
+ allow(event).to receive(:method) { "test_method" }
end
context "%F" do
let(:pattern) { "%F" }
- it { should eq("/path/to/file.rb\n") }
+
+ it "returns correctly" do
+ expect(output).to eq("/path/to/file.rb\n")
+ end
end
context "%f" do
let(:pattern) { "%f" }
- it { should eq("file.rb\n") }
+
+ it "returns correctly" do
+ expect(output).to eq("file.rb\n")
+ end
end
context "%M" do
let(:pattern) { "%M" }
- it { should eq("test_method\n") }
+
+ it "returns correctly" do
+ expect(output).to eq("test_method\n")
+ end
end
context "%n" do
let(:pattern) { "%n" }
- it { should eq("123\n") }
+
+ it "returns correctly" do
+ expect(output).to eq("123\n")
+ end
end
end
context "%N" do
let(:pattern) { "%N" }
- it { should eq("Yell\n") }
+
+ it "returns correctly" do
+ expect(output).to eq("Yell\n")
+ end
end
end
describe "presets" do
context "NoFormat" do
let(:pattern) { Yell::NoFormat }
- it { should eq("Hello World!\n") }
+
+ it "Retrns correctly" do
+ expect(output).to eq("Hello World!\n")
+ end
end
context "DefaultFormat" do
let(:pattern) { Yell::DefaultFormat }
- it { should eq("#{time.iso8601} [ INFO] #{$$} : Hello World!\n") }
+
+ it "returns correctly" do
+ expect(output).to eq("#{time.iso8601} [ INFO] #{$$} : Hello World!\n")
+ end
end
context "BasicFormat" do
let(:pattern) { Yell::BasicFormat }
- it { should eq("I, #{time.iso8601} : Hello World!\n") }
+
+ it "returns correctly" do
+ expect(output).to eq("I, #{time.iso8601} : Hello World!\n")
+ end
end
context "ExtendedFormat" do
let(:pattern) { Yell::ExtendedFormat }
- it { should eq("#{time.iso8601} [ INFO] #{$$} #{Socket.gethostname} : Hello World!\n") }
+
+ it "Returns correctly" do
+ expect(output).to eq("#{time.iso8601} [ INFO] #{$$} #{Socket.gethostname} : Hello World!\n")
+ end
end
end
@@ -122,16 +169,20 @@ describe Yell::Formatter do
let(:message) { StandardError.new("This is an Exception") }
before do
- stub(message).backtrace { ["backtrace"] }
+ allow(message).to receive(:backtrace) { ["backtrace"] }
end
- it { should eq("StandardError: This is an Exception\n\tbacktrace\n") }
+ it "returns correctly" do
+ expect(output).to eq("StandardError: This is an Exception\n\tbacktrace\n")
+ end
end
describe "Hash" do
let(:message) { {:test => 'message'} }
- it { should eq("test: message\n") }
+ it "Returns correctly" do
+ expect(output).to eq("test: message\n")
+ end
end
describe "custom message modifiers" do
@@ -139,8 +190,8 @@ describe Yell::Formatter do
Yell::Formatter.new(pattern) { |f| f.modify(String) { |m| "Modified! #{m}" } }
end
- it { should eq("Modified! #{message}\n") }
+ it "Returns correctly" do
+ expect(output).to eq("Modified! #{message}\n")
+ end
end
-
end
-
diff --git a/spec/yell/loggable_spec.rb b/spec/yell/loggable_spec.rb
index 2c56dd4..23b947b 100644
--- a/spec/yell/loggable_spec.rb
+++ b/spec/yell/loggable_spec.rb
@@ -6,15 +6,16 @@ end
describe Yell::Loggable do
let(:factory) { LoggableFactory.new }
- subject { factory }
- it { should respond_to(:logger) }
+ it "responds with logger" do
+ expect(factory).to respond_to(:logger)
+ end
it "should make a lookup in the Yell::Repository" do
- mock(Yell::Repository)[LoggableFactory]
+ expect(Yell::Repository).to(
+ receive(:[]).with(LoggableFactory)
+ )
factory.logger
end
-
end
-
diff --git a/spec/yell/logger_spec.rb b/spec/yell/logger_spec.rb
index 8be5db9..f86f096 100644
--- a/spec/yell/logger_spec.rb
+++ b/spec/yell/logger_spec.rb
@@ -111,7 +111,9 @@ describe Yell::Logger do
context "initialize with a #filename" do
it "should call adapter with :file" do
- mock.proxy(Yell::Adapters::File).new(:filename => filename)
+ expect(Yell::Adapters::File).to(
+ receive(:new).with(:filename => filename).and_call_original
+ )
Yell::Logger.new(filename)
end
@@ -121,14 +123,18 @@ describe Yell::Logger do
let(:pathname) { Pathname.new(filename) }
it "should call adapter with :file" do
- mock.proxy(Yell::Adapters::File).new(:filename => pathname)
+ expect(Yell::Adapters::File).to(
+ receive(:new).with(:filename => pathname).and_call_original
+ )
Yell::Logger.new(pathname)
end
end
context "initialize with a :stdout adapter" do
- before { mock.proxy(Yell::Adapters::Stdout).new(anything) }
+ before do
+ expect(Yell::Adapters::Stdout).to receive(:new)
+ end
it "should call adapter with STDOUT" do
Yell::Logger.new(STDOUT)
@@ -140,7 +146,9 @@ describe Yell::Logger do
end
context "initialize with a :stderr adapter" do
- before { mock.proxy(Yell::Adapters::Stderr).new(anything) }
+ before do
+ expect(Yell::Adapters::Stderr).to receive(:new)
+ end
it "should call adapter with STDERR" do
Yell::Logger.new(STDERR)
@@ -186,12 +194,22 @@ describe Yell::Logger do
context "initialize with #adapters option" do
it "should set adapters in logger correctly" do
- any_instance_of(Yell::Logger) do |logger|
- mock.proxy(logger).adapter(:stdout)
- mock.proxy(logger).adapter(:stderr, :level => :error)
- end
-
- Yell::Logger.new(:adapters => [:stdout, {:stderr => {:level => :error}}])
+ expect(Yell::Adapters::Stdout).to(
+ receive(:new).
+ and_call_original
+ )
+ expect(Yell::Adapters::Stderr).to(
+ receive(:new).
+ with(hash_including(:level => :error)).
+ and_call_original
+ )
+
+ Yell::Logger.new(
+ :adapters => [
+ :stdout,
+ {:stderr => {:level => :error}}
+ ]
+ )
end
end
@@ -203,8 +221,12 @@ describe Yell::Logger do
factory = LoggerFactory.new
factory.logger = logger
- mock(stdout.send(:stream)).syswrite("#{__FILE__}, 7: info\n")
- mock(stdout.send(:stream)).syswrite("#{__FILE__}, 11: add\n")
+ expect(stdout.send(:stream)).to(
+ receive(:syswrite).with("#{__FILE__}, 7: info\n")
+ )
+ expect(stdout.send(:stream)).to(
+ receive(:syswrite).with("#{__FILE__}, 11: add\n")
+ )
factory.info
factory.add
@@ -252,13 +274,13 @@ describe Yell::Logger do
let(:logger) { Yell::Logger.new(stdout, :silence => silence) }
it "should not pass a matching message to any adapter" do
- dont_allow(stdout).write
+ expect(stdout).to_not receive(:write)
logger.info "this should not be logged"
end
it "should pass a non-matching message to any adapter" do
- mock(stdout).write(is_a(Yell::Event))
+ expect(stdout).to receive(:write).with(kind_of(Yell::Event))
logger.info "that should be logged"
end
diff --git a/spec/yell/repository_spec.rb b/spec/yell/repository_spec.rb
index ef004bc..93ff864 100644
--- a/spec/yell/repository_spec.rb
+++ b/spec/yell/repository_spec.rb
@@ -23,8 +23,13 @@ describe Yell::Repository do
let!(:logger) { Yell.new(:stdout, :name => "Numeric") }
it "should raise with the correct :name when logger not found" do
- mock.proxy(Yell::LoggerNotFound).new(String)
- expect{ Yell::Repository[String] }.to raise_error(Yell::LoggerNotFound)
+ expect(Yell::LoggerNotFound).to(
+ receive(:new).with(String).and_call_original
+ )
+
+ expect {
+ Yell::Repository[String]
+ }.to raise_error(Yell::LoggerNotFound)
end
it "should return the logger" do
diff --git a/spec/yell_spec.rb b/spec/yell_spec.rb
index 64f4788..367c6b1 100644
--- a/spec/yell_spec.rb
+++ b/spec/yell_spec.rb
@@ -33,7 +33,9 @@ describe Yell do
subject { Yell.load!('yell.yml') }
before do
- mock(Yell::Configuration).load!('yell.yml') { {} }
+ expect(Yell::Configuration).to(
+ receive(:load!).with('yell.yml') { {} }
+ )
end
it "should be_kind_of Yell::Logger" do
@@ -45,7 +47,7 @@ describe Yell do
let(:name) { 'test' }
it "should delegate to the repository" do
- mock(Yell::Repository)[name]
+ expect(Yell::Repository).to receive(:[]).with(name)
Yell[name]
end
@@ -55,7 +57,9 @@ describe Yell do
let(:name) { 'test' }
it "should delegate to the repository" do
- mock.proxy(Yell::Repository)[name] = logger
+ expect(Yell::Repository).to(
+ receive(:[]=).with(name, logger).and_call_original
+ )
Yell[name] = logger
end
@@ -70,8 +74,8 @@ describe Yell do
context "fallback to RACK_ENV" do
before do
- stub(ENV).key?('YELL_ENV') { false }
- mock(ENV).key?('RACK_ENV') { true }
+ expect(ENV).to receive(:key?).with('YELL_ENV') { false }
+ expect(ENV).to receive(:key?).with('RACK_ENV') { true }
ENV['RACK_ENV'] = 'rack'
end
@@ -85,9 +89,9 @@ describe Yell do
context "fallback to RAILS_ENV" do
before do
- stub(ENV).key?('YELL_ENV') { false }
- stub(ENV).key?('RACK_ENV') { false }
- mock(ENV).key?('RAILS_ENV') { true }
+ expect(ENV).to receive(:key?).with('YELL_ENV') { false }
+ expect(ENV).to receive(:key?).with('RACK_ENV') { false }
+ expect(ENV).to receive(:key?).with('RAILS_ENV') { true }
ENV['RAILS_ENV'] = 'rails'
end
@@ -101,9 +105,9 @@ describe Yell do
context "fallback to development" do
before do
- stub(ENV).key?('YELL_ENV') { false }
- stub(ENV).key?('RACK_ENV') { false }
- stub(ENV).key?('RAILS_ENV') { false }
+ expect(ENV).to receive(:key?).with('YELL_ENV') { false }
+ expect(ENV).to receive(:key?).with('RACK_ENV') { false }
+ expect(ENV).to receive(:key?).with('RAILS_ENV') { false }
end
it "should == 'development'" do
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-ruby-extras/ruby-yell.git
More information about the Pkg-ruby-extras-commits
mailing list