Sha256: eabb6101c9cae21461ce52bedf04152b7c369891e7de31741952a4d49bb974f8

Contents?: true

Size: 665 Bytes

Versions: 15

Compression:

Stored size: 665 Bytes

Contents

require 'spec_helper'

include Restspec::Schema::Types

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

  describe '#valid?' do
    it 'only allows strings' do
      expect(type.valid?(attribute, true)).to eq(false)
      expect(type.valid?(attribute, false)).to eq(false)
      expect(type.valid?(attribute, 1)).to eq(false)
      expect(type.valid?(attribute, 1.5)).to eq(false)
      expect(type.valid?(attribute, 'string')).to eq(true)
    end
  end

  describe '#example_for' do
    it 'generates a string' do
      10.times.map {
        expect(type.example_for(attribute)).to be_kind_of(String)
      }
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

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