Sha256: ecafcc433d99577c38dca9060209eeb47c73d99eb85639d0ce82a7b4a625fa5d

Contents?: true

Size: 701 Bytes

Versions: 3

Compression:

Stored size: 701 Bytes

Contents

require 'api-tester/definition/fields/field'

module ApiTester
  class ArrayField < Field
    attr_accessor :fields

    def initialize name
      super(name)
      self.fields = []
    end

    def with_field(newField)
      self.fields << newField
      self
    end

    def has_subfields?
      true
    end

    def default_value
      if self.fields.size == 0
        return []
      end

      obj = Hash.new
      self.fields.each do |field|
        obj[field.name] = field.default_value
      end
      [obj]
    end

    def negative_boundary_values
      super +
      [
        "string",
        123,
        0,
        1,
        true,
        false,
        {}
      ]
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
api-tester-0.3.1 lib/api-tester/definition/fields/array_field.rb
api-tester-0.3.0 lib/api-tester/definition/fields/array_field.rb
api-tester-0.2.0 lib/api-tester/definition/fields/array_field.rb