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

Make sure Rational specs pass with Ruby 1.8.x

This commit is contained in:
Mike Dvorkin 2012-09-03 21:22:05 -07:00
parent c7bdcd85e6
commit bef11700b5
3 changed files with 13 additions and 2 deletions

View file

@ -37,6 +37,7 @@ Default options:
:keyword => :cyan,
:method => :purpleish,
:nilclass => :red,
:rational => :blue,
:string => :yellowish,
:struct => :pale,
:symbol => :cyanish,

View file

@ -201,7 +201,7 @@ module AwesomePrint
def awesome_bigdecimal(n)
colorize(n.to_s("F"), :bigdecimal)
end
# Format Rational object.
#------------------------------------------------------------------------------
def awesome_rational(n)

View file

@ -486,7 +486,17 @@ EOS
it "should present Rational object with arbitrary precision" do
rat = Rational(201020102010201020102010201020102010, 2)
rat.ai(:plain => true).should == "100510051005100510051005100510051005/1"
out = rat.ai(:plain => true)
#
# Ruby 1.9 slightly changed the format of Rational#to_s, see
# http://techtime.getharvest.com/blog/harvest-is-now-on-ruby-1-dot-9-3 and
# http://www.ruby-forum.com/topic/189397
#
if RUBY_VERSION < "1.9"
out.should == "100510051005100510051005100510051005"
else
out.should == "100510051005100510051005100510051005/1"
end
end
end