lib/rspec/rails/api/field_config.rb in rspec-rails-api-0.5.0 vs lib/rspec/rails/api/field_config.rb in rspec-rails-api-0.6.0

- old
+ new

@@ -9,13 +9,16 @@ # Represents an entity field configuration. # A field have some options and a method to serialize itself. class FieldConfig attr_accessor :required, :type, :attributes, :description - def initialize(type:, description:, required: true, attributes: nil, of: nil) + def initialize(type:, description:, required: true, attributes: nil, of: nil) # rubocop:disable Metrics/CyclomaticComplexity @required = required @description = description + raise "Field type not allowed: '#{type}'" unless Validator.valid_type?(type) + raise "Don't use 'of' on non-arrays" if of && type != :array + raise "Don't use 'attributes' on non-objects" if attributes && type != :object define_attributes attributes if type == :object define_attributes of if type == :array @type = type