diff options
author | Kasper Timm Hansen <kaspth@gmail.com> | 2018-12-19 21:09:34 +0100 |
---|---|---|
committer | Kasper Timm Hansen <kaspth@gmail.com> | 2018-12-19 21:47:50 +0100 |
commit | 1b7c3222e86b98ce886110ae0860ba62e35e2299 (patch) | |
tree | 21728e09c24e5d9c79360a820b49b1b72efb3a70 /activesupport/lib/active_support/testing | |
parent | abae9d0e0a0f1628cbf608765db09c1db3303732 (diff) | |
download | rails-1b7c3222e86b98ce886110ae0860ba62e35e2299.tar.gz rails-1b7c3222e86b98ce886110ae0860ba62e35e2299.tar.bz2 rails-1b7c3222e86b98ce886110ae0860ba62e35e2299.zip |
Require Ruby 2.5 for Rails 6.
Generally followed the pattern for https://github.com/rails/rails/pull/32034
* Removes needless CI configs for 2.4
* Targets 2.5 in rubocop
* Updates existing CHANGELOG entries for fewer merge conflicts
* Removes Hash#slice extension as that's inlined on Ruby 2.5.
* Removes the need for send on define_method in MethodCallAssertions.
Diffstat (limited to 'activesupport/lib/active_support/testing')
-rw-r--r-- | activesupport/lib/active_support/testing/method_call_assertions.rb | 14 |
1 files changed, 6 insertions, 8 deletions
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) |