Sha256: 1673a18874cce67de3146046013a550cea68b180ecf425eb19446dc1ef1deb0b

Contents?: true

Size: 1.02 KB

Versions: 1

Compression:

Stored size: 1.02 KB

Contents

# -*- coding: utf-8 -*-
require 'spec_helper'

shared_examples_for 'a validation error reader' do
  context 'and that property has no associated errors' do
    it 'should return an empty array' do
      @errors[@property].should == []
    end
  end
  context 'and that property has associated error(s)' do
    it 'should return a non empty array' do
      @errors.add(@property.to_sym, 'invalid')
      @errors[@property].should_not be_empty
    end
  end
end

describe 'DataMapper::Validations::ViolationSet' do
  describe '[]' do
    describe 'when passing the argument as a String' do
      before(:each) do
        @errors   = DataMapper::Validations::ViolationSet.new(Object.new)
        @property = 'name'
      end
      it_should_behave_like 'a validation error reader'
    end
    describe 'when passing the argument as a Symbol' do
      before(:each) do
        @errors   = DataMapper::Validations::ViolationSet.new(Object.new)
        @property = :name
      end
      it_should_behave_like 'a validation error reader'
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
aequitas-0.0.1 spec_legacy/unit/violation_set/reading_spec.rb