summaryrefslogtreecommitdiff
path: root/spec/ruby/core/string/to_r_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby/core/string/to_r_spec.rb')
-rw-r--r--spec/ruby/core/string/to_r_spec.rb10
1 files changed, 7 insertions, 3 deletions
diff --git a/spec/ruby/core/string/to_r_spec.rb b/spec/ruby/core/string/to_r_spec.rb
index 7fa16f6f49..fb7c9d108e 100644
--- a/spec/ruby/core/string/to_r_spec.rb
+++ b/spec/ruby/core/string/to_r_spec.rb
@@ -1,8 +1,8 @@
-require File.expand_path('../../../spec_helper', __FILE__)
+require_relative '../../spec_helper'
describe "String#to_r" do
it "returns a Rational object" do
- String.new.to_r.should be_an_instance_of(Rational)
+ String.new.to_r.should.instance_of?(Rational)
end
it "returns (0/1) for the empty String" do
@@ -29,10 +29,14 @@ describe "String#to_r" do
"a1765, ".to_r.should_not == Rational(1765, 1)
end
- it "treats leading hypens as minus signs" do
+ it "treats leading hyphen as minus signs" do
"-20".to_r.should == Rational(-20, 1)
end
+ it "accepts leading plus signs" do
+ "+20".to_r.should == Rational(20, 1)
+ end
+
it "does not treat a leading period without a numeric prefix as a decimal point" do
".9".to_r.should_not == Rational(8106479329266893, 9007199254740992)
end