I test a lot of bad lines when checking as follows:
['0', '3:a', 'xx:11', '-1', '-3:00', 'h', 'h2', 'h2h', 'm', 'm10', 'm10m', '2hm', 'h2m', 'hm2', '2m10h', '2m10m', '2h10h'].each do |input| FactoryGirl.build(:time_record, duration_string: input).should have(1).error_on('duration_string'), "Tested value was '#{input}'" end
Unfortunately, when one of them fails, the message expected 1 error on :duration_string, got 0 does not tell me which one failed. I know that I can pass a second argument that appears instead of the default message, for example:
x.should have(1).error_on('duration_string'), "Tested value was '#{input}'"
But this hides the original message. Is there a way to add only my own message to the original instead of replacing it?
Thanks.
source share