watir 1.4.1 → 1.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (151) hide show
  1. data/bin/watir-console +1 -0
  2. data/changes.rb +119 -0
  3. data/license.rb +37 -0
  4. data/readme.rb +55 -120
  5. data/unittests/buttons_test.rb +107 -104
  6. data/unittests/buttons_xpath_test.rb +69 -0
  7. data/unittests/checkbox_test.rb +154 -141
  8. data/unittests/checkbox_xpath_test.rb +107 -0
  9. data/unittests/core_tests.rb +6 -2
  10. data/unittests/css_test.rb +50 -50
  11. data/unittests/defer_test.rb +47 -0
  12. data/unittests/dialog_test.rb +78 -0
  13. data/unittests/div2_xpath_test.rb +22 -0
  14. data/unittests/div_test.rb +159 -159
  15. data/unittests/div_xpath_test.rb +96 -0
  16. data/unittests/errorchecker_test.rb +22 -22
  17. data/unittests/filefield_test.rb +30 -23
  18. data/unittests/filefield_xpath_test.rb +35 -0
  19. data/unittests/form_test.rb +250 -229
  20. data/unittests/form_xpath_test.rb +253 -0
  21. data/unittests/frame_test.rb +123 -108
  22. data/unittests/google_form_test.rb +17 -0
  23. data/unittests/html/JavascriptClick.html +39 -0
  24. data/unittests/html/buttons1.html +3 -2
  25. data/unittests/html/checkboxes1.html +32 -14
  26. data/unittests/html/complex_table.html +1 -1
  27. data/unittests/html/depot_store.html +59 -0
  28. data/unittests/html/div.html +3 -21
  29. data/unittests/html/div_xml.html +21 -0
  30. data/unittests/html/fileupload.html +2 -2
  31. data/unittests/html/forms2.html +3 -3
  32. data/unittests/html/forms3.html +2 -2
  33. data/unittests/html/frame_links.html +2 -2
  34. data/unittests/html/google_india.html +119 -0
  35. data/unittests/html/iframeTest.html +2 -2
  36. data/unittests/html/images/map.GIF +0 -0
  37. data/unittests/html/images/map2.gif +0 -0
  38. data/unittests/html/images1.html +17 -2
  39. data/unittests/html/javascriptevents.html +3 -7
  40. data/unittests/html/links1.html +9 -8
  41. data/unittests/html/links_multi.html +14 -0
  42. data/unittests/html/list_matters.html +720 -0
  43. data/unittests/html/lists.html +18 -0
  44. data/unittests/html/map_test.html +31 -0
  45. data/unittests/html/modal_dialog.html +10 -0
  46. data/unittests/html/modal_dialog_launcher.html +12 -0
  47. data/unittests/html/new_browser.html +17 -0
  48. data/unittests/html/pass.html +3 -0
  49. data/unittests/html/popups1.html +1 -1
  50. data/unittests/html/pre.html +28 -0
  51. data/unittests/html/radioButtons1.html +6 -5
  52. data/unittests/html/selectboxes1.html +12 -11
  53. data/unittests/html/simple_table.html +1 -1
  54. data/unittests/html/simple_table_columns.html +1 -1
  55. data/unittests/html/table1.html +1 -1
  56. data/unittests/html/tableCell_using_xpath.html +19 -0
  57. data/unittests/html/textfields1.html +6 -4
  58. data/unittests/html/xpath_nbsp.html +12 -0
  59. data/unittests/ie_exists_test.rb +32 -0
  60. data/unittests/ie_mock.rb +78 -79
  61. data/unittests/ie_test.rb +39 -39
  62. data/unittests/images_test.rb +132 -155
  63. data/unittests/images_xpath_test.rb +91 -0
  64. data/unittests/links_multi_test.rb +36 -0
  65. data/unittests/links_test.rb +158 -152
  66. data/unittests/links_xpath_test.rb +40 -0
  67. data/unittests/lists_test.rb +29 -0
  68. data/unittests/map_test.rb +99 -0
  69. data/unittests/minmax_test.rb +23 -23
  70. data/unittests/navigate_test.rb +43 -51
  71. data/unittests/nbsp_xpath_test.rb +18 -0
  72. data/unittests/other/WindowLogonExample.rb +28 -0
  73. data/unittests/{WindowLogonExtra.rb → other/WindowLogonExtra.rb} +0 -0
  74. data/unittests/{all_tests_concurrent.rb → other/all_tests_concurrent.rb} +23 -23
  75. data/unittests/other/navigate_exception_test.rb +14 -0
  76. data/unittests/other/rexml_unit_test.rb +24 -0
  77. data/unittests/other/testcase_method_order_test.rb +36 -0
  78. data/unittests/other/testcase_verify_test.rb +25 -0
  79. data/unittests/other/wait_until_test.rb +99 -0
  80. data/unittests/pagecontainstext_test.rb +56 -37
  81. data/unittests/parent_child_test.rb +55 -0
  82. data/unittests/popups_test.rb +37 -37
  83. data/unittests/pre_test.rb +52 -0
  84. data/unittests/radios_test.rb +186 -155
  85. data/unittests/radios_xpath_test.rb +101 -0
  86. data/unittests/screen_capture_test.rb +41 -41
  87. data/unittests/selectbox_test.rb +223 -181
  88. data/unittests/selectbox_xpath_test.rb +113 -0
  89. data/unittests/setup.rb +29 -25
  90. data/unittests/speed_settings_test.rb +22 -0
  91. data/unittests/table_cell_using_xpath_test.rb +40 -0
  92. data/unittests/table_test.rb +315 -284
  93. data/unittests/table_xpath_test.rb +114 -0
  94. data/unittests/textarea_test.rb +81 -0
  95. data/unittests/textarea_xpath_test.rb +82 -0
  96. data/unittests/textfields_test.rb +205 -229
  97. data/unittests/textfields_xpath_test.rb +111 -0
  98. data/unittests/window_tests.rb +7 -0
  99. data/unittests/windows/attach_to_existing_window_test.rb +52 -0
  100. data/unittests/windows/attach_to_new_window_test.rb +82 -0
  101. data/unittests/windows/close_window_test.rb +22 -0
  102. data/unittests/windows/frame_links_test.rb +25 -0
  103. data/unittests/windows/ie-each_test.rb +48 -0
  104. data/unittests/windows/iedialog_test.rb +55 -0
  105. data/unittests/windows/js_events_test.rb +57 -0
  106. data/unittests/windows/jscriptExtraAlert.rb +6 -0
  107. data/unittests/windows/jscriptExtraConfirmCancel.rb +7 -0
  108. data/unittests/windows/jscriptExtraConfirmOk.rb +7 -0
  109. data/unittests/{jscriptPushButton.rb → windows/jscriptPushButton.rb} +1 -1
  110. data/unittests/windows/jscript_test.rb +64 -0
  111. data/unittests/windows/modal_dialog_test.rb +127 -0
  112. data/unittests/windows/new.rb +56 -0
  113. data/unittests/windows/open_close_test.rb +22 -0
  114. data/unittests/windows/send_keys_test.rb +34 -0
  115. data/unittests/xpath_tests.rb +10 -0
  116. data/watir.rb +4344 -3565
  117. data/watir/IEDialog/Release/IEDialog.dll +0 -0
  118. data/watir/WindowHelper.rb +13 -11
  119. data/watir/assertions.rb +36 -0
  120. data/watir/camel_case.rb +14 -5
  121. data/watir/close_all.rb +38 -0
  122. data/watir/contrib/enabled_popup.rb +21 -0
  123. data/watir/contrib/ie-new-process.rb +27 -0
  124. data/watir/contrib/page_checker.rb +29 -0
  125. data/watir/contrib/visible.rb +47 -0
  126. data/watir/cookiemanager.rb +4 -4
  127. data/watir/datahandler.rb +107 -0
  128. data/watir/dialog.rb +46 -0
  129. data/watir/elements.rb +65 -0
  130. data/watir/exceptions.rb +18 -36
  131. data/watir/ie-process.rb +40 -0
  132. data/watir/irb-history.rb +31 -0
  133. data/watir/process.rb +20 -0
  134. data/watir/testUnitAddons.rb +3 -42
  135. data/watir/testcase.rb +58 -0
  136. data/watir/utils.rb +20 -0
  137. data/watir/waiter.rb +88 -0
  138. data/watir/watir_simple.rb +4 -4
  139. data/watir/win32ole.rb +8 -0
  140. data/watir/win32ole/win32ole.so +0 -0
  141. data/watir/winClicker.rb +374 -400
  142. metadata +209 -128
  143. data/unittests/WindowLogonExample.rb +0 -30
  144. data/unittests/attachToExistingWindow_test.rb +0 -40
  145. data/unittests/js_events_test.rb +0 -77
  146. data/unittests/jscriptExtraAlert.rb +0 -6
  147. data/unittests/jscriptExtraConfirmCancel.rb +0 -7
  148. data/unittests/jscriptExtraConfirmOk.rb +0 -7
  149. data/unittests/jscript_test.rb +0 -57
  150. data/unittests/send_keys_test.rb +0 -29
  151. data/unittests/textAreafields_test.rb +0 -81
