Sha256: 88b9acdfce29edfb6fba556eb3a8e88634cf2cf6d3b13f359a81f1cc80b8656f

Contents?: true

Size: 910 Bytes

Versions: 13

Compression:

Stored size: 910 Bytes

Contents

require 'spec_helper'

include Restspec::Schema::Types

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

  describe '#example_for' do
    it 'returns a valid date' do
      expect(type.example_for(attribute).match(DateType::DATE_FORMAT)).to be_present
    end
  end

  describe '#valid?' do
    it 'validates dates in the ISO 8601 format' do
      expect(type.valid?(attribute, '2014-12-19')).to eq(true)
      expect(type.valid?(attribute, '2014/12/19')).to eq(false)
      expect(type.valid?(attribute, '2014-12-19 01:31:10')).to eq(false)
      expect(type.valid?(attribute, '20141219')).to eq(false)
      expect(type.valid?(attribute, '2014-19-12')).to eq(false)
      expect(type.valid?(attribute, '19-12-2014')).to eq(false)
      expect(type.valid?(attribute, '12-19-2014')).to eq(false)
      expect(type.valid?(attribute, '19/12/2014')).to eq(false)
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

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