Sha256: 31e67941564e1cd379933198c824659cb5d8dec03302b94d7a8314e75594564a

Contents?: true

Size: 1.17 KB

Versions: 2

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 ignoring_interference_by_writer
          @allow_matcher.ignoring_interference_by_writer
          self
        end

        def failure_message
          @allow_matcher.failure_message_when_negated
        end

        def failure_message_when_negated
          @allow_matcher.failure_message
        end

        def strict
          @allow_matcher.strict
          self
        end

        protected

        attr_reader :allow_matcher
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
shoulda-matchers-3.0.1 lib/shoulda/matchers/active_model/disallow_value_matcher.rb
shoulda-matchers-3.0.0 lib/shoulda/matchers/active_model/disallow_value_matcher.rb