1
0
Fork 0
mirror of https://github.com/awesome-print/awesome_print synced 2023-03-27 23:22:34 -04:00

ActiveRecrd specs pass with Ruby 1.9.2

This commit is contained in:
Mike Dvorkin 2010-10-31 19:21:26 -07:00
parent 816b5a6513
commit 3ab0cbabc1
2 changed files with 35 additions and 5 deletions

View file

@ -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
#<User:0x01234567> {
: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] #<User:0x01234567> {
:id => nil,
:name => "Diana",
:rank => 1,
:admin => false,
:created_at => Sat Oct 10 12:30:00 UTC 1992
:created_at => ?
},
[1] #<User:0x01234567> {
: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

View file

@ -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'