Module: Fixtures::Time
Overview
Test data around time schemas
Instance Method Summary collapse
-
#earliest ⇒ Example
A time schema that has a restriction on the earliest time.
-
#earliest_time ⇒ Time
A time that is used by the #earliest example.
-
#latest ⇒ Example
A time schema that has a restriction on the latest time.
-
#latest_time ⇒ Time
A time that is used by the #latest example.
-
#optional ⇒ Example
A time schema that is optional.
-
#simple ⇒ Example
A simple time schema.
-
#variants ⇒ Hash{Symbol => untyped}
The variants used by each example.
Instance Method Details
#earliest ⇒ Example
A time schema that has a restriction on the earliest time
45 46 47 |
# File 'lib/data_model/fixtures/time.rb', line 45 def earliest Example.new([:time, { earliest: earliest_time }], variants:) end |
#earliest_time ⇒ Time
Returns a time that is used by the #earliest example.
8 9 10 |
# File 'lib/data_model/fixtures/time.rb', line 8 def earliest_time return ::Time.now - 1 end |
#latest ⇒ Example
A time schema that has a restriction on the latest time
51 52 53 |
# File 'lib/data_model/fixtures/time.rb', line 51 def latest Example.new([:time, { latest: latest_time }], variants:) end |
#latest_time ⇒ Time
Returns a time that is used by the #latest example.
13 14 15 |
# File 'lib/data_model/fixtures/time.rb', line 13 def latest_time return ::Time.now + 1 end |
#optional ⇒ Example
A time schema that is optional
39 40 41 |
# File 'lib/data_model/fixtures/time.rb', line 39 def optional Example.new([:time, { optional: true }], variants:) end |
#simple ⇒ Example
A simple time schema
33 34 35 |
# File 'lib/data_model/fixtures/time.rb', line 33 def simple Example.new([:time], 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/time.rb', line 18 def variants now = ::Time.now { time: now, string: [now.strftime("%H:%M:%S.%6N"), now], invalid: "invalid", early: earliest_time - 1, late: latest_time + 1, missing: nil } end |