Hi Terry...
I hope better programmers than me comment, this is a really good question.

> Right now I'm cluttering up my test case with a lot of conditionals/case
> statements so that it can react accordingly, but that doesn't seem really
> elegant to me. Does anyone know of a better way to do this?

 A general design rule of thumb is to substitute methods for
conditionals.  I know that sounds all abstract and stuff, but here's a
concrete example.  I have an app that shows 10 things at a time on an
arbitrarily large number of pages.  So I'll write a method like this:

def check_for_next_page
@ie.links.each do |link|
        if link.href =~ /b_start/ and link.text =~ /Next/ and link.text =~ 
/items/
                process_next_page_method
                link.click
        end
end
end #def

So above that I have another method that will process the page *if the
page exists*:

def process_next_page_method
@ie.links.each do |link|
        if link.href =~ /IWantThisLink/
                link.href =~/\d+/
                @data_array<<$&
                #puts $&
        end
end #def

That way only one conditional per page, one conditional per link per page.

I hope that makes sense, good luck.
BTW, I bet if you google something like "ruby conditionals methods"
you might find useful stuff, too.
-Chris

_______________________________________________
Wtr-general mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/wtr-general

Reply via email to