Sha256: b7e1041fc8487af16ca9899f6061b298486609f2164b32349d58a674f4fc5038

Contents?: true

Size: 1.17 KB

Versions: 7

Compression:

Stored size: 1.17 KB

Contents

require 'forwardable'

module Shoulda
  module Matchers
    module ActiveModel
      # @private
      class DisallowValueMatcher
        extend Forwardable

        def_delegators :allow_matcher, :_after_setting_value
        def initialize(value)
          @allow_matcher = AllowValueMatcher.new(value)
        end

        def matches?(subject)
          !@allow_matcher.matches?(subject)
        end

        def for(attribute)
          @allow_matcher.for(attribute)
          self
        end

        def on(context)
          @allow_matcher.on(context)
          self
        end

        def with_message(message, options={})
          @allow_matcher.with_message(message, options)
          self
        end

        def failure_message
          @allow_matcher.failure_message_when_negated
        end
        alias failure_message_for_should failure_message

        def failure_message_when_negated
          @allow_matcher.failure_message
        end
        alias failure_message_for_should_not failure_message_when_negated

        def strict
          @allow_matcher.strict
          self
        end

        protected

        attr_reader :allow_matcher
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
ish_lib_manager-0.0.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/shoulda-matchers-2.8.0/lib/shoulda/matchers/active_model/disallow_value_matcher.rb
shoulda-matchers-3.0.0.rc1 lib/shoulda/matchers/active_model/disallow_value_matcher.rb
shoulda-matchers-2.8.0 lib/shoulda/matchers/active_model/disallow_value_matcher.rb
shoulda-matchers-2.8.0.rc2 lib/shoulda/matchers/active_model/disallow_value_matcher.rb
shoulda-matchers-2.8.0.rc1 lib/shoulda/matchers/active_model/disallow_value_matcher.rb
shoulda-matchers-2.7.0 lib/shoulda/matchers/active_model/disallow_value_matcher.rb
shoulda-matchers-2.6.2 lib/shoulda/matchers/active_model/disallow_value_matcher.rb