/usr/lib/ruby/vendor_ruby/shoulda/matchers/active_record/validation_matcher.rb is in ruby-shoulda-matchers 1.0.0~beta2-1build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | module Shoulda # :nodoc:
module Matchers
module ActiveRecord # :nodoc:
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
|