Sha256: 2898dbd202c4feb6af74cf6f88b37e4ae84552fc71a0d113c9113608ab308ad4

Contents?: true

Size: 1.04 KB

Versions: 3

Compression:

Stored size: 1.04 KB

Contents

require File.expand_path(File.dirname(__FILE__) + '/spec_helper')

module WhosGotDirt
  RSpec.describe Validator do
    let :invalid do
      {
        'name' => 'John Smith',
        'birth_date' => 2015,
        'identifiers' => [{
          'scheme' => 'ACME',
        }, {
          'identifier' => 'john-smith',
        }, {
          'scheme' => 'ACME',
        }],
      }
    end

    let :valid do
      {
        'name' => 'John Smith',
        'birth_date' => '2015',
        'identifiers' => [{
          'identifier' => 'john-smith',
        }],
      }
    end

    describe '.validate' do
      it 'should return errors for invalid data' do
        expect(Validator.validate(invalid, 'entity').map{|error| [error[:fragment], error[:failed_attribute]]}).to eq([
          ['#/birth_date', 'Type'],
          ['#/identifiers/0', 'Properties'],
          ['#/identifiers/2', 'Properties'],
        ])
      end

      it 'should not return errors for valid data' do
        expect(Validator.validate(valid, 'entity')).to eq([])
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
whos_got_dirt-0.0.5 spec/validator_spec.rb
whos_got_dirt-0.0.4 spec/validator_spec.rb
whos_got_dirt-0.0.3 spec/validator_spec.rb