Skip to content

Commit

Permalink
Fixed bad failure messages for validate_uniqueness_of [thoughtbot#152
Browse files Browse the repository at this point in the history
…state:resolved]
  • Loading branch information
Gavin Stark authored and jferris committed Feb 10, 2009
1 parent dfc0af0 commit 1ce9339
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 1ce9339

Please sign in to comment.