I'm at it again!  Having some trouble completing an RSpec script with
a pretty simple concept -- mostly having trouble with the hierarchy of
it all.


Basically, I have a single page with many links.  Each link points the
same type of template with a different title.  The script stores these
links to an array, visits each page and verifies that it contains the
correct title.  That's the easy part.

However with RSpec, I'd like each different link to be it's own
headline/describe function for the HTML report -- each page should
have it's own "NAME page should contain the word name in the title",
etc.  Here is what I have so far, that obviously does not work:

    describe "Page with links" do

      before(:all) do
        setup
        @browser.goto page
      end #before.all

      it "should contain a table with links" do
        @browser.table(:class, /example/).links.each do |link|
          @countries << [link.text, link.href]
        end #links

        @countries.should_not be_empty
      end #it

      @countries.each do |name, link|
        it "should contain the word #{name} in the title" do
          @browser.goto link
          @browser.div(:id, /example/).text.should include(name)
        end #it
      end #...@countries

      after(:all) do
        teardown
      end #after
    end #describe


That made me think that I'd need something more like what is below,
but I need to instantiate the browser and created the @countries
array, and this script did not like having two describe blocks...  I'm
getting pretty confused!

(this seems correct, I just don't know where to put it in the script!)

    @countries.each do |name, link|
         describe name do
              it "should contain the word #{name}" do
                    @browser.goto link
                    @browser.div(:id, /whatever/).text.should
include(name)
              end #it
         end
    end #each


With Test::Unit, I would simply use the following, but again, I'm not
trying to conform to RSpec-type output here:

    def test_01_example
         page_links << Array.new

         @browser.goto page

         @browser.links.each do |link|
            page_links << [link.text, link.href]
         end #page.links.each

         page_links.each do |title, url|
            @browser.goto url
            assert(@browser.contains_text(title))
         end #page_links.each
    end #def

Can someone please sort me out?

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

Reply via email to