diff --git a/spec/active_record_spec.rb b/spec/active_record_spec.rb index c271eb9..e5e5836 100644 --- a/spec/active_record_spec.rb +++ b/spec/active_record_spec.rb @@ -50,37 +50,53 @@ if defined?(::ActiveRecord) it "display single record" do out = @ap.send(:awesome, @diana) - out.gsub(/0x([a-f\d]+)/, "0x01234567").should == <<-EOS.strip + str = <<-EOS.strip # { :id => nil, :name => "Diana", :rank => 1, :admin => false, - :created_at => Sat Oct 10 12:30:00 UTC 1992 + :created_at => ? } EOS + if RUBY_VERSION.to_f < 1.9 + str.sub!('?', 'Sat Oct 10 12:30:00 UTC 1992') + else + str.sub!('?', '1992-10-10 12:30:00 UTC') + end + + out.gsub(/0x([a-f\d]+)/, "0x01234567").should == str end it "display multiple records" do out = @ap.send(:awesome, [ @diana, @laura ]) - out.gsub(/0x([a-f\d]+)/, "0x01234567").should == <<-EOS.strip + str = <<-EOS.strip [ [0] # { :id => nil, :name => "Diana", :rank => 1, :admin => false, - :created_at => Sat Oct 10 12:30:00 UTC 1992 + :created_at => ? }, [1] # { :id => nil, :name => "Laura", :rank => 2, :admin => true, - :created_at => Mon May 26 14:15:00 UTC 2003 + :created_at => ! } ] EOS + if RUBY_VERSION.to_f < 1.9 + str.sub!('?', 'Sat Oct 10 12:30:00 UTC 1992') + str.sub!('!', 'Mon May 26 14:15:00 UTC 2003') + else + str.sub!('?', '1992-10-10 12:30:00 UTC') + str.sub!('!', '2003-05-26 14:15:00 UTC') + end + + out.gsub(/0x([a-f\d]+)/, "0x01234567").should == str end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 789ef6f..f3076dc 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,3 +1,17 @@ +# Copyright (c) 2010 Michael Dvorkin +# +# Awesome Print is freely distributable under the terms of MIT license. +# See LICENSE file or http://www.opensource.org/licenses/mit-license.php +#------------------------------------------------------------------------------ +# +# Running specs with Ruby 1.8.7 and RSpec 1.3+: +# $ rake spec # Entire spec suite. +# $ ruby --color -rubygems spec/logger_spec.rb # Individual spec file. +# +# Running specs with Ruby 1.9.2 and RSpec 2.0+: +# $ rake spec # Entire spec suite. +# $ rspec --color spec/logger_spec.rb # Individual spec file. +# $LOAD_PATH.unshift(File.dirname(__FILE__)) $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib')) require 'ap'