As for what it's called, various Ruby guides use the name "variable-length argument lists". There's some good info online:
http://en.wikibooks.org/wiki/Ruby_Programming/Syntax/Method_Calls#Variable_Length_Argument_List.2C_Asterisk_Operator http://ruby-doc.org/docs/ProgrammingRuby/html/tut_methods.html (skip down to the "Variable-Length Argument Lists" section) The O'Reilly Ruby Programming Language book also has info on the same thing. It's a great read if you're interested in topics like this. Thanks Bill On Thu, Dec 10, 2009 at 1:18 PM, AR <[email protected]> wrote: > 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 -- 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
