From: 7stud -- Date: 2009-08-18T19:51:06+09:00 Subject: Re: unit testing generated content sylvain wrote: > > What I would like to do now, is to have a regexp assert multiline > match, some thing like : > > assert_match_regexp(actual) { > /^start/ > /something .*/ > /^\s*$/ > /^end/ > } > > Which mean I expect 4 lines, individually matching the associated > regexp > > Do you see a want to achieve? > > I mean, reading the blockgiven, counting the regexp, and asserting the > whole... > > More that that a full regexpdiff in fact ! ;-) > > Any link or clue/hint, would be nice. > How about: def test_it(str) num_lines = 4 regexs = [/^start/, /something .*/, /^\s*$/, /^end/] lines = str.split("\n") return false if lines.length != num_lines match_results = lines.zip(regexs).collect{|line, regex| line =~ regex} match_results.all? end s1 =<