Skip to content

Commit

Permalink
Merge pull request #41428 from jonathanhefner/enumerable-test-empty-m…
Browse files Browse the repository at this point in the history
…aximum-minimum

Test #maximum and #minimum with empty enumerable
  • Loading branch information
kamipo committed Feb 12, 2021
2 parents 1acde22 + 5df979d commit 8dc7439
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions activesupport/test/core_ext/enumerable_test.rb
Expand Up @@ -34,11 +34,21 @@ def test_minimum
assert_equal 5, payments.minimum(:price)
end

def test_minimum_with_empty_enumerable
payments = GenericEnumerable.new([])
assert_nil payments.minimum(:price)
end

def test_maximum
payments = GenericEnumerable.new([ Payment.new(5), Payment.new(15), Payment.new(10) ])
assert_equal 15, payments.maximum(:price)
end

def test_maximum_with_empty_enumerable
payments = GenericEnumerable.new([])
assert_nil payments.maximum(:price)
end

def test_sums
enum = GenericEnumerable.new([5, 15, 10])
assert_equal 30, enum.sum
Expand Down

0 comments on commit 8dc7439

Please sign in to comment.