jasonkarns
9/17/2015 - 4:07 PM

match_with_captures_spec.rb

# 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