Sha256: 69cd69650278050511f2dac25f8bf55d79b2a2d143402ddaf57d5527de9b43ce

Contents?: true

Size: 763 Bytes

Versions: 15

Compression:

Stored size: 763 Bytes

Contents

require 'spec_helper'

include Restspec::Schema::Types

describe BooleanType do
  let(:type) { BooleanType.new }
  let(:attribute) { double }

  describe '#example_for' do
    it 'returns true or false' do
      expect([true, false]).to include(type.example_for(attribute))
    end
  end

  describe '#valid?' do
    it 'only validates boolean values' do
      expect(type.valid?(attribute, true)).to eq(true)
      expect(type.valid?(attribute, false)).to eq(true)
      expect(type.valid?(attribute, 'true')).to eq(false)
      expect(type.valid?(attribute, '1')).to eq(false)
      expect(type.valid?(attribute, 'on')).to eq(false)
      expect(type.valid?(attribute, 'yes')).to eq(false)
      expect(type.valid?(attribute, 1)).to eq(false)
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
restspec-0.3.2 spec/restspec/schema/types/boolean_type_spec.rb
restspec-0.3.1 spec/restspec/schema/types/boolean_type_spec.rb
restspec-0.3.0 spec/restspec/schema/types/boolean_type_spec.rb
restspec-0.2.6 spec/restspec/schema/types/boolean_type_spec.rb
restspec-0.2.5 spec/restspec/schema/types/boolean_type_spec.rb
restspec-0.2.4 spec/restspec/schema/types/boolean_type_spec.rb
restspec-0.2.3 spec/restspec/schema/types/boolean_type_spec.rb
restspec-0.2.2 spec/restspec/schema/types/boolean_type_spec.rb
restspec-0.2.1 spec/restspec/schema/types/boolean_type_spec.rb
restspec-0.2 spec/restspec/schema/types/boolean_type_spec.rb
restspec-0.1 spec/restspec/schema/types/boolean_type_spec.rb
restspec-0.0.4 spec/restspec/schema/types/boolean_type_spec.rb
restspec-0.0.3 spec/restspec/schema/types/boolean_type_spec.rb
restspec-0.0.2 spec/restspec/schema/types/boolean_type_spec.rb
restspec-0.0.1 spec/restspec/schema/types/boolean_type_spec.rb