Skip to content

Instantly share code, notes, and snippets.

@jasonkarns
Created September 17, 2015 16:07
Show Gist options
  • Save jasonkarns/f009fa582315fae87cfb to your computer and use it in GitHub Desktop.
Save jasonkarns/f009fa582315fae87cfb to your computer and use it in GitHub Desktop.
# named captures shouldn't *have* to be compared as a hash;
# MatchData still returns the captures as a plain indexed array,
# so matching against the indexed captures should still be allowed
it "matches indexed captures against named captures" do
expect(Regexp.new("(?<num>123)")).to match("a123a").with_captures("123")
end
# doesn't make sense to show the expected captures if the match itself fails; they're irrelevant at that point
it "shows plain match failure message if match itself fails" do
expect {
expect(/(a)/).to match("123").with_captures()
}.to fail_with(/expected \/(a)\/ to match "123"/)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment