Permalink
Browse files

Use DisallowValueMatcher for `disallows_value_of` method

  • Loading branch information...
mxie committed Mar 27, 2013
1 parent 7e11f3e commit 058f39f1871dd1608cad89c38289ba01fc253bdd
View
@@ -1,4 +1,5 @@
# HEAD
+* Use DisallowValueMatcher for `disallows_value_of` method
* Assert `class_name` value on real class name for `AssociationMatcher`
* Correct the variable used for `validate_confirmation_of` matcher description
@@ -24,9 +24,18 @@ def failure_message_for_should
@allow_matcher.failure_message_for_should_not
end
+ def failure_message_for_should_not
+ @allow_matcher.failure_message_for_should
+ end
+
def allowed_types
''
end
+
+ def strict
+ @allow_matcher.strict
+ self
+ end
end
end
end
@@ -38,14 +38,14 @@ def allows_value_of(value, message = nil)
end
def disallows_value_of(value, message = nil)
- disallow = allow_value_matcher(value, message)
+ disallow = disallow_value_matcher(value, message)
if disallow.matches?(@subject)
- @failure_message_for_should = disallow.failure_message_for_should_not
- false
- else
@failure_message_for_should_not = disallow.failure_message_for_should
true
+ else
+ @failure_message_for_should = disallow.failure_message_for_should_not
+ false
end
end
@@ -62,6 +62,19 @@ def allow_value_matcher(value, message)
end
end
+ def disallow_value_matcher(value, message)
+ matcher = DisallowValueMatcher.
+ new(value).
+ for(@attribute).
+ with_message(message)
+
+ if strict?
+ matcher.strict
+ else
+ matcher
+ end
+ end
+
def strict?
@strict
end

0 comments on commit 058f39f

Please sign in to comment.