@@ -1,31 +1,31 @@
1
1
  # feature tests for minimizing and maximizing IE windows
2
- # revision: $Revision: 1.1.2.1 $
2
+ # revision: $Revision: 958 $
3
3
 
4
4
  $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') if $0 == __FILE__
5
5
  require 'unittests/setup'
6
6
 
7
7
  class TC_MinMax< Test::Unit::TestCase
8
- include Watir
9
- def setup
10
- $ie.goto($htmlRoot + 'pass.html')
11
- end
12
- def teardown
13
- $ie.restore
14
- end
15
- def test_minimimum
16
- $ie.minimize
17
- end
18
- def test_maximum
19
- $ie.maximize
20
- end
21
- def test_front
22
- assert $ie.front?
23
- ie2 = IE.start($htmlRoot + 'blankpage.html')
24
- assert ie2.front?
25
- assert_false $ie.front?
26
- $ie.bring_to_front
27
- assert $ie.front?
28
- ie2.close
29
- end
8
+ include Watir
9
+ def setup
10
+ $ie.goto($htmlRoot + 'pass.html')
11
+ end
12
+ def teardown
13
+ $ie.restore
14
+ end
15
+ def test_minimimum
16
+ $ie.minimize
17
+ end
18
+ def test_maximum
19
+ $ie.maximize
20
+ end
21
+ def test_front
22
+ assert $ie.front?
23
+ ie2 = IE.start($htmlRoot + 'blankpage.html')
24
+ assert ie2.front?
25
+ assert_false $ie.front?
26
+ $ie.bring_to_front
27
+ assert $ie.front?
28
+ ie2.close
29
+ end
30
30
  end
