Sha256: 2f62e1409755600937fad3056108af0f2281390bbdea17cffb7c370c5d53bc13

Contents?: true

Size: 1.71 KB

Versions: 13

Compression:

Stored size: 1.71 KB

Contents

require 'forwardable'

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

        def_delegators(
          :allow_matcher,
          :_after_setting_value,
          :attribute_changed_value_message=,
          :attribute_to_set,
          :description,
          :expects_strict?,
          :failure_message_preface,
          :failure_message_preface=,
          :ignore_interference_by_writer,
          :last_attribute_setter_used,
          :last_value_set,
          :model,
          :simple_description,
          :values_to_preset=,
        )

        def initialize(value)
          @allow_matcher = AllowValueMatcher.new(value)
        end

        def matches?(subject)
          allow_matcher.does_not_match?(subject)
        end

        def does_not_match?(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 strict(strict = true)
          allow_matcher.strict(strict)
          self
        end

        def ignoring_interference_by_writer(value = :always)
          allow_matcher.ignoring_interference_by_writer(value)
          self
        end

        def failure_message
          allow_matcher.failure_message_when_negated
        end

        def failure_message_when_negated
          allow_matcher.failure_message
        end

        protected

        attr_reader :allow_matcher
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
shoulda-matchers-6.4.0 lib/shoulda/matchers/active_model/disallow_value_matcher.rb
shoulda-matchers-6.3.1 lib/shoulda/matchers/active_model/disallow_value_matcher.rb
shoulda-matchers-6.3.0 lib/shoulda/matchers/active_model/disallow_value_matcher.rb
shoulda-matchers-6.2.0 lib/shoulda/matchers/active_model/disallow_value_matcher.rb
shoulda-matchers-6.1.0 lib/shoulda/matchers/active_model/disallow_value_matcher.rb
shoulda-matchers-6.0.0 lib/shoulda/matchers/active_model/disallow_value_matcher.rb
shoulda-matchers-5.3.0 lib/shoulda/matchers/active_model/disallow_value_matcher.rb
shoulda-matchers-5.2.0 lib/shoulda/matchers/active_model/disallow_value_matcher.rb
shoulda-matchers-5.1.0 lib/shoulda/matchers/active_model/disallow_value_matcher.rb
shoulda-matchers-5.0.0 lib/shoulda/matchers/active_model/disallow_value_matcher.rb
shoulda-matchers-5.0.0.rc1 lib/shoulda/matchers/active_model/disallow_value_matcher.rb
shoulda-matchers-4.5.1 lib/shoulda/matchers/active_model/disallow_value_matcher.rb
shoulda-matchers-4.5.0 lib/shoulda/matchers/active_model/disallow_value_matcher.rb