rails--rails/actionpack/test/controller/parameters
Ricardo Díaz 93cbc30f34 Use Enumerator#all? and Enumerator#any? with classes instead of iterations
These methods have changed in Ruby 2.5 to be more akin to grep:

https://bugs.ruby-lang.org/issues/11286

Using classes seems to be faster (and a bit more expressive) than iterating over
the collection items:

```
Warming up --------------------------------------
    #all? with class   504.000  i/100ms
     #all? with proc   189.000  i/100ms
Calculating -------------------------------------
    #all? with class      4.960k (± 1.6%) i/s -     25.200k in   5.082049s
     #all? with proc      1.874k (± 2.8%) i/s -      9.450k in   5.047866s

Comparison:
    #all? with class:     4959.9 i/s
     #all? with proc:     1873.8 i/s - 2.65x  (± 0.00) slower
```

Benchmark script:

```ruby
require "minitest/autorun"
require "benchmark/ips"

class BugTest < Minitest::Test
  def test_enumerators_with_classes
    arr = (1..10000).to_a << nil

    assert_equal arr.all?(Integer), arr.all? { |v| v.is_a?(Integer) }

    Benchmark.ips do |x|
      x.report("#all? with class") do
        arr.all?(Integer)
      end

      x.report("#all? with proc") do
        arr.all? { |v| v.is_a?(Integer) }
      end

      x.compare!
    end
  end
end
```
2021-02-07 01:29:50 -05:00
..
accessors_test.rb Use Enumerator#all? and Enumerator#any? with classes instead of iterations 2021-02-07 01:29:50 -05:00
always_permitted_parameters_test.rb
dup_test.rb
log_on_unpermitted_params_test.rb Enable `Layout/EmptyLinesAroundAccessModifier` cop 2019-06-13 12:00:45 +09:00
multi_parameter_attributes_test.rb
mutators_test.rb Add compact and compact! to ActionController::Parameters 2020-05-17 11:04:25 +01:00
nested_parameters_permit_test.rb fixed usage of Parameters when a non-numeric key exists 2019-05-13 15:03:27 +08:00
parameters_permit_test.rb
raise_on_unpermitted_params_test.rb
serialization_test.rb