Sha256: 02a651d6deb8547cef922e7c2b2dd1f05071f3d11b6f68473c3b16fc12d12011

Contents?: true

Size: 784 Bytes

Versions: 11

Compression:

Stored size: 784 Bytes

Contents

require 'spec_helper'

include Restspec::Schema::Types

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

  describe '#example_for' do
    it 'returns a number' do
      10.times do
        expect(type.example_for(attribute)).to be_a_kind_of(Fixnum)
      end
    end
  end

  describe '#valid?' do
    it 'only validates integer values' do
      expect(type.valid?(attribute, 1)).to eq(true)
      expect(type.valid?(attribute, -10)).to eq(true)
      expect(type.valid?(attribute, -10.5)).to eq(false)
      expect(type.valid?(attribute, '10.5')).to eq(false)
      expect(type.valid?(attribute, '10')).to eq(false)
      expect(type.valid?(attribute, 'no')).to eq(false)
      expect(type.valid?(attribute, nil)).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/integer_type_spec.rb
restspec-0.3.1 spec/restspec/schema/types/integer_type_spec.rb
restspec-0.3.0 spec/restspec/schema/types/integer_type_spec.rb
restspec-0.2.6 spec/restspec/schema/types/integer_type_spec.rb
restspec-0.2.5 spec/restspec/schema/types/integer_type_spec.rb
restspec-0.2.4 spec/restspec/schema/types/integer_type_spec.rb
restspec-0.2.3 spec/restspec/schema/types/integer_type_spec.rb
restspec-0.2.2 spec/restspec/schema/types/integer_type_spec.rb
restspec-0.2.1 spec/restspec/schema/types/integer_type_spec.rb
restspec-0.2 spec/restspec/schema/types/integer_type_spec.rb
restspec-0.1 spec/restspec/schema/types/integer_type_spec.rb