31
31
 
@@ -1,56 +1,48 @@
1
1
  # feature tests for navigation
2
- # revision: $Revision: 1.12 $
2
+ # revision: $Revision: 1009 $
3
3
 
4
4
  $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') if $0 == __FILE__
5
5
  require 'unittests/setup'
6
-
7
- class TC_Navigate< Test::Unit::TestCase
8
- include Watir
9
-
10
- def gotoPage( a )
11
- $ie.goto($htmlRoot + a)
12
- end
13
-
14
- def test_navigation
15
-
16
- $ie.clear_url_list
17
- gotoPage( 'buttons1.html')
18
- url = $ie.url.downcase.gsub('///' , '//') # no idea why this happens - we get 3 / after file:
19
- assert_equal(url.downcase , ( $htmlRoot + 'buttons1.html' ).downcase ) # the downcase is that sometimes we get capital drivee letters
20
-
21
- assert_equal( 1, $ie.url_list.length )
22
- assert_equal( url , $ie.url_list[0].gsub('\\', '/').downcase )
23
-
24
- gotoPage( 'checkboxes1.html')
25
- url = $ie.url.downcase.gsub('///' , '//') # no idea why this happens - we get 3 / after file:
26
-
27
- assert_equal($ie.title , "Test page for Check Boxes")
28
- assert_equal( 2, $ie.url_list.length )
29
- assert_equal( url , $ie.url_list[1].gsub('\\', '/').downcase )
30
-
31
- $ie.clear_url_list
32
- assert_equal( 0, $ie.url_list.length )
33
-
34
- $ie.back
35
- assert_equal($ie.title , "Test page for buttons")
36
-
37
- $ie.forward
38
- assert_equal($ie.title , "Test page for Check Boxes")
39
-
40
- $ie.checkBox(:name , "box1").set
41
- assert($ie.checkBox(:name, "box1").isSet?)
42
-
43
- $ie.refresh
44
- # Not sure how we test this. Text fields and checkboxes dont get reset if you click the browser refresh button
45
- end
46
-
47
- def test_http_errors
48
- # this is commented out as it depends on too many things.....
49
-
50
- assert_raises(NavigationException) { $ie.goto('http://localhost:3001') } # Cannot find server or DNS Error
51
- assert_raises(NavigationException) { $ie.goto('http://www.fxruby.org/dfdf' ) } # HTTP 404 - File not found
52
-
53
- end
54
-
6
+ require 'CGI'
7
+
8
+ class TC_Navigate < Test::Unit::TestCase
9
+ include Watir
10
+
11
+ def goto_page(a)
12
+ $ie.goto($htmlRoot + a)
13
+ end
14
+
15
+ def test_navigation
16
+ $ie.clear_url_list
17
+ goto_page('buttons1.html')
18
+ url = $ie.url.downcase.gsub('///' , '//') # no idea why this happens - we get 3 / after file:
19
+ url = CGI::unescape(url) # url is encoded so we need to
20
+ assert_equal(url.downcase, ($htmlRoot + 'buttons1.html' ).downcase ) # sometimes we get capital drive letters
21
+
22
+ assert_equal(1, $ie.url_list.length)
23
+ assert_equal(url, $ie.url_list[0].gsub('\\', '/').downcase)
24
+
25
+ goto_page('checkboxes1.html')
26
+ url = $ie.url.downcase.gsub('///' , '//') # no idea why this happens - we get 3 / after file:
27
+ url = CGI::unescape(url) # url is encoded so we need to
28
+
29
+ assert_equal($ie.title, "Test page for Check Boxes")
30
+ assert_equal(2, $ie.url_list.length)
31
+ assert_equal(url, $ie.url_list[1].gsub('\\', '/').downcase)
32
+
33
+ $ie.clear_url_list
34
+ assert_equal(0, $ie.url_list.length )
35
+
36
+ $ie.back
37
+ assert_equal($ie.title , "Test page for buttons")
38
+
39
+ $ie.forward
40
+ assert_equal($ie.title , "Test page for Check Boxes")
41
+
42
+ $ie.checkBox(:name, "box1").set
43
+ assert($ie.checkBox(:name, "box1").isSet?)
44
+
45
+ $ie.refresh
46
+ # Not sure how we test this. Text fields and checkboxes dont get reset if you click the browser refresh button
47
+ end
55
48
  end
