Permalink
Browse files

Fixed bad failure messages for validate_uniqueness_of [#152 state:res…

…olved]
  • Loading branch information...
1 parent dfc0af0 commit 1ce9339d9c452d39c60eb2fd04156104e6e133e4 Gavin Stark committed with jferris Feb 10, 2009
@@ -77,9 +77,9 @@ def matches?(subject)
def find_existing
if @existing = @subject.class.find(:first)
- @failure_message = "Can't find first #{class_name}"
true
else
+ @failure_message = "Can't find first #{class_name}"
false
end
end
@@ -31,10 +31,16 @@ class ValidateUniquenessOfMatcherTest < Test::Unit::TestCase # :nodoc:
context "without an existing value" do
setup do
assert_nil Example.find(:first)
+ @matcher = validate_uniqueness_of(:attr)
end
should "fail to require a unique value" do
- assert_rejects validate_uniqueness_of(:attr), @model
+ assert_rejects @matcher, @model
+ end
+
+ should "alert the tester that an existing value is not present" do
+ @matcher.matches?(@model)
+ assert @matcher.negative_failure_message =~ /^Can't find first .*/
end
end
end

0 comments on commit 1ce9339

Please sign in to comment.