summaryrefslogtreecommitdiff
path: root/spec/ruby/library/date
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/library/date
parent296f68816cf575b3ff920f92aec8a4109a7d81d4 (diff)
Update to ruby/spec@ec84479
Diffstat (limited to 'spec/ruby/library/date')
-rw-r--r--spec/ruby/library/date/parse_spec.rb17
1 files changed, 17 insertions, 0 deletions
diff --git a/spec/ruby/library/date/parse_spec.rb b/spec/ruby/library/date/parse_spec.rb
index 379847a6fd..ef72ba3f4e 100644
--- a/spec/ruby/library/date/parse_spec.rb
+++ b/spec/ruby/library/date/parse_spec.rb
@@ -69,6 +69,23 @@ describe "Date#parse" do
-> { Date.parse(1) }.should raise_error(TypeError)
-> { Date.parse(:invalid) }.should raise_error(TypeError)
end
+
+ it "coerces using to_str" do
+ c = Class.new do
+ attr_accessor :string
+ def to_str
+ @string
+ end
+ end
+ o = c.new
+ o.string = "19101101"
+
+ d = Date.parse(o)
+ d.should == Date.civil(1910, 11, 1)
+
+ # parse should not modify string value
+ o.to_str.should == "19101101"
+ end
end
describe "Date#parse with '.' separator" do