aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport
diff options
context:
space:
mode:
Diffstat (limited to 'activesupport')
-rw-r--r--activesupport/CHANGELOG.md4
-rw-r--r--activesupport/activesupport.gemspec2
-rw-r--r--activesupport/lib/active_support/core_ext/hash/slice.rb23
-rw-r--r--activesupport/lib/active_support/testing/method_call_assertions.rb14
4 files changed, 9 insertions, 34 deletions
diff --git a/activesupport/CHANGELOG.md b/activesupport/CHANGELOG.md
index ba8aaf47f9..e678f48244 100644
--- a/activesupport/CHANGELOG.md
+++ b/activesupport/CHANGELOG.md
@@ -282,9 +282,9 @@
*Jeremy Daer*
-* Rails 6 requires Ruby 2.4.1 or newer.
+* Rails 6 requires Ruby 2.5.0 or newer.
- *Jeremy Daer*
+ *Jeremy Daer*, *Kasper Timm Hansen*
* Adds parallel testing to Rails.
diff --git a/activesupport/activesupport.gemspec b/activesupport/activesupport.gemspec
index 448a2eeebb..bdd7bc70a0 100644
--- a/activesupport/activesupport.gemspec
+++ b/activesupport/activesupport.gemspec
@@ -9,7 +9,7 @@ Gem::Specification.new do |s|
s.summary = "A toolkit of support libraries and Ruby core extensions extracted from the Rails framework."
s.description = "A toolkit of support libraries and Ruby core extensions extracted from the Rails framework. Rich support for multibyte strings, internationalization, time zones, and testing."
- s.required_ruby_version = ">= 2.4.1"
+ s.required_ruby_version = ">= 2.5.0"
s.license = "MIT"
diff --git a/activesupport/lib/active_support/core_ext/hash/slice.rb b/activesupport/lib/active_support/core_ext/hash/slice.rb
index e07a5498ff..3d0f8a1e62 100644
--- a/activesupport/lib/active_support/core_ext/hash/slice.rb
+++ b/activesupport/lib/active_support/core_ext/hash/slice.rb
@@ -1,29 +1,6 @@
# frozen_string_literal: true
class Hash
- # Slices a hash to include only the given keys. Returns a hash containing
- # the given keys.
- #
- # { a: 1, b: 2, c: 3, d: 4 }.slice(:a, :b)
- # # => {:a=>1, :b=>2}
- #
- # This is useful for limiting an options hash to valid keys before
- # passing to a method:
- #
- # def search(criteria = {})
- # criteria.assert_valid_keys(:mass, :velocity, :time)
- # end
- #
- # search(options.slice(:mass, :velocity, :time))
- #
- # If you have an array of keys you want to limit to, you should splat them:
- #
- # valid_keys = [:mass, :velocity, :time]
- # search(options.slice(*valid_keys))
- def slice(*keys)
- keys.each_with_object(Hash.new) { |k, hash| hash[k] = self[k] if has_key?(k) }
- end unless method_defined?(:slice)
-
# Replaces the hash with only the given keys.
# Returns a hash containing the removed key/value pairs.
#
diff --git a/activesupport/lib/active_support/testing/method_call_assertions.rb b/activesupport/lib/active_support/testing/method_call_assertions.rb
index eba41aa907..03c38be481 100644
--- a/activesupport/lib/active_support/testing/method_call_assertions.rb
+++ b/activesupport/lib/active_support/testing/method_call_assertions.rb
@@ -35,18 +35,16 @@ module ActiveSupport
assert_called(object, method_name, message, times: 0, &block)
end
- # TODO: No need to resort to #send once support for Ruby 2.4 is
- # dropped.
def assert_called_on_instance_of(klass, method_name, message = nil, times: 1, returns: nil)
times_called = 0
- klass.send(:define_method, "stubbed_#{method_name}") do |*|
+ klass.define_method("stubbed_#{method_name}") do |*|
times_called += 1
returns
end
- klass.send(:alias_method, "original_#{method_name}", method_name)
- klass.send(:alias_method, method_name, "stubbed_#{method_name}")
+ klass.alias_method "original_#{method_name}", method_name
+ klass.alias_method method_name, "stubbed_#{method_name}"
yield
@@ -55,9 +53,9 @@ module ActiveSupport
assert_equal times, times_called, error
ensure
- klass.send(:alias_method, method_name, "original_#{method_name}")
- klass.send(:undef_method, "original_#{method_name}")
- klass.send(:undef_method, "stubbed_#{method_name}")
+ klass.alias_method method_name, "original_#{method_name}"
+ klass.undef_method "original_#{method_name}"
+ klass.undef_method "stubbed_#{method_name}"
end
def assert_not_called_on_instance_of(klass, method_name, message = nil, &block)