Sha256: ac5b634cc57830fa3e658a87471570b3f4aa7ce88aa092d6bc70ecb1a2318861

Contents?: true

Size: 1.23 KB

Versions: 10

Compression:

Stored size: 1.23 KB

Contents

require File.join(File.dirname(__FILE__), '..', '..', 'test_helper')

class ValidateAcceptanceOfMatcherTest < Test::Unit::TestCase # :nodoc:

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

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

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

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

    should "not require that attribute to be accepted" do
      assert_rejects validate_acceptance_of(:attr), @model
    end
  end

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

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

end

Version data entries

10 entries across 10 versions & 5 rubygems

Version Path
Flamefork-shoulda-2.10.1 test/matchers/active_record/validate_acceptance_of_matcher_test.rb
Flamefork-shoulda-2.10.2 test/matchers/active_record/validate_acceptance_of_matcher_test.rb
francois-shoulda-2.10.1 test/matchers/active_record/validate_acceptance_of_matcher_test.rb
technicalpickles-shoulda-2.10.0 test/matchers/active_record/validate_acceptance_of_matcher_test.rb
thoughtbot-shoulda-2.10.0 test/matchers/active_record/validate_acceptance_of_matcher_test.rb
thoughtbot-shoulda-2.10.1 test/matchers/active_record/validate_acceptance_of_matcher_test.rb
thoughtbot-shoulda-2.9.2 test/matchers/active_record/validate_acceptance_of_matcher_test.rb
shoulda-2.9.2 test/matchers/active_record/validate_acceptance_of_matcher_test.rb
shoulda-2.10.0 test/matchers/active_record/validate_acceptance_of_matcher_test.rb
shoulda-2.10.1 test/matchers/active_record/validate_acceptance_of_matcher_test.rb