Sha256: 1511029e50b9123efd7a27033cb97956e437a15d6bbecdcebf9011de4a831c2f

Contents?: true

Size: 764 Bytes

Versions: 3

Compression:

Stored size: 764 Bytes

Contents

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

module ApiTester
  class ObjectField < 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
          obj = Hash.new

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

          obj
      end

      def negative_boundary_values
          super +
            [
              "string",
              [],
              123,
              1,
              0,
              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/object_field.rb
api-tester-0.3.0 lib/api-tester/definition/fields/object_field.rb
api-tester-0.2.0 lib/api-tester/definition/fields/object_field.rb