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

Fixed specs to work with the latest ActiveRecord

This commit is contained in:
Mike Dvorkin 2012-09-05 18:40:30 -07:00
parent 1ed20e1fbe
commit 5f00926d80

View file

@ -125,9 +125,9 @@ EOS
it "display single record" do
out = @ap.send(:awesome, @diana)
# ActiveRecord 3.1
# ActiveRecord 3.1 and on.
#--------------------------------------------------------------------------
if ActiveRecord::VERSION::STRING.start_with?('3.1')
if ActiveRecord::VERSION::STRING >= "3.1"
str = <<-EOS.strip
#<User:0x01234567
@aggregation_cache = {},
@ -182,7 +182,7 @@ EOS
EOS
# ActiveRecord 2.x
#--------------------------------------------------------------------------
else
elsif ActiveRecord::VERSION::STRING.start_with?('2.')
str = <<-EOS.strip
#<User:0x01234567
@attributes_cache = {},
@ -209,9 +209,9 @@ EOS
it "display multiple records" do
out = @ap.send(:awesome, [ @diana, @laura ])
# ActiveRecord 3.1
# ActiveRecord 3.1 and on.
#--------------------------------------------------------------------------
if ActiveRecord::VERSION::STRING.start_with?('3.1')
if ActiveRecord::VERSION::STRING >= "3.1"
str = <<-EOS.strip
[
[0] #<User:0x01234567
@ -315,7 +315,7 @@ EOS
EOS
# ActiveRecord 2.0.x
#--------------------------------------------------------------------------
else
elsif ActiveRecord::VERSION::STRING.start_with?('2.')
str = <<-EOS.strip
[
[0] #<User:0x01234567
@ -359,7 +359,6 @@ EOS
end
end
#------------------------------------------------------------------------------
describe "ActiveRecord class" do
before do
@ -403,7 +402,16 @@ EOS
it "should format class methods properly" do
out = @ap.send(:awesome, User.methods.grep(/first/))
out.should =~ /\sfirst\(\*arg.*?\)\s+User \(ActiveRecord::Base\)/
if ActiveRecord::VERSION::STRING >= "3.2"
if RUBY_VERSION >= "1.9"
out.should =~ /\sfirst\(\*args,\s&block\)\s+Class \(ActiveRecord::Querying\)/
else
out.should =~ /\sfirst\(\*arg1\)\s+Class \(ActiveRecord::Querying\)/
end
else
out.should =~ /\sfirst\(\*arg.*?\)\s+User \(ActiveRecord::Base\)/
end
out = @ap.send(:awesome, User.methods.grep(/primary_key/))
out.should =~ /\sprimary_key\(.*?\)\s+User/