Sha256: ce11048dd7bd6a50ec72ca08bc412b9985910d6175351477f979429cdbe2cf15

Contents?: true

Size: 1.49 KB

Versions: 3

Compression:

Stored size: 1.49 KB

Contents

module DataModel
	# test fixtures for array type
	module Fixtures::Array
		extend self
		include Fixtures

		# a simple array of any types
		# @return [Example] the example
		def any_array
			Example.new(
				[:array],
				variants: {
					mixed: ["a", 2, [], ::Object.new]
				},
			)
		end

		# a simple array of strings example
		# @return [Example] the example
		def string_array
			Example.new(
				[:array, :string],
				variants: {
					strings: ["a", "b", "c"],
					string: ["a", ["a"]],
					number: [1, ["1"]],
					missing: nil,
					numbers: [[1, 2, 3], ["1", "2", "3"]],
					other_type: ::Object.new
				},
			)
		end

		# a simple array of strings that wraps single values
		# @return [Example] the example
		def wrapping_string_array
			Example.new(
				[:array, { wrap_single_value: true }, :string],
				variants: {
					strings: ["a", "b", "c"],
					string: ["a", ["a"]],
					number: [1, ["1"]],
					missing: nil,
					numbers: [[1, 2, 3], ["1", "2", "3"]],
					other_type: ::Object.new
				},
			)
		end

		# an optional example
		# @return [Example] the example
		def optional_string_array
			Example.new(
				[:array, { optional: true }, :string],
				variants: {
					strings: ["a", "b", "c"],
					missing: nil
				},
			)
		end

		# an array of optional strings
		# @return [Example] the example
		def array_optional_string
			Example.new(
				[:array, [:string, { optional: true }]],
				variants: {
					optional_strings: ["a", nil, "c"],
					numbers: [1, nil, 3]
				},
			)
		end
	end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
data_model-0.6.1 lib/data_model/fixtures/array.rb
data_model-0.6.0 lib/data_model/fixtures/array.rb
data_model-0.5.0 lib/data_model/fixtures/array.rb