Sha256: 67cf2334d754997ac922c78b303cfc13a793b12422a0a15e4471400fcac09dc9
Contents?: true
Size: 1.67 KB
Versions: 1
Compression:
Stored size: 1.67 KB
Contents
require 'spec_helper' describe 'validate_presence_of' do context "without message" do context '#should' do it 'passes if validation exists' do lambda{ expect(Person).to validate_presence_of :last_name}.should_pass end it 'fails if validation does not exist' do expect{ expect(Person).to validate_presence_of :age}. to fail_with "expected to validate presence of age" end end context '#should_not' do it 'fails if validation exists' do expect{ expect(Person).not_to validate_presence_of :last_name}. to fail_with "expected to not validate presence of last_name" end end end context 'with message' do context '#should' do it 'passes if messages are the same' do lambda{ expect(Person).to validate_presence_of(:first_name). with_message('Where is the first name?') }.should_pass end it 'fails if messages are different' do expect{ expect(Person).to validate_presence_of(:first_name). with_message('Different message') }.to fail_with 'expected to validate presence of first_name with message "Different message"' end end context '#should_not' do it 'fails if validation message exists' do expect{ expect(Person).not_to validate_presence_of(:first_name). with_message('Where is the first name?') }.to fail_with 'expected to not validate presence of first_name with message "Where is the first name?"' end end end context 'instance of model' do it "should pass" do lambda{ expect(Person.new).to validate_presence_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_presence_of_spec.rb |