class Shoulda::ActiveRecord::Matchers::ValidateUniquenessOfMatcher
def validate_after_scope_change
to a value that's already taken. An alternative implementation
TODO: There is a chance that we could change the scoped field
def validate_after_scope_change if @scopes.blank? true else @scopes.all? do |scope| previous_value = @existing.send(scope) # Assume the scope is a foreign key if the field is nil previous_value ||= 0 next_value = previous_value.next @subject.send("#{scope}=", next_value) 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