Scope issues can be very confusing and it sounds a lot like that's the
core of your problem..   I'm frankly still wrapping my head around all
the complexities of scope (being primarily a tester not a developer)
and what I can tell you is this..

Investigate the Watircraft framework  (wiki.github.com/bret/
watircraft).  it's specifically designed to make it easier to work
with Watir along with Rspec and Cucumber.  it does a lot to take away
the headaches of scope, and automatically creates browser instances
for you when your test runs, and generally makes it a lot easier and
more effecient to do BDD/TDD stuff with watir.

back to scope, I'm mostly using cucumber so maybe one of the other
folks more experienced with rspec can address your specific code, but
what I found in general was that even if I made it as a local, if I
created the browser inside a test in my test class, as soon as the
code passed outside that test blam it was gone.  Even if I had a
utility method to create the browser that was defined outside the test
class, if I ivoked that method from inside the test, as soon as we
passed outside the test gone.  I had to devolve to using globals for
my browser instance to prevent this...   I've since moved to using
watircraft, and I no longer worry about this, I just use 'browser'
everywhere and it just works.  that alone, plus the ability to define
things using page files, has made the switch worth it.

On Apr 15, 9:17 am, «°¤§ømåtïçCðrp§ë¤°» <[email protected]>
wrote:
> Sorry, forgot to mention, I changed the 'ibrowser' error to the right
> syntax, but when it gets to the 'vaildating text on the page should
> find predefine text on a page', it doesn't recognize "browser" as a
> valid, global object. Do I have to initialize it, outside of the
> describe/do scenarios?
>
> There's lots more questions, but we'll deal with those, after the
> aforementioned one...
>
> On Apr 15, 10:00 am, «°¤§ømåtïçCðrp§ë¤°» <[email protected]>
> wrote:
>
>
>
> > So, I'm trying to do some BDD/TDD development, and I can't figure some
> > things out...
>
> > Primarily, if I run the script, using "ruby T.rb", nothing happens -
> > nothing returns, etc. If I use "spec T.rb", then I get a bunch of
> > errors.
>
> > Does ruby/watir/spec treat each instance (describe/do) as it's own
> > main, leaving the objects within that section?
>
> > I'll append the code, to illustrate what I'm doing, and the errors,
> > afterwards...
>
> > [code]
>
> > ##-------------------------------------------------------------------------­­-------------------------------------------
> > ##
> > ##                                                                          
> >                                             ##
> > ##Sevin V 0.0.1                                                             
> >                                     ##
> > ##Sevin is written by Bailey, John E.                                       
> >                                     ##
> > ##Sevin is written under the GPL/GNU.                                       
> >                                     ##
> > ##                                                                          
> >                                             ##
> > ##                                      ErrorCodes ::
> > ErrorCodes                                                              ##
> > ##Code1 - User Initiated Error (Some instance that is directly related
> > to user action/inaction)                ##
> > ##Code2 - System Initiated Error (Some instance that is directly
> > related to system action/inaction)      ##
> > ##                                                                          
> >                                             ##
> > ##                                                                          
> >                                             ##
> > ##-------------------------------------------------------------------------­­-------------------------------------------
> > ##
>
> >   #################
> >  #Process Dependencies        #
> > #################
> > require 'spec'
> > require 'watir'
> > require 'test/unit'
>
> >     ##########################
> >    #                                                  #
> >   #                  Begin Iteration                    #
> >  #                                                            #
> > ##########################
>
> > #####################
> > #Get Customer Info                    #
> > ####################
> > Fname = String.new
> > LName = String.new
>
> > puts "What is the user's First Name?"
> > Fname = gets.chomp #Removes return (recognized as new line command)
> > character '\n'
> > puts "What is the user's Last Name?"
> > Lname = gets.chomp #Removes return (recognized as new line command)
> > character '\n'
>
> > #####################
> > #Take control of the Brower        #
> > ####################
> >         describe "Ticket Processing" do
> >                 it "should click the button to begin the process" do
> >                         begin
> >                         #attach to a running instance of IE
> >                         browser = Watir::IE.attach(:url, 
> > 'https://www.servicecenterweb.unisys.com/sc2/index.do')
> >                                 #rescue the process, if no instance is 
> > running
> >                                 rescue 
> > Watir::Exception::NoMatchingWindowFoundException
> >                                         puts "ALERT: You must have a 
> > running instance of SVC open!"
> >                                         browser = Watir::IE.new(:url, 
> > 'https://www.servicenterweb.unisys.com/sc2/index.do')
> >                                         puts "Please log into SVC and 
> > restart Sevin. Exiting: Code1."
> >                                 break
> >                         end
> >                         #sets speed of browser/process handling
> >                         browser.speed = :zippy
> >                         #take control and begin creating a new ticket
> >                         browser.frame(:id, 'detail').button(:id, 'X8').click
> >                 end
> >         end
> > ######################
> > #Validate IE returned correct page #
> > #####################
> >         describe "vaildating text on the page" do
> >                 it "should find predefine text on a page" do
> >                         #validate that the process worked
> >                         if ibrowser.text.include?("COMPANY INFORMATION")
> >                                         puts: "Validated returned page - 
> > Sevin Continuing."
> >                                 else
> >                                         puts: "Sevin Failed! Exiting: 
> > Code2. Page didn't contain text:
> > COMPANY INFORMATION."
> >                                         break
> >                         end
> >                 end
> >         end
> > ######################
> > #Begin Entitlement processing        #
> > #####################
> >         describe "Entitlment processing" do
> >                 it "should insert the user's name and company" do
> >                         #Insert company name and user
> >                         broswer.frame(:id, 'detail').text_field(:id, 
> > 'X6').set("BAXTER")
> >                         browser.frame(:id, 'detail').text_field(:id, '  
> > ').set(%Fname)
> >                         broswer.frame(:id, 'detail').text_field(:id, '  
> > ').set(%Lname)
> >                         browser.frame(:id, 'detail').button(:id, '  ').click
> >                 end
> >         end
> > ######################
> > #Ensure entitlement was successful #
> > #####################
> >         describe "Validate text on page (phone)" do
> >                 it "should fine some data filled into form" do
> >                         #Validate data is in phone field
>
> >                 end
> >         end
> > ######################
> > #Begin Ticket Creation                  #
> > #####################
> >         describe "Begin creating the ticket" do
> >                 it "should place data into the required fields" do
> >                         #Insert data
>
> >                 end
> >         end
>
> > #TODO: implement remaining code, after admin privileges are granted.
> > [/code]
>
> > ERRORS:
> > C:\Documents and Settings\M0nKy\Desktop>spec T.rb
> > What is the user's First Name?
> > What is the user's Last Name?
> > .ALERT: You must have a running instance of SVC open!
> > Please log into SVC and restart Sevin. Exiting: Code1.
> > FFF..
>
> > 1)
> > NoMethodError in 'Ticket Processing should click the button to begin
> > the process
> > '
> > undefined method `speed=' for nil:NilClass
> > ./T.rb:55:
>
> > 2)
> > NameError in 'vaildating text on the page should find predefine text
> > on a page'
> > undefined local variable or method `browser' for
> > #<Spec::Example::ExampleGroup::
> > Subclass_3:0x32e7acc>
> > ./T.rb:67:
>
> > 3)
> > NameError in 'Entitlment processing should insert the user's name and
> > company'
> > undefined local variable or method `browser' for
> > #<Spec::Example::ExampleGroup::
> > Subclass_4:0x32e4b88>
> > ./T.rb:81:
>
> > Finished in 12.578 seconds
>
> > 6 examples, 3 failures
>
> > C:\Documents and Settings\M0nKy\Desktop>
>
> > C:\Documents and Settings\M0nKy\Desktop>ruby T.rb
>
> > C:\Documents and Settings\M0nKy\Desktop>- Hide quoted text -
>
> - Show quoted text -
--~--~---------~--~----~------------~-------~--~----~
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