Sha256: 071fc7677b8700755b2790cb211f80311e65d1f2dbd17ac9ad214d1508367c76

Contents?: true

Size: 569 Bytes

Versions: 11

Compression:

Stored size: 569 Bytes

Contents

require 'spec_helper'

include Restspec::Schema::Types

describe OneOfType do
  let(:type) { OneOfType.new(elements: [1, 2, 3]) }

  describe '#example_for' do
    it 'returns one example of the elements array' do
      expect([1, 2, 3]).to include(type.example_for(double))
    end
  end

  describe '#valid' do
    it 'checks if the value is one of the elements array' do
      expect(type.totally_valid?(double, 1)).to eq(true)
      expect(type.totally_valid?(double, nil)).to eq(false)
      expect(type.totally_valid?(double, '1')).to eq(false)
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
restspec-0.3.2 spec/restspec/schema/types/one_of_type_spec.rb
restspec-0.3.1 spec/restspec/schema/types/one_of_type_spec.rb
restspec-0.3.0 spec/restspec/schema/types/one_of_type_spec.rb
restspec-0.2.6 spec/restspec/schema/types/one_of_type_spec.rb
restspec-0.2.5 spec/restspec/schema/types/one_of_type_spec.rb
restspec-0.2.4 spec/restspec/schema/types/one_of_type_spec.rb
restspec-0.2.3 spec/restspec/schema/types/one_of_type_spec.rb
restspec-0.2.2 spec/restspec/schema/types/one_of_type_spec.rb
restspec-0.2.1 spec/restspec/schema/types/one_of_type_spec.rb
restspec-0.2 spec/restspec/schema/types/one_of_type_spec.rb
restspec-0.1 spec/restspec/schema/types/one_of_type_spec.rb