Sha256: 6b44505581a1922def6734bb3c5ac9b2c3bd590b3bbd707f248dad80e98a1b52

Contents?: true

Size: 1.19 KB

Versions: 91

Compression:

Stored size: 1.19 KB

Contents

require 'test_helper'

class ValidateAcceptanceOfMatcherTest < ActiveSupport::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

91 entries across 61 versions & 10 rubygems

Version Path
faster_shoulda-2.11.3 test/matchers/active_record/validate_acceptance_of_matcher_test.rb
dirty_history-0.1.3 dirty_history/ruby/1.9.1/gems/shoulda-2.11.3/test/matchers/active_record/validate_acceptance_of_matcher_test.rb
nimboids-shoulda-2.11.4 test/matchers/active_record/validate_acceptance_of_matcher_test.rb
putio-0.0.1.pre2 development/ruby/1.8/gems/shoulda-2.11.3/test/matchers/active_record/validate_acceptance_of_matcher_test.rb
putio-0.0.1.pre development/ruby/1.8/gems/shoulda-2.11.3/test/matchers/active_record/validate_acceptance_of_matcher_test.rb
nimboids-shoulda-2.11.3 test/matchers/active_record/validate_acceptance_of_matcher_test.rb
shoulda-2.11.3 test/matchers/active_record/validate_acceptance_of_matcher_test.rb
shoulda-2.11.2 test/matchers/active_record/validate_acceptance_of_matcher_test.rb
thoughtbot-shoulda-2.11.1 test/matchers/active_record/validate_acceptance_of_matcher_test.rb
shoulda-2.11.1 test/matchers/active_record/validate_acceptance_of_matcher_test.rb
shoulda-2.11.0 test/matchers/active_record/validate_acceptance_of_matcher_test.rb