Sha256: dd2fffe9fc7c2de01962af093eec808c47471fd0bc14003e0494d14206b27d29

Contents?: true

Size: 1.18 KB

Versions: 28

Compression:

Stored size: 1.18 KB

Contents

require 'spec_helper'

describe Shoulda::Matchers::ActiveModel::ValidateAcceptanceOfMatcher do

  context "an attribute which must be accepted" do
    before do
      @model = define_model(:example, :attr => :string) do
        validates_acceptance_of :attr
      end.new
    end

    it "should require that attribute to be accepted" do
      @model.should validate_acceptance_of(:attr)
    end

    it "should not overwrite the default message with nil" do
      @model.should validate_acceptance_of(:attr).with_message(nil)
    end
  end

  context "an attribute that does not need to be accepted" do
    before do
      @model = define_model(:example, :attr => :string).new
    end

    it "should not require that attribute to be accepted" do
      @model.should_not validate_acceptance_of(:attr)
    end
  end

  context "an attribute which must be accepted with a custom message" do
    before do
      @model = define_model(:example, :attr => :string) do
        validates_acceptance_of :attr, :message => 'custom'
      end.new
    end

    it "should require that attribute to be accepted with that message" do
      @model.should validate_acceptance_of(:attr).with_message(/custom/)
    end
  end

end

Version data entries

28 entries across 20 versions & 4 rubygems

Version Path
challah-0.8.0.pre vendor/bundle/gems/shoulda-matchers-1.2.0/spec/shoulda/active_model/validate_acceptance_of_matcher_spec.rb
shoulda-matchers-1.3.0 spec/shoulda/active_model/validate_acceptance_of_matcher_spec.rb
challah-0.7.1 vendor/bundle/gems/shoulda-matchers-1.2.0/spec/shoulda/active_model/validate_acceptance_of_matcher_spec.rb
challah-0.7.0 vendor/bundle/gems/shoulda-matchers-1.2.0/spec/shoulda/active_model/validate_acceptance_of_matcher_spec.rb
challah-0.7.0.pre2 vendor/bundle/gems/shoulda-matchers-1.2.0/spec/shoulda/active_model/validate_acceptance_of_matcher_spec.rb
challah-0.7.0.pre vendor/bundle/gems/shoulda-matchers-1.2.0/spec/shoulda/active_model/validate_acceptance_of_matcher_spec.rb
shoulda-matchers-1.2.0 spec/shoulda/active_model/validate_acceptance_of_matcher_spec.rb
shoulda-matchers-1.1.0 spec/shoulda/active_model/validate_acceptance_of_matcher_spec.rb