Skip to content

Commit

Permalink
Rational#to_i: Share spec; 1.9 moved Rational to core
Browse files Browse the repository at this point in the history
  • Loading branch information
runpaint committed Jun 17, 2009
1 parent 9afdb50 commit 481ee80
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 13 deletions.
17 changes: 4 additions & 13 deletions library/rational/to_i_spec.rb
Original file line number Diff line number Diff line change
@@ -1,16 +1,7 @@
require File.dirname(__FILE__) + '/../../spec_helper'
require 'rational'
require File.dirname(__FILE__) + '/../../shared/rational/to_i'

describe "Rational#to_i" do
it "converts self to an Integer by truncation" do
Rational(7, 4).to_i.should eql(1)
Rational(11, 4).to_i.should eql(2)
ruby_version_is ""..."1.9" do
describe "Rational#to_i" do
it_behaves_like(:rational_to_i, :to_i)
end

ruby_bug "#", "1.8.6" do
it "converts self to an Integer by truncation" do
Rational(-7, 4).to_i.should eql(-1)
end
end

end
15 changes: 15 additions & 0 deletions shared/rational/to_i.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
require File.dirname(__FILE__) + '/../../spec_helper'
require 'rational'

describe :rational_to_i, :shared => true do
it "converts self to an Integer by truncation" do
Rational(7, 4).to_i.should eql(1)
Rational(11, 4).to_i.should eql(2)
end

ruby_bug "#", "1.8.6" do
it "converts self to an Integer by truncation" do
Rational(-7, 4).to_i.should eql(-1)
end
end
end

0 comments on commit 481ee80

Please sign in to comment.