spec/loggability/formatter_spec.rb in loggability-0.7.0 vs spec/loggability/formatter_spec.rb in loggability-0.8.0.pre.65
- old
+ new
@@ -1,27 +1,23 @@
# -*- rspec -*-
-BEGIN {
- require 'pathname'
- basedir = Pathname( __FILE__ ).dirname.parent.parent
- $LOAD_PATH.unshift( basedir.to_s ) unless $LOAD_PATH.include?( basedir.to_s )
-}
+require_relative '../helpers'
require 'tempfile'
require 'rspec'
-require 'spec/lib/helpers'
+
require 'loggability/logger'
require 'loggability/formatter'
require 'loggability/formatter/default'
describe Loggability::Formatter do
it "formats messages with the pattern it's constructed with" do
formatter = Loggability::Formatter.new( '[%5$s] %7$s' )
- formatter.call( 'INFO', Time.at(1336286481), nil, 'Foom.' ).should =~
- /\[INFO\] Foom./i
+ result = formatter.call( 'INFO', Time.at(1336286481), nil, 'Foom.' )
+ expect( result ).to match(/\[INFO\] Foom./i)
end
it "formats exceptions into useful messages" do
formatter = Loggability::Formatter.new( '[%5$s] %7$s' )
msg = nil
@@ -30,16 +26,17 @@
raise ArgumentError, "invalid argument"
rescue => err
msg = formatter.call( 'INFO', Time.at(1336286481), nil, err )
end
- msg.should =~ /\[INFO\] ArgumentError: invalid argument/i
+ expect( msg ).to match(/\[INFO\] ArgumentError: invalid argument/i)
end
it "formats regular objects into useful messages" do
formatter = Loggability::Formatter.new( '[%5$s] %7$s' )
- formatter.call( 'INFO', Time.at(1336286481), nil, Object.new ).should =~
- /\[INFO\] #<Object:0x[[:xdigit:]]+>/i
+ result = formatter.call( 'INFO', Time.at(1336286481), nil, Object.new )
+
+ expect( result ).to match(/\[INFO\] #<Object:0x[[:xdigit:]]+>/i)
end
end