In the following snippet, the first two fields exist, the remaining do
not. However, the test correctly tells me that replyaddr is missing, but
never processes the last two items in the list:
def test_fields_exist
@fields = ['jobid', 'company', 'replyaddr', 'SEEKER_CC', 'RESUME_FILE']
@fields.each do |field|
assert(@reply_form.has_field?(field), "Field missing: #{field}")
end
end
Why is that?
···
--
"Oh, look: rocks!"
-- Doctor Who, "Destiny of the Daleks"
AFAIK the Test::Unit framework always terminates a test method at the first failure. To get what I think you are looking for, you might write something like:
<code--not tested>
def test_fields_present
['jobid', 'company'].each do |field|
assert(@reply_form.has_field?(field), "Field missing: #{field}")
end
end
def test_fields_missing
['replyaddr', 'SEEKER_CC', 'RESUME_FILE'].each do |field|
assert(not @reply_form.has_field?(field), "Field present: #{field}")
end
end
</code>
Regards, Morton
···
On Nov 1, 2007, at 9:17 PM, Todd A. Jacobs wrote:
In the following snippet, the first two fields exist, the remaining do
not. However, the test correctly tells me that replyaddr is missing, but
never processes the last two items in the list:
def test_fields_exist
@fields = ['jobid', 'company', 'replyaddr', 'SEEKER_CC', 'RESUME_FILE']
@fields.each do |field|
assert(@reply_form.has_field?(field), "Field missing: #{field}")
end
end
Why is that?