[rspec-users] RSpec framework question

Adam R reed.adam at gmail.com
Tue Mar 2 16:05:41 EST 2010

An update for this issue.  This script works, but only if I explicitly define
the array that I'm iterating over (][countryname, url]].each do, rather than
@countries.each do).

Can someone help me understand why my array here (@countries) is not
recognized?  I tried to instantiate it as a global variable ($countries) and
it still was not recognized.  If I explicitly describe an array in place of
the variable, the script works.

Is it an issue with my organization format, or something else?

$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') if $0 == __FILE__
require 'helpers/example_helper'

describe "The country page for" do
  include ExHelper
  before(:all) do
  @countries.each do |name, link|
    describe name do
    it "should contain the word #{name} in the title" do
      @browser.goto link
      @browser.div(:id, /content-content/).text.should include(name)
    end #it
    end #desc
  end #countries
  after(:all) do
  end #after
end #spec

$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') if $0 == __FILE__
require 'helpers/global_helper'

module ExHelper
  include GlobalHelper
  def setup
    @browser = Watir::Browser.new
    @browser.add_checker lambda {|b| b.text.should_not include('The
requested page could not be found.')}
  end # setup
  def collect_global_countries
    @countries = Array.new
    @countries.should be_empty
    @browser.goto "http://www.#{$env}.com/global"
    @browser.table(:class, /global-list/).links.each do |link|    
      @countries << [link.text, link.href]
    end #links
    @countries.should_not be_empty
  def teardown
  end # teardown
end #module
View this message in context: http://old.nabble.com/RSpec-and-Watir%2C-easy-script-structure-question-tp27758607p27761159.html
Sent from the rspec-users mailing list archive at Nabble.com.

More information about the rspec-users mailing list