Sha256: 30318e242146f2088f092b5c74e1b227d94d3d77486a4cd92fb40b16b9cdde55

Contents?: true

Size: 1.56 KB

Versions: 2

Compression:

Stored size: 1.56 KB

Contents

require 'spec_helper'

describe 'validate_format_of' do

  context 'without message' do
    context '#should 'do
      it 'passes if validatation exists' do
        lambda { Tag.should validate_format_of(:name).with(/\w+/) }.should_pass
      end

      it 'fails if validation does not exist' do
        lambda { Tag.should validate_format_of(:id).with(/\w+/) }.
          should fail_with 'expected to validate format of id with /\w+/'
      end
    end

    context '#should_not' do
      it 'fails if validation exists' do
        lambda { Tag.should_not validate_format_of(:name).with(/\w+/) }.
          should 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{ Genre.should validate_format_of(:name).with(/\w+/).
          with_message('Bad format of genre')
        }.should_pass
      end

      it 'fails if messages are different' do
        lambda{ Genre.should validate_format_of(:name).with(/\w+/).
          with_message('Different message')
        }.should 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
        lambda{ Genre.should_not validate_format_of(:name).with(/\w+/).
          with_message('Bad format of genre')
        }.should fail_with 'expected to not validate format of name with /\w+/ and message "Bad format of genre"'
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
dm-rspec-0.1.2 spec/dm/matchers/validate_format_of_spec.rb
dm-rspec-0.1.1 spec/dm/matchers/validate_format_of_spec.rb