Basic application:
I currently have a function in almost every script that is screaming
to be stripped out and put into a global helper.rb file.  At the end
of a series of tests, it sends me an email and parses the errors I've
collected stored in the array $errors.  This works well, except that
some tests may store 4 items per block in the array, while others may
only store 2 or 3.

I know that I've seen other functions defined where the author was
able to use something like:
def my_function(condition1, condition2, ...)
and therefore collect as many variable as were supplied, no matter
what the limit, but I'm not sure what that is called so Google isn't
helping.

I know this is probably something mundane and simple that I am
overlooking, but I've spent enough time wondering that it is time to
ask.

As for code, I'm currently using the stream method to send me an error
digest.  I've marked the line that needs to change on a test by test
basis -- all of the other items I can easily parametrize once I tackle
this problem.

CATCHING THE ERROR
begin
  assert_match(expected, actual)
  log_success("Expected matches actual") #custom function
rescue
  log_failure("Expected does not match actual) #custom function
  $errors << [expected, actual]
end #begin


THE EMAIL
    def email_errors
        int = 0
        Net::SMTP.start("##.##.##.##") do |smtp|
        smtp.open_message_stream('automated_t...@#####.com',
'#...@#####.com') do |stream|
          stream.puts "Subject: ########## Errors"
          stream.puts "The following whatevers failed to do the thing
you told them to:"

          $errors.each do |exp, act|  # ** this is the section that
needs to change on a test by test basis **
            int = int + 1
            stream.puts ""
            stream.puts "#{int}\tCondition:#{exp}"
            stream.puts "\tExpected Condition:#{act}"
            stream.puts ""
          end #$errors
        end #smtp
        smtp.finish #close the smtp connection
        end #Net
    end #email_errors

-- 
You received this message because you are subscribed to the Google Groups 
"Watir General" group.
To post to this group, send email to [email protected]
Before posting, please read the following guidelines: 
http://wiki.openqa.org/display/WTR/Support
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/watir-general

Reply via email to