summaryrefslogtreecommitdiff
path: root/spec/ruby/core/kernel
diff options
context:
space:
mode:
authorBenoit Daloze <eregontp@gmail.com>2020-03-28 00:22:51 +0100
committerBenoit Daloze <eregontp@gmail.com>2020-03-28 00:22:51 +0100
commitf234d51eaba861edea925eabb564a0bee41b96a0 (patch)
tree3334f36a91fe81ec704f2980ab169231f52c41d0 /spec/ruby/core/kernel
parent296f68816cf575b3ff920f92aec8a4109a7d81d4 (diff)
Update to ruby/spec@ec84479
Diffstat (limited to 'spec/ruby/core/kernel')
-rw-r--r--spec/ruby/core/kernel/Float_spec.rb6
-rw-r--r--spec/ruby/core/kernel/instance_of_spec.rb2
-rw-r--r--spec/ruby/core/kernel/shared/sprintf.rb6
3 files changed, 13 insertions, 1 deletions
diff --git a/spec/ruby/core/kernel/Float_spec.rb b/spec/ruby/core/kernel/Float_spec.rb
index 6580c38137..af64fcbe86 100644
--- a/spec/ruby/core/kernel/Float_spec.rb
+++ b/spec/ruby/core/kernel/Float_spec.rb
@@ -54,6 +54,12 @@ describe :kernel_float, shared: true do
-> { @object.send(:Float, "float") }.should raise_error(ArgumentError)
end
+ it "raises an ArgumentError for a String with string in error message" do
+ -> { @object.send(:Float, "foo") }.should raise_error(ArgumentError) { |e|
+ e.message.should == 'invalid value for Float(): "foo"'
+ }
+ end
+
it "raises an ArgumentError if there are two decimal points in the String" do
-> { @object.send(:Float, "10.0.0") }.should raise_error(ArgumentError)
end
diff --git a/spec/ruby/core/kernel/instance_of_spec.rb b/spec/ruby/core/kernel/instance_of_spec.rb
index 40e856b0d9..d1170d5047 100644
--- a/spec/ruby/core/kernel/instance_of_spec.rb
+++ b/spec/ruby/core/kernel/instance_of_spec.rb
@@ -1,7 +1,7 @@
require_relative '../../spec_helper'
require_relative 'fixtures/classes'
-describe Kernel, "#instance_of?" do
+describe "Kernel#instance_of?" do
before :each do
@o = KernelSpecs::InstanceClass.new
end
diff --git a/spec/ruby/core/kernel/shared/sprintf.rb b/spec/ruby/core/kernel/shared/sprintf.rb
index 8defbfd665..1ad6f8a3cf 100644
--- a/spec/ruby/core/kernel/shared/sprintf.rb
+++ b/spec/ruby/core/kernel/shared/sprintf.rb
@@ -336,6 +336,12 @@ describe :kernel_sprintf, shared: true do
@method.call("%s", obj)
}.should raise_error(NoMethodError)
end
+
+ it "formats a partial substring without including omitted characters" do
+ long_string = "aabbccddhelloddccbbaa"
+ sub_string = long_string[8, 5]
+ sprintf("%.#{1 * 3}s", sub_string).should == "hel"
+ end
end
describe "%" do