Sha256: 13213afaf521016e67c63f2b87d792cf32cb4d99b3dae87cf46ae80677b86d58

Contents?: true

Size: 1.29 KB

Versions: 114

Compression:

Stored size: 1.29 KB

Contents

module Shoulda # :nodoc:
  module ActiveRecord # :nodoc:
    module Matchers

      class ValidationMatcher # :nodoc:

        attr_reader :failure_message

        def initialize(attribute)
          @attribute = attribute
        end

        def negative_failure_message
          @negative_failure_message || @failure_message
        end

        def matches?(subject)
          @subject = subject
          false
        end

        private

        def allows_value_of(value, message = nil)
          allow = AllowValueMatcher.
            new(value).
            for(@attribute).
            with_message(message)
          if allow.matches?(@subject)
            @negative_failure_message = allow.failure_message
            true
          else
            @failure_message = allow.negative_failure_message
            false
          end
        end

        def disallows_value_of(value, message = nil)
          disallow = AllowValueMatcher.
            new(value).
            for(@attribute).
            with_message(message)
          if disallow.matches?(@subject)
            @failure_message = disallow.negative_failure_message
            false
          else
            @negative_failure_message = disallow.failure_message
            true
          end
        end
      end

    end
  end
end

Version data entries

114 entries across 84 versions & 17 rubygems

Version Path
dirty_history-0.4.4 dirty_history/ruby/1.9.1/gems/shoulda-2.11.3/lib/shoulda/active_record/matchers/validation_matcher.rb
dirty_history-0.4.4 dirty_history/ruby/1.9.1/gems/dirty_history-0.2.0/dirty_history/ruby/1.9.1/gems/dirty_history-0.2.0/dirty_history/ruby/1.9.1/gems/shoulda-2.11.3/lib/shoulda/active_record/matchers/validation_matcher.rb
dirty_history-0.4.4 dirty_history/ruby/1.9.1/gems/dirty_history-0.2.0/dirty_history/ruby/1.9.1/gems/shoulda-2.11.3/lib/shoulda/active_record/matchers/validation_matcher.rb
dirty_history-0.4.3 dirty_history/ruby/1.9.1/gems/shoulda-2.11.3/lib/shoulda/active_record/matchers/validation_matcher.rb
dirty_history-0.4.3 dirty_history/ruby/1.9.1/gems/dirty_history-0.2.0/dirty_history/ruby/1.9.1/gems/dirty_history-0.2.0/dirty_history/ruby/1.9.1/gems/shoulda-2.11.3/lib/shoulda/active_record/matchers/validation_matcher.rb
dirty_history-0.4.3 dirty_history/ruby/1.9.1/gems/dirty_history-0.2.0/dirty_history/ruby/1.9.1/gems/shoulda-2.11.3/lib/shoulda/active_record/matchers/validation_matcher.rb
dirty_history-0.4.2 dirty_history/ruby/1.9.1/gems/shoulda-2.11.3/lib/shoulda/active_record/matchers/validation_matcher.rb
dirty_history-0.4.2 dirty_history/ruby/1.9.1/gems/dirty_history-0.2.0/dirty_history/ruby/1.9.1/gems/dirty_history-0.2.0/dirty_history/ruby/1.9.1/gems/shoulda-2.11.3/lib/shoulda/active_record/matchers/validation_matcher.rb
dirty_history-0.4.2 dirty_history/ruby/1.9.1/gems/dirty_history-0.2.0/dirty_history/ruby/1.9.1/gems/shoulda-2.11.3/lib/shoulda/active_record/matchers/validation_matcher.rb
dirty_history-0.3.0 dirty_history/ruby/1.9.1/gems/shoulda-2.11.3/lib/shoulda/active_record/matchers/validation_matcher.rb
dirty_history-0.3.0 dirty_history/ruby/1.9.1/gems/dirty_history-0.2.0/dirty_history/ruby/1.9.1/gems/shoulda-2.11.3/lib/shoulda/active_record/matchers/validation_matcher.rb
dirty_history-0.3.0 dirty_history/ruby/1.9.1/gems/dirty_history-0.2.0/dirty_history/ruby/1.9.1/gems/dirty_history-0.2.0/dirty_history/ruby/1.9.1/gems/shoulda-2.11.3/lib/shoulda/active_record/matchers/validation_matcher.rb
dirty_history-0.2.0 dirty_history/ruby/1.9.1/gems/shoulda-2.11.3/lib/shoulda/active_record/matchers/validation_matcher.rb
dirty_history-0.2.0 dirty_history/ruby/1.9.1/gems/dirty_history-0.2.0/dirty_history/ruby/1.9.1/gems/shoulda-2.11.3/lib/shoulda/active_record/matchers/validation_matcher.rb
vanity-1.7.1 vendor/ruby/1.9.1/gems/shoulda-2.11.3/lib/shoulda/active_record/matchers/validation_matcher.rb
faster_shoulda-2.11.3 lib/shoulda/active_record/matchers/validation_matcher.rb
dirty_history-0.1.3 dirty_history/ruby/1.9.1/gems/shoulda-2.11.3/lib/shoulda/active_record/matchers/validation_matcher.rb
nimboids-shoulda-2.11.4 lib/shoulda/active_record/matchers/validation_matcher.rb
putio-0.0.1.pre2 development/ruby/1.8/gems/shoulda-2.11.3/lib/shoulda/active_record/matchers/validation_matcher.rb
putio-0.0.1.pre development/ruby/1.8/gems/shoulda-2.11.3/lib/shoulda/active_record/matchers/validation_matcher.rb