Sha256: a11765c6061f37ed161c240102392cca9152f05efccb54965204b119ab19b810

Contents?: true

Size: 1.38 KB

Versions: 28

Compression:

Stored size: 1.38 KB

Contents

require 'spec_helper'

describe Shoulda::Matchers::ActiveModel::ValidateConfirmationOfMatcher do

  context "an attribute which needs confirmation" do
    before do
      define_model(:example, :attr => :string) do
        validates_confirmation_of :attr
      end
      @model = Example.new
    end

    it "should require confirmation of that attribute" do
      @model.should validate_confirmation_of(:attr)
    end

    it "should not override the default message with a blank" do
      @model.should validate_confirmation_of(:attr).with_message(nil)
    end
  end

  context "an attribute which must be confirmed with a custom message" do
    before do
      define_model :example, :attr => :string do
        validates_confirmation_of :attr, :message => 'custom'
      end
      @model = Example.new
    end

    it "should require confirmation of that attribute with that message" do
      @model.should validate_confirmation_of(:attr).with_message(/custom/)
    end

    it "should not require confirmation of that attribute with another message" do
      @model.should_not validate_confirmation_of(:attr)
    end
  end

  context "an attribute which doesn't need confirmation" do
    before do
      @model = define_model(:example, :attr => :string).new
    end

    it "should not require confirmation of that attribute" do
      @model.should_not validate_confirmation_of(:attr)
    end
  end
end

Version data entries

28 entries across 20 versions & 4 rubygems

Version Path
challah-1.0.0.beta vendor/bundle/gems/shoulda-matchers-1.4.2/spec/shoulda/active_model/validate_confirmation_of_matcher_spec.rb
challah-0.9.1.beta.3 vendor/bundle/gems/shoulda-matchers-1.4.2/spec/shoulda/active_model/validate_confirmation_of_matcher_spec.rb
devise_sociable-0.1.0 vendor/bundle/gems/shoulda-matchers-1.4.2/spec/shoulda/active_model/validate_confirmation_of_matcher_spec.rb
challah-0.9.1.beta vendor/bundle/gems/shoulda-matchers-1.4.2/spec/shoulda/active_model/validate_confirmation_of_matcher_spec.rb
challah-0.9.0 vendor/bundle/gems/shoulda-matchers-1.4.2/spec/shoulda/active_model/validate_confirmation_of_matcher_spec.rb
shoulda-matchers-1.4.2 spec/shoulda/active_model/validate_confirmation_of_matcher_spec.rb
challah-rolls-0.2.0 vendor/bundle/gems/shoulda-matchers-1.4.1/spec/shoulda/active_model/validate_confirmation_of_matcher_spec.rb
challah-rolls-0.2.0 vendor/bundle/gems/shoulda-matchers-1.3.0/spec/shoulda/active_model/validate_confirmation_of_matcher_spec.rb
challah-rolls-0.2.0 vendor/bundle/gems/shoulda-matchers-1.2.0/spec/shoulda/active_model/validate_confirmation_of_matcher_spec.rb
challah-rolls-0.2.0 vendor/bundle/gems/challah-0.8.3/vendor/bundle/gems/shoulda-matchers-1.4.1/spec/shoulda/active_model/validate_confirmation_of_matcher_spec.rb
challah-rolls-0.2.0 vendor/bundle/gems/challah-0.8.0.pre/vendor/bundle/gems/shoulda-matchers-1.2.0/spec/shoulda/active_model/validate_confirmation_of_matcher_spec.rb
challah-rolls-0.2.0 vendor/bundle/gems/challah-0.8.3/vendor/bundle/gems/shoulda-matchers-1.3.0/spec/shoulda/active_model/validate_confirmation_of_matcher_spec.rb
challah-0.8.3 vendor/bundle/gems/shoulda-matchers-1.3.0/spec/shoulda/active_model/validate_confirmation_of_matcher_spec.rb
challah-0.8.3 vendor/bundle/gems/shoulda-matchers-1.4.1/spec/shoulda/active_model/validate_confirmation_of_matcher_spec.rb
shoulda-matchers-1.4.1 spec/shoulda/active_model/validate_confirmation_of_matcher_spec.rb
shoulda-matchers-1.4.0 spec/shoulda/active_model/validate_confirmation_of_matcher_spec.rb
challah-0.8.1 vendor/bundle/gems/shoulda-matchers-1.3.0/spec/shoulda/active_model/validate_confirmation_of_matcher_spec.rb
challah-rolls-0.1.0 vendor/bundle/gems/challah-0.8.0.pre/vendor/bundle/gems/shoulda-matchers-1.2.0/spec/shoulda/active_model/validate_confirmation_of_matcher_spec.rb
challah-rolls-0.1.0 vendor/bundle/gems/shoulda-matchers-1.2.0/spec/shoulda/active_model/validate_confirmation_of_matcher_spec.rb
challah-rolls-0.1.0 vendor/bundle/gems/shoulda-matchers-1.3.0/spec/shoulda/active_model/validate_confirmation_of_matcher_spec.rb