Thanks. I've got it now. I wasn't doing a require 'test/unit/assertions' --
I was mistakenly doing require 'test/unit', and not including this:
Test::Unit::Assertions. (smacks forehead)
Paul gave me a couple pointers and I have this working like a charm:
irb(main):001:0 require 'watir'
= true
irb(main):002:0 require 'test/unit/assertions'
= true
irb(main):003:0 include Test::Unit::Assertions
= Object
irb(main):004:0 ie = Watir::IE.new
= #Watir::IE:0x2da5928 @form=nil, @ie=#WIN32OLE:0x2da58c8,
@defaultSleepTime=0.1, @error_ch
eckers=[#Proc:[EMAIL PROTECTED]:/ruby/lib/ruby/site_ruby/1.8/watir.rb:1213],
@logger=#Watir::Defa
ultLogger:0x2da5868 @progname=nil, @logdev=#Logger::LogDevice:0x2da5808
@dev=#IO:0x2a6f370,
@shift_size=nil, @shift_age=nil, @filename=nil, @level=2,
@datetime_format=%d-%b-%Y %H:%M:%S
, @typingspeed=0.08, @activeObjectHighLightColor=yellow,
@enable_spinner=false, @url_list=[]
irb(main):005:0 ie.goto(http://www.google.com;)
= 0.391
irb(main):006:0 ie.text_field(:name, q).set(pickaxe)
= nil
irb(main):007:0 ie.button(:value, Google Search).click
= nil
irb(main):008:0 begin
irb(main):009:1* assert(ie.contains_text(Programming Ruby) )
irb(main):010:1 puts(TEST PASSED. Found test string 'Programming Ruby'
)
irb(main):011:1 rescue = e
irb(main):012:1puts(TEST FAILED. + e.message + \n +
e.backtrace.join(\n))
irb(main):013:1end
TEST PASSED. Found test string 'Programming Ruby'
= nil
-Original Message-
From: [EMAIL PROTECTED] [mailto:wtr-general-
[EMAIL PROTECTED] On Behalf Of Bret Pettichord
Sent: August 2, 2005 4:40 PM
To: wtr-general@rubyforge.org
Subject: RE: [Wtr-general] Using Asserts
Works for me:
irb(main):010:0 require 'test/unit/assertions'
= true
irb(main):011:0 include Test::Unit::Assertions
= Object
irb(main):012:0 assert(true)
= nil
irb(main):013:0 assert(false)
Test::Unit::AssertionFailedError: false is not true.
from c:/ruby/lib/ruby/1.8/test/unit/assertions.rb:30:in
`assert_block'
from c:/ruby/lib/ruby/1.8/test/unit/assertions.rb:28:in
`_wrap_assertion
'
from c:/ruby/lib/ruby/1.8/test/unit/assertions.rb:28:in
`assert_block'
from c:/ruby/lib/ruby/1.8/test/unit/assertions.rb:40:in `assert'
from c:/ruby/lib/ruby/1.8/test/unit/assertions.rb:38:in
`_wrap_assertion
'
from c:/ruby/lib/ruby/1.8/test/unit/assertions.rb:38:in `assert'
from (irb):13
irb(main):014:0
At 05:08 PM 8/2/2005, Jonathan Kohl wrote:
I haven t been able to get assertions to work in IRB when using Watir
either. I do a require for both Watir and test::unit, but it gets into a
strange state. I wanted to do this for live demos, but have had to
hand-wave at this point, and then run a script that prints out the
assertions. Maybe someone else has a suggestion.
Out of curiosity, why do you want to do this in IRB instead of saving the
tests in test files?
-Jonathan
--
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Tuyet Cong-Ton-Nu
Sent: August 2, 2005 4:04 PM
To: wtr-general@rubyforge.org
Subject: [Wtr-general] Using Asserts
I still can t get Asserts commands to work in the irb.
I got all the require statements correctly (they return true), but here
are some asserts statements that don t give me back anything.
Maybe I don t know how to use them or decipher whether it s true or
false:
irb(main):046:1 assert_true(ie.contains_text(none)
irb(main):047:2 assert_true(ie.contains_text(%%%none)
irb(main):048:3 rescue = e
irb(main):049:3 puts e
irb(main):050:3 I get nothing here! I expected it to fail since there
is
no such text on my IE page
___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general
_
Bret Pettichord
www.pettichord.com
___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general
___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general