Module: Fixtures::Date
Overview
Provides fixtures for testing date types
Instance Method Summary collapse
-
#earliest ⇒ Example
A date schema that has a restriction on the earliest date.
-
#earliest_date ⇒ Date
A date that is used by the #earliest example.
-
#latest ⇒ Example
A date schema that has a restriction on the latest date.
-
#latest_date ⇒ Date
A date that is used by the #latest example.
-
#optional ⇒ Example
A date schema that is optional.
-
#simple ⇒ Example
A simple date schema.
-
#variants ⇒ Hash{Symbol => untyped}
The variants used by each example.
Instance Method Details
#earliest ⇒ Example
A date schema that has a restriction on the earliest date
45 46 47 |
# File 'lib/data_model/fixtures/date.rb', line 45 def earliest Example.new([:date, { earliest: earliest_date }], variants:) end |
#earliest_date ⇒ Date
Returns a date that is used by the #earliest example.
8 9 10 |
# File 'lib/data_model/fixtures/date.rb', line 8 def earliest_date return ::Date.today - 1 end |
#latest ⇒ Example
A date schema that has a restriction on the latest date
51 52 53 |
# File 'lib/data_model/fixtures/date.rb', line 51 def latest Example.new([:date, { latest: latest_date }], variants:) end |
#latest_date ⇒ Date
Returns a date that is used by the #latest example.
13 14 15 |
# File 'lib/data_model/fixtures/date.rb', line 13 def latest_date return ::Date.today + 1 end |
#optional ⇒ Example
A date schema that is optional
39 40 41 |
# File 'lib/data_model/fixtures/date.rb', line 39 def optional Example.new([:date, { optional: true }], variants:) end |
#simple ⇒ Example
A simple date schema
33 34 35 |
# File 'lib/data_model/fixtures/date.rb', line 33 def simple Example.new([:date], variants:) end |
#variants ⇒ Hash{Symbol => untyped}
Returns the variants used by each example.
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/data_model/fixtures/date.rb', line 18 def variants today = ::Date.today { date: today, string: [today.to_s, today], invalid: "invalid", early: earliest_date - 1, late: latest_date + 1, missing: nil } end |