Sha256: 2e149c98245dbc4c2b2dd4794601c240c8b6515a3ad3f254a9e49de61230e3bc

Contents?: true

Size: 1.02 KB

Versions: 4

Compression:

Stored size: 1.02 KB

Contents

require 'spec_helper'

describe HashValidator::Validator::Base do
  let(:validator)  { HashValidator::Validator::MultipleValidator.new }
  let(:errors)     { Hash.new }

  def multiple(*validations)
    HashValidator::Validations::Multiple.new(validations)
  end

  describe '#should_validate?' do
    it 'should validate an Multiple validation' do
      expect(validator.should_validate?(multiple('numeric', 1..10))).to eq true
    end

    it 'should not validate other things' do
      expect(validator.should_validate?('string')).to eq false
      expect(validator.should_validate?('array')).to eq false
      expect(validator.should_validate?(nil)).to eq false
    end
  end

  describe '#validate' do
    it 'should accept an empty collection of validators' do
      validator.validate(:key, 73, multiple(), errors)

      expect(errors).to be_empty
    end

    it 'should accept an collection of validators' do
      validator.validate(:key, 73, multiple('numeric', 1..100), errors)

      expect(errors).to be_empty
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
hash_validator-1.1.1 spec/validators/multiple_spec.rb
hash_validator-1.1.0 spec/validators/multiple_spec.rb
hash_validator-1.0.0 spec/validators/multiple_spec.rb
hash_validator-0.8.0 spec/validators/multiple_spec.rb