Module: Minitest::Assertions

Defined in:
lib/sixarm_ruby_minitest_equal_collection/minitest/assertions/equal_collection.rb

Overview

Please see README

Instance Method Summary collapse

Instance Method Details

#assert_equal_collection(expect, actual, msg = nil) ⇒ Object

Succeeds when exp and act contain equal items and counts, regardless of order.



11
12
13
14
15
16
# File 'lib/sixarm_ruby_minitest_equal_collection/minitest/assertions/equal_collection.rb', line 11

def assert_equal_collection(expect, actual, msg = nil)
  shared_equal_collection(expect, actual, msg)
  diff = shared_diff(expect, actual)
  assert diff.empty?, 
    "Expected collections to have the same items. Expect: #{ expect.inspect }. Actual #{ actual.inspect }. Diff: #{ diff.inspect }." + append_msg(msg)
end

#refute_equal_collection(expect, actual, msg = nil) ⇒ Object

Succeeds when exp and act contain different items and/or counts, regardless of order.



21
22
23
24
25
26
# File 'lib/sixarm_ruby_minitest_equal_collection/minitest/assertions/equal_collection.rb', line 21

def refute_equal_collection(expect, actual, msg = nil)
  shared_equal_collection(expect, actual)
  diff = shared_diff(expect, actual)
  refute diff.empty?,
    "Expected collections to not have the same items. Expect: #{ expect.inspect }. Actual: #{ actual.inspect }. Diff: #{ diff.inspect }" + append_msg(msg)
end