Skip to content
Browse files

Fixed failing matcher tests

  • Loading branch information...
1 parent ef6ffc9 commit 3c6fb6e0b306f5b06058fac35c1c60b4f4754102 @jferris jferris committed
Showing with 10 additions and 3 deletions.
  1. +1 −1 Rakefile
  2. +9 −2 lib/shoulda/active_record/matchers/require_unique_attribute_matcher.rb
View
2 Rakefile
@@ -8,7 +8,7 @@ require 'shoulda'
load 'tasks/shoulda.rake'
# Test::Unit::UI::VERBOSE
-test_files_pattern = 'test/{unit,functional,other}/**/*_test.rb'
+test_files_pattern = 'test/{unit,functional,other,matchers}/**/*_test.rb'
Rake::TestTask.new do |t|
t.libs << 'lib'
t.pattern = test_files_pattern
View
11 lib/shoulda/active_record/matchers/require_unique_attribute_matcher.rb
@@ -78,7 +78,7 @@ def validate_after_scope_change
if @scopes.blank?
true
else
- @scopes.each do |scope|
+ @scopes.all? do |scope|
previous_value = @existing.send(scope)
# Assume the scope is a foreign key if the field is nil
@@ -88,7 +88,14 @@ def validate_after_scope_change
@subject.send("#{scope}=", next_value)
- allows_value_of(existing_value, @expected_message)
+ if allows_value_of(existing_value, @expected_message)
+ @negative_failure_message <<
+ " (with different value of #{scope})"
+ true
+ else
+ @failure_message << " (with different value of #{scope})"
+ false
+ end
end
end
end

0 comments on commit 3c6fb6e

Please sign in to comment.
Something went wrong with that request. Please try again.