must vs will
Published 2008-04-28 @ 10:57
Tagged ruby, thoughts
John Barnette made a suggestion I like: will vs wont.
Do you like that better than must vs wont? I think I do, but it might be too visually similar. I’m not sure. Check it:
(6 * 7).must_equal 42
(6 * 9).wont_equal 42
vs.
(6 * 7).will_equal 42
(6 * 9).wont_equal 42
I think it looks OK so far.
Also, I added a simple little mapping system to make morphing the assertions into specifications more readable:
Object.infect(:must, :wont,
/(throw)s/ => '\1',
/must_(.*_of|nil|same)/ => 'must_be_\1',
/must_not_(nil|same)/ => 'must_not_be_\1',
/wont_(nil|same)/ => 'wont_be_\1',
/must_in_delta/ => 'must_be_close_to',
/must_no_match/ => 'must_not_match',
/must_operator/ => 'must_be',
/^(wont|must(_(block|raises|nothing_(raised|thrown)))?)$/ => :skip)