Module: MiniTest::Assertions

Defined in:
lib/debugger/test/matchers.rb

Instance Method Summary collapse

Instance Method Details

#assert_includes_in_order(given_collection, original_collection, msg = nil) ⇒ Object

This matcher checks that given collection is included into the original collection, and in correct order. It accepts both strings and regexps.

Examples:

assert_includes_in_order(%w{1 2 3 4 5}, %w{1 3 5})            # => pass
assert_includes_in_order(%w{1 2 3 4 5}, %w{1 5 3})            # => fail
assert_includes_in_order(w{1 2 3 4 5}, ["1", /\d+/, "5"])     # => pass
assert_includes_in_order(w{1 2 3 4 5}, ["1", /\[a-z]+/, "5"]) # => fail


13
14
15
16
17
18
# File 'lib/debugger/test/matchers.rb', line 13

def assert_includes_in_order(given_collection, original_collection, msg = nil)
  msg = message(msg) do
    "Expected #{mu_pp(original_collection)} to include #{mu_pp(given_collection)} in order"
  end
  assert includes_in_order_result(original_collection, given_collection), msg
end

#refute_includes_in_order(given_collection, original_collection, msg = nil) ⇒ Object



20
21
22
23
24
25
# File 'lib/debugger/test/matchers.rb', line 20

def refute_includes_in_order(given_collection, original_collection, msg = nil)
  msg = message(msg) do
    "Expected #{mu_pp(original_collection)} to not include #{mu_pp(given_collection)} in order"
  end
  refute includes_in_order_result(original_collection, given_collection), msg
end