aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCarlos Antonio da Silva <carlosantoniodasilva@gmail.com>2012-11-09 07:05:41 -0800
committerCarlos Antonio da Silva <carlosantoniodasilva@gmail.com>2012-11-09 07:05:41 -0800
commite56b8900f9b7704db8a01f5c54ee48f5935f406f (patch)
treeb7578af7e8b648f1ebfb2f1e3ec8ece7b5a2ae78
parent9622b3fd2cce642ca35f121395848887b9ff070f (diff)
parent88d59de12d9951c0ac18a1e53e52f92c00c15849 (diff)
downloadrails-e56b8900f9b7704db8a01f5c54ee48f5935f406f.tar.gz
rails-e56b8900f9b7704db8a01f5c54ee48f5935f406f.tar.bz2
rails-e56b8900f9b7704db8a01f5c54ee48f5935f406f.zip
Merge pull request #8158 from steveklabnik/deprecate_diff
Deprecate Hash#diff.
-rw-r--r--actionpack/lib/action_dispatch/testing/assertions/routing.rb4
-rw-r--r--activesupport/CHANGELOG.md3
-rw-r--r--activesupport/lib/active_support/core_ext/hash/diff.rb1
3 files changed, 5 insertions, 3 deletions
diff --git a/actionpack/lib/action_dispatch/testing/assertions/routing.rb b/actionpack/lib/action_dispatch/testing/assertions/routing.rb
index 305bafc0c5..8f17ee05be 100644
--- a/actionpack/lib/action_dispatch/testing/assertions/routing.rb
+++ b/actionpack/lib/action_dispatch/testing/assertions/routing.rb
@@ -1,5 +1,4 @@
require 'uri'
-require 'active_support/core_ext/hash/diff'
require 'active_support/core_ext/hash/indifferent_access'
require 'action_controller/metal/exceptions'
@@ -44,9 +43,8 @@ module ActionDispatch
expected_options.stringify_keys!
- # FIXME: minitest does object diffs, do we need to have our own?
message ||= sprintf("The recognized options <%s> did not match <%s>, difference: <%s>",
- request.path_parameters, expected_options, expected_options.diff(request.path_parameters))
+ request.path_parameters, expected_options, diff(expected_options, request.path_parameters))
assert_equal(expected_options, request.path_parameters, message)
end
diff --git a/activesupport/CHANGELOG.md b/activesupport/CHANGELOG.md
index 61d85543d1..dc84b44dec 100644
--- a/activesupport/CHANGELOG.md
+++ b/activesupport/CHANGELOG.md
@@ -1,4 +1,7 @@
## Rails 4.0.0 (unreleased) ##
+
+* Deprecate Hash#diff in favor of MiniTest's #diff. *Steve Klabnik*
+
* Kernel#capture can catch output from subprocesses *Dmitry Vorotilin*
* `to_xml` conversions now use builder's `tag!` method instead of explicit invocation of `method_missing`.
diff --git a/activesupport/lib/active_support/core_ext/hash/diff.rb b/activesupport/lib/active_support/core_ext/hash/diff.rb
index 831dee8ecb..a27c55479a 100644
--- a/activesupport/lib/active_support/core_ext/hash/diff.rb
+++ b/activesupport/lib/active_support/core_ext/hash/diff.rb
@@ -6,6 +6,7 @@ class Hash
# {}.diff(1 => 2) # => {1 => 2}
# {1 => 2, 3 => 4}.diff(1 => 2) # => {3 => 4}
def diff(other)
+ ActiveSupport::Deprecation.warn "Hash#diff is no longer used inside of Rails, and is being deprecated with no replacement. If you're using it to compare hashes for the purpose of testing, please use MiniTest's diff instead."
dup.
delete_if { |k, v| other[k] == v }.
merge!(other.dup.delete_if { |k, v| has_key?(k) })