56
-
@@ -0,0 +1,18 @@
1
+ # feature tests for Tables
2
+ # revision: $Revision: 1076 $
3
+
4
+ $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') if $0 == __FILE__
5
+ require 'unittests/setup'
6
+
7
+ class TC_Tables < Test::Unit::TestCase
8
+ include Watir
9
+
10
+ def setup
11
+ $ie.goto($htmlRoot + "xpath_nbsp.html")
12
+ end
13
+
14
+ def test_nbsp
15
+ div = $ie.element_by_xpath("//div")
16
+ assert(div.innerText, "Hello world")
17
+ end
18
+ end
@@ -0,0 +1,28 @@
1
+ $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') if $0 == __FILE__
2
+ require 'unittests/setup'
3
+ require 'watir/WindowHelper'
4
+
5
+ class TC_Logon_Test < Test::Unit::TestCase
6
+ include Watir
7
+
8
+ def goto_windows_login_page
9
+ $ie.goto('http://clio.lyris.com/')
10
+ end
11
+
12
+
13
+ def test_window_logon
14
+
15
+ a = Thread.new {
16
+ system('ruby WindowLogonExtra.rb')
17
+
18
+ }
19
+ b = Thread.new {
20
+ goto_windows_login_page
21
+ }
22
+ a.join
23
+ b.join
24
+ end
25
+
26
+
27
+
28
+ end
@@ -14,19 +14,19 @@ require 'unittests/checkbox_test'
14
14
  require 'test/unit/testsuite'
15
15
  require 'thread'
16
16
  class ConcurrentTestSuite < Test::Unit::TestSuite
17
-
18
- # Runs the tests and/or suites contained in this TestSuite.
19
- def run(result, &progress_block)
20
- yield(STARTED, name)
21
- threads = []
22
- @tests.each do |test|
23
- threads << Thread.new do
24
- test.run(result, &progress_block)
25
- end
26
- end
27
- threads.each {|t| t.join}
28
- yield(FINISHED, name)
17
+
18
+ # Runs the tests and/or suites contained in this TestSuite.
19
+ def run(result, &progress_block)
20
+ yield(STARTED, name)
21
+ threads = []
22
+ @tests.each do |test|
23
+ threads << Thread.new do
24
+ test.run(result, &progress_block)
29
25
  end
