Sha256: ddeada51c25080edea9b106471ac2f6ae2ff59d6b19011eee84e287c98c2ebc8

Contents?: true

Size: 829 Bytes

Versions: 52

Compression:

Stored size: 829 Bytes

Contents

require File.expand_path('../../../spec_helper', __FILE__)

describe "Integer#to_r" do
  ruby_version_is "1.9" do
    it "returns a Rational object" do
      309.to_r.should be_an_instance_of(Rational)
    end

    it "constructs a rational number with self as the numerator" do
      34.to_r.numerator.should == 34
    end

    it "constructs a rational number with 1 as the denominator" do
      298.to_r.denominator.should == 1
    end

    it "works even if self is a Bignum" do
      bignum = 99999**999
      bignum.should be_an_instance_of(Bignum)
      bignum.to_r.should == Rational(bignum, 1)
    end

    it "raises an ArgumentError if given any arguments" do
      lambda { 287.to_r(2) }.should raise_error(ArgumentError)
      lambda { 9102826.to_r(309, [], 71) }.should raise_error(ArgumentError)
    end
  end
end

Version data entries

52 entries across 52 versions & 2 rubygems

Version Path
rhodes-7.6.0 spec/framework_spec/app/spec/core/integer/to_r_spec.rb
rhodes-7.5.1 spec/framework_spec/app/spec/core/integer/to_r_spec.rb
rhodes-7.4.1 spec/framework_spec/app/spec/core/integer/to_r_spec.rb
rhodes-7.1.17 spec/framework_spec/app/spec/core/integer/to_r_spec.rb
rhodes-6.2.0 spec/framework_spec/app/spec/core/integer/to_r_spec.rb
rhodes-6.0.11 spec/framework_spec/app/spec/core/integer/to_r_spec.rb
rhodes-5.5.18 spec/framework_spec/app/spec/core/integer/to_r_spec.rb
rhodes-5.5.17 spec/framework_spec/app/spec/core/integer/to_r_spec.rb
rhodes-5.5.15 spec/framework_spec/app/spec/core/integer/to_r_spec.rb
rhodes-5.5.0.22 spec/framework_spec/app/spec/core/integer/to_r_spec.rb
rhodes-5.5.2 spec/framework_spec/app/spec/core/integer/to_r_spec.rb
rhodes-5.5.0.7 spec/framework_spec/app/spec/core/integer/to_r_spec.rb
rhodes-5.5.0.3 spec/framework_spec/app/spec/core/integer/to_r_spec.rb
rhodes-5.5.0 spec/framework_spec/app/spec/core/integer/to_r_spec.rb
tauplatform-1.0.3 spec/framework_spec/app/spec/core/integer/to_r_spec.rb
tauplatform-1.0.2 spec/framework_spec/app/spec/core/integer/to_r_spec.rb
tauplatform-1.0.1 spec/framework_spec/app/spec/core/integer/to_r_spec.rb
rhodes-3.5.1.12 spec/framework_spec/app/spec/core/integer/to_r_spec.rb
rhodes-3.3.5 spec/framework_spec/app/spec/core/integer/to_r_spec.rb
rhodes-3.4.2 spec/framework_spec/app/spec/core/integer/to_r_spec.rb