Skip to content

Commit

Permalink
Merge pull request #1113 from herwinw/date_iso8601
Browse files Browse the repository at this point in the history
Extend specs for Date.iso8601
  • Loading branch information
andrykonchin authored Nov 13, 2023
2 parents bc5f987 + c6e9c28 commit ca1073c
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions library/date/iso8601_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,18 @@
d.should == Date.civil(-4712, 1, 1)
end

it "raises a Date::Error if the argument is a invalid Date" do
-> {
Date.iso8601('invalid')
}.should raise_error(Date::Error, "invalid date")
end

it "raises a Date::Error when passed a nil" do
-> {
Date.iso8601(nil)
}.should raise_error(Date::Error, "invalid date")
end

it "raises a TypeError when passed an Object" do
-> { Date.iso8601(Object.new) }.should raise_error(TypeError)
end
Expand All @@ -32,4 +44,13 @@
h = Date._iso8601('invalid')
h.should == {}
end

it "returns an empty hash if the argument is nil" do
h = Date._iso8601(nil)
h.should == {}
end

it "raises a TypeError when passed an Object" do
-> { Date._iso8601(Object.new) }.should raise_error(TypeError)
end
end

0 comments on commit ca1073c

Please sign in to comment.