26
+ end
27
+ threads.each {|t| t.join}
28
+ yield(FINISHED, name)
29
+ end
30
30
  end
31
31
 
32
32
  # create a suite
@@ -36,19 +36,19 @@ require 'test/unit/collector'
36
36
  include Test::Unit::Collector
37
37
 
38
38
 
39
- @filters = []
40
- suite = ConcurrentTestSuite.new('super suite')
41
- sub_suites = []
42
- ::ObjectSpace.each_object(Class) do |klass|
43
- if(Test::Unit::TestCase > klass)
44
- puts sub_suites, klass.suite
45
- add_suite(sub_suites, klass.suite)
46
- end
47
- end
48
- sort(sub_suites).each{|s| suite << s}
39
+ @filters = []
40
+ suite = ConcurrentTestSuite.new('super suite')
41
+ sub_suites = []
42
+ ::ObjectSpace.each_object(Class) do |klass|
43
+ if(Test::Unit::TestCase > klass)
44
+ puts sub_suites, klass.suite
45
+ add_suite(sub_suites, klass.suite)
46
+ end
47
+ end
48
+ sort(sub_suites).each{|s| suite << s}
49
+
49
50
 
50
51
 
51
-
52
52
  # select a runner
53
53
  require 'test/unit/ui/console/testrunner'
54
54
  Test::Unit::UI::Console::TestRunner.run(suite)
