Skip to content

Commit

Permalink
FakeDataGenerator: support for new dry-types types
Browse files Browse the repository at this point in the history
  • Loading branch information
Rustam Ibragimov committed May 20, 2018
1 parent 4970c87 commit 91b7ac1
Showing 1 changed file with 32 additions and 19 deletions.
51 changes: 32 additions & 19 deletions spec/support/spec_support/fake_data_generator.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# frozen_string_literal: true

# rubocop:disable Metrics/ModuleLength
module SpecSupport::FakeDataGenerator
module_function

Expand All @@ -22,46 +23,57 @@ module SpecSupport::FakeDataGenerator
].freeze

EVENT_ATTR_CONSTRAINTS = {
primitive: nil,
strict: '::Strict',
coercible: '::Coercible',
form: '::Params',
json: '::JSON',
maybe_strict: '::Maybe::Strict',
maybe_coercible: '::Maybe::Coercible'
primitive: nil,
strict: '::Strict',
coercible: '::Coercible',
params: '::Params',
json: '::JSON',
maybe_strict: '::Maybe::Strict',
maybe_coercible: '::Maybe::Coercible',
optional_strict: '::Optional::Strict',
optional_coercible: '::Optional::Coercible'
}.freeze

EVENT_ATTR_TYPES = {
primitive: %i[
Any Nil Symbol Class True False Bool Integer
Float Decimal String Date DateTime Time Array Hash
Decimal Nil True False Bool Time DateTime Integer
Float String Array Hash Range Object Symbol Class Date Any
].freeze,

strict: %i[
Nil Symbol Class True False Bool Integer
Float Decimal String Date DateTime Time Array Hash
Decimal Nil Symbol Class False True Bool Time
Date Integer Float String Array Hash Range DateTime
].freeze,

coercible: %i[
String Integer Float Decimal Array Hash
Decimal Integer Float String Array Hash
].freeze,

form: %i[
Nil Date DateTime Time True False Bool
Integer Float Decimal Array Hash
params: %i[
Decimal Nil DateTime True False Bool
Time Date Integer Float Array Hash
].freeze,

json: %i[
Nil Date DateTime Time Decimal Array Hash
Decimal Nil DateTime Time Date Array Hash
].freeze,

maybe_strict: %i[
Class String Symbol True False Integer Float
Decimal Date DateTime Time Array Hash
Decimal Symbol Class False True Time Date
Integer Float String Array Hash Range DateTime
].freeze,

maybe_coercible: %i[
String Integer Float Decimal Array Hash
Decimal Integer Float String Array Hash
].freeze,

optional_strict: %i[
Decimal Symbol Class False True Time Date Integer
Float String Array Hash Range DateTime
].freeze,

optional_coercible: %i[
Decimal Integer Float String Array Hash
].freeze
}.freeze

Expand Down Expand Up @@ -117,3 +129,4 @@ def gen_event_attr_type(constraint = :primitive)
Object.const_get(type_const)
end
end
# rubocop:enable Metrics/ModuleLength

0 comments on commit 91b7ac1

Please sign in to comment.