Module: Fixtures::Time

Extended by:
Time
Includes:
Fixtures
Included in:
Time
Defined in:
lib/data_model/fixtures/time.rb

Overview

Test data around time schemas

Instance Method Summary collapse

Instance Method Details

#earliestExample

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_timeTime



8
9
10
# File 'lib/data_model/fixtures/time.rb', line 8

def earliest_time
  return ::Time.now - 1
end

#latestExample

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_timeTime



13
14
15
# File 'lib/data_model/fixtures/time.rb', line 13

def latest_time
  return ::Time.now + 1
end

#optionalExample

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

#simpleExample

A simple time schema



33
34
35
# File 'lib/data_model/fixtures/time.rb', line 33

def simple
  Example.new([:time], variants:)
end

#variantsHash{Symbol => untyped}



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