@@ -0,0 +1,14 @@
1
+ # feature tests for navigation errors
2
+ # revision: $Revision: 958 $
3
+
4
+ $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') if $0 == __FILE__
5
+ require 'unittests/setup'
6
+
7
+ class TC_NavigateException < Test::Unit::TestCase
8
+ include Watir
9
+
10
+ def test_http_errors
11
+ assert_raises(NavigationException) { $ie.goto('http://localhost:3001') } # Cannot find server or DNS Error
12
+ assert_raises(NavigationException) { $ie.goto('http://www.fxruby.org/dfdf' ) } # HTTP 404 - File not found
13
+ end
14
+ end
@@ -0,0 +1,24 @@
1
+ require 'test/unit'
2
+ require "rexml/document"
3
+
4
+ class RexmlTest < Test::Unit::TestCase
5
+ def setup
6
+ file = File.open( "xpath_bug.xml" )
7
+ @doc = REXML::Document.new file
8
+ end
9
+ def fixture xpath
10
+ matches = []
11
+ @doc.elements.each(xpath) do |element|
12
+ matches << element
13
+ assert_equal('Add', element.text)
14
+ assert_equal('ButtonText', element.attributes['class'])
15
+ end
16
+ assert_equal(1, matches.length)
17
+ end
18
+ def test_text
19
+ fixture "//div[text()='Add' and @class='ButtonText']"
20
+ end
21
+ def test_contains
22
+ fixture "//div[contains(.,'Add') and @class='ButtonText']"
23
+ end
24
+ end
@@ -0,0 +1,36 @@
1
+ # the default behavior of Test::Unit::TestCase should be to execute test
2
+ # methods in alphabetical order.
3
+ # When executed, should print "A.B.C.D.E.F.G.H.I.J.K.L.F"
4
+ # The final F is actually an expected failure:
5
+ # 1) Failure:
6
+ # default_test(TC4_No_Test_Methods)
7
+
8
+ $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', '..') if $0 == __FILE__
9
+
10
+ require 'watir/testcase'
11
+
12
+ class TC1_Alphabetical_Default < Watir::TestCase
13
+ execute :alphabetically
14
+ def test_b; print 'B'; end
15
+ def test_a; print 'A'; end
16
+ def test_d; print 'D'; end
17
+ def test_c; print 'C'; end
18
+ end
19
+
20
+ class TC2_Sequential < Watir::TestCase
21
+ def test_b; print 'E'; end
22
+ def test_a; print 'F'; end
23
+ def test_d; print 'G'; end
24
+ def test_c; print 'H'; end
25
+ end
26
+
27
+ class TC3_Alphabetical_Specified < Watir::TestCase
28
+ execute :alphabetically
29
+ def test_b; print 'J'; end
30
+ def test_a; print 'I'; end
31
+ def test_d; print 'L'; end
32
+ def test_c; print 'K'; end
33
+ end
34
+
35
+ class TC4_No_Test_Methods < Watir::TestCase
36
+ end
@@ -0,0 +1,25 @@
1
+ # 3 tests, 10 assertions, 4 failures, 0 errors
2
+
3
+ require 'watir/testcase'
4
+
5
+ class VerifyTests < Watir::TestCase
6
+
7
+ def test_verify
8
+ verify true
9
+ assert true
10
+ verify false
11
+ assert true
12
+ end
13
+
14
+ def test_verify_equal
15
+ verify_equal 1, 1
16
+ verify_equal 1, 2
17
+ verify_equal 3, 4
18
+ end
19
+
20
+ def test_verify_match
21
+ verify_match /\d*/, '123'
22
+ verify_match 'foo', 'foobar'
23
+ verify_match '...', 'A'
24
+ end
25
+ end
@@ -0,0 +1,99 @@
1
+ # feature tests for wait_until
2
+
3
+ require 'watir/testcase'
4
+ require 'watir/waiter'
5
+ require 'watir'
6
+ require 'spec' # gem install rspec
7
+
8
+ # used for unit testing
9
+ class MockTimeKeeper < Watir::TimeKeeper
10
+ def sleep seconds
11
+ @sleep_time += seconds
12
+ end
13
+ def now
14
+ Time.now + @sleep_time
15
+ end
16
+ end
17
+
18
+ class WaitUntilInstanceTest < Watir::TestCase
19
+
20
+ def setup
21
+ @waiter = Watir::Waiter.new
22
+ @waiter.timeout = 10.0
23
+ @mock_checkee = Spec::Mocks::Mock.new "mock_checkee"
24
+
25
+ # remove this line to test with actual TimeKeeper intead of the Mock
26
+ # (slower, but more accurate)
27
+ @waiter.timer = MockTimeKeeper.new
28
+ end
29
+
30
+ def teardown
31
+ @mock_checkee.__verify if @test_passed
32
+ end
33
+
34
+ # Instance Method
35
+
36
+ def test_no_time_passes_if_true
37
+ @waiter.wait_until {true}
38
+ @waiter.timer.sleep_time.should_equal 0.0
39
+ end
40
+
41
+ def test_three_tries_before_true
42
+ @mock_checkee.should_receive(:check).exactly(3).times.and_return [false, false, true]
43
+ @waiter.wait_until {@mock_checkee.check}
44
+ @waiter.timer.sleep_time.should_equal 1.0
45
+ end
46
+
47
+ def test_timeout
48
+ @mock_checkee.should_receive(:check).any_number_of_times.and_return false
49
+ lambda{@waiter.wait_until {@mock_checkee.check}}.should_raise Watir::Exception::TimeOutException
50
+ @waiter.timer.sleep_time.should_be_close 10.25, 0.26
51
+ @waiter.timer.sleep_time.should_satisfy {|x| [10.0, 10.5].include? x}
52
+ end
53
+
54
+ def test_polling_interval
55
+ @waiter.polling_interval = 0.1
56
+ @mock_checkee.should_receive(:check).any_number_of_times.and_return false
57
+ lambda{@waiter.wait_until {@mock_checkee.check}}.should_raise Watir::Exception::TimeOutException
58
+ @waiter.timer.sleep_time.should_be_close 10.05, 0.07
59
+ end
60
+
61
+ def test_timeout_duration
62
+ @mock_checkee.should_receive(:check).any_number_of_times.and_return false
63
+ begin
64
+ @waiter.wait_until {@mock_checkee.check}
65
+ flunk
66
+ rescue Watir::Exception::TimeOutException => e
67
+ e.duration.should_be_close 10.25, 0.26
68
+ e.timeout.should_equal 10.0
69
+ end
70
+ end
71
+ end
72
+
73
+ class WaitUntilClassTest < Watir::TestCase
74
+
75
+ def setup
76
+ @mock_checkee = Spec::Mocks::Mock.new "mock_checkee"
77
+ @mock_checkee.should_receive(:check).exactly(3).times.and_return [false, false, true]
78
+ end
79
+
80
+ def teardown
81
+ @mock_checkee.__verify if @test_passed
82
+ end
83
+ # Class method
84
+
85
+ def test_class_method_with_args
86
+ Watir::Waiter.wait_until(5, 0.1) {@mock_checkee.check}
87
+ end
88
+
89
+ def test_class_method_with_defaults
90
+ Watir::Waiter.wait_until {@mock_checkee.check}
91
+ end
92
+
93
+ include Watir
94
+ def test_watir_method
95
+ wait_until {@mock_checkee.check}
96
+ end
97
+
98
+ end
99
+