-
-
Save adam12/677199202cb76791b6e767563b93e908 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "minitest/autorun" | |
class TestFoo < Minitest::Test | |
ArrayPattern = Struct.new(:pattern) do | |
def ===(other) | |
pattern.zip(other).all? { |(left, right)| left === right } | |
end | |
end | |
def assert_includes_pattern(collection, pattern) | |
array_pattern = ArrayPattern.new(pattern) | |
assert(collection.any? { _1 in ^array_pattern }, <<~EOM) | |
Expected #{collection.inspect} to contain #{pattern.inspect} | |
EOM | |
end | |
def test_assertion | |
users = [ | |
["adam12", "#ruby"], | |
["ruby-bot", "#ruby"] | |
] | |
assert_includes_pattern users, ["adam12", String] | |
assert_includes_pattern users, ["adam12", "#libera"] | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment