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
apl-library-0.0.90 vendor/bundle/ruby/1.9.1/gems/shoulda-2.11.3/test/matchers/active_record/validate_acceptance_of_matcher_test.rb
apl-library-0.0.90 vendor/bundle/ruby/2.1.0/gems/apl-library-0.0.90/vendor/bundle/ruby/1.9.1/gems/shoulda-2.11.3/test/matchers/active_record/validate_acceptance_of_matcher_test.rb
apl-library-0.0.90 vendor/bundle/ruby/2.1.0/gems/apl-library-0.0.90/vendor/bundle/ruby/2.1.0/gems/shoulda-2.11.3/test/matchers/active_record/validate_acceptance_of_matcher_test.rb
apl-library-0.0.90 vendor/bundle/ruby/2.1.0/gems/shoulda-2.11.3/test/matchers/active_record/validate_acceptance_of_matcher_test.rb
dirty_history-0.7.3 dirty_history/ruby/1.9.1/gems/shoulda-2.11.3/test/matchers/active_record/validate_acceptance_of_matcher_test.rb
dirty_history-0.7.2 dirty_history/ruby/1.9.1/gems/shoulda-2.11.3/test/matchers/active_record/validate_acceptance_of_matcher_test.rb
dirty_history-0.7.1 dirty_history/ruby/1.9.1/gems/shoulda-2.11.3/test/matchers/active_record/validate_acceptance_of_matcher_test.rb
dirty_history-0.7.0 dirty_history/ruby/1.9.1/gems/shoulda-2.11.3/test/matchers/active_record/validate_acceptance_of_matcher_test.rb
dirty_history-0.6.7 dirty_history/ruby/1.9.1/gems/shoulda-2.11.3/test/matchers/active_record/validate_acceptance_of_matcher_test.rb
dirty_history-0.6.6 dirty_history/ruby/1.9.1/gems/shoulda-2.11.3/test/matchers/active_record/validate_acceptance_of_matcher_test.rb
dirty_history-0.6.5 dirty_history/ruby/1.9.1/gems/shoulda-2.11.3/test/matchers/active_record/validate_acceptance_of_matcher_test.rb
dirty_history-0.6.4 dirty_history/ruby/1.9.1/gems/shoulda-2.11.3/test/matchers/active_record/validate_acceptance_of_matcher_test.rb
dirty_history-0.6.3 dirty_history/ruby/1.9.1/gems/shoulda-2.11.3/test/matchers/active_record/validate_acceptance_of_matcher_test.rb
challah-0.6.2 vendor/bundle/gems/shoulda-2.11.3/test/matchers/active_record/validate_acceptance_of_matcher_test.rb
dirty_history-0.6.2 dirty_history/ruby/1.9.1/gems/shoulda-2.11.3/test/matchers/active_record/validate_acceptance_of_matcher_test.rb
dirty_history-0.6.1 dirty_history/ruby/1.9.1/gems/shoulda-2.11.3/test/matchers/active_record/validate_acceptance_of_matcher_test.rb
dirty_history-0.6.0 dirty_history/ruby/1.9.1/gems/shoulda-2.11.3/test/matchers/active_record/validate_acceptance_of_matcher_test.rb
challah-0.6.1 vendor/bundle/gems/shoulda-2.11.3/test/matchers/active_record/validate_acceptance_of_matcher_test.rb
dirty_history-0.5.4 dirty_history/ruby/1.9.1/gems/shoulda-2.11.3/test/matchers/active_record/validate_acceptance_of_matcher_test.rb
challah-0.6.0 vendor/bundle/gems/shoulda-2.11.3/test/matchers/active_record/validate_acceptance_of_matcher_test.rb