Sha256: 78179f693d70d45d5b1ea822d14c4a521b8e9541902fd47f28b22d3093ecaae7
Contents?: true
Size: 1.72 KB
Versions: 1
Compression:
Stored size: 1.72 KB
Contents
require 'spec_helper' describe 'validate_format_of' do context 'without message' do context '#should 'do it 'passes if validatation exists' do lambda { expect(Tag).to validate_format_of(:name).with(/\w+/) }.should_pass end it 'fails if validation does not exist' do expect { expect(Tag).to validate_format_of(:id).with(/\w+/) }. to fail_with 'expected to validate format of id with /\w+/' end end context '#should_not' do it 'fails if validation exists' do expect { expect(Tag).not_to validate_format_of(:name).with(/\w+/) }. to fail_with 'expected to not validate format of name with /\w+/' end end end context 'with message' do context '#should' do it 'passes if messages are the same' do lambda{ expect(Genre).to validate_format_of(:name).with(/\w+/). with_message('Bad format of genre') }.should_pass end it 'fails if messages are different' do expect{ expect(Genre).to validate_format_of(:name).with(/\w+/). with_message('Different message') }.to fail_with 'expected to validate format of name with /\w+/ and 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_format_of(:name).with(/\w+/). with_message('Bad format of genre') }.to fail_with 'expected to not validate format of name with /\w+/ and message "Bad format of genre"' end end end context 'instance of model' do it 'should pass' do lambda { expect(Tag.new).to validate_format_of(:name).with(/\w+/) }.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_format_of_spec.rb |