Sha256: 9a9eb8600379d123bee46a70bc7855f444667bdbfcd1f4ad94dcd860840be804
Contents?: true
Size: 1.7 KB
Versions: 1
Compression:
Stored size: 1.7 KB
Contents
require 'spec_helper' describe 'validate_uniqueness_of' do context 'without message' do context '#should 'do it 'passes if validatation exists' do lambda { expect(Author).to validate_uniqueness_of :last_name}.should_pass end it 'fails if validation does not exist' do expect { expect(Author).to validate_uniqueness_of :first_name}. to fail_with "expected to validate uniqueness of first_name" end end context '#should_not' do it 'fails if validation exists' do expect { expect(Author).not_to validate_uniqueness_of :last_name}. to fail_with "expected to not validate uniqueness of last_name" end end end context 'with message' do context '#should' do it 'passes if messages are the same' do lambda{ expect(Genre).to validate_uniqueness_of(:name). with_message('Genre name must be unique!') }.should_pass end it 'fails if messages are different' do expect{ expect(Genre).to validate_uniqueness_of(:name). with_message('Different message') }.to fail_with 'expected to validate uniqueness of name with message "Different message"' end end context '#should_not' do it 'fails if validation message exists and it is the same' do expect{ expect(Genre).not_to validate_uniqueness_of(:name). with_message('Genre name must be unique!') }.to fail_with 'expected to not validate uniqueness of name with message "Genre name must be unique!"' end end end context 'instance of model' do it "should pass" do lambda { expect(Author.new).to validate_uniqueness_of :last_name}.should_pass end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
dm-rspec-0.3.0 | spec/dm/matchers/validate_uniquness_of_spec.rb |