watir 1.4.1
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.
- data/readme.rb +211 -0
- data/unittests/WindowLogonExample.rb +30 -0
- data/unittests/WindowLogonExtra.rb +7 -0
- data/unittests/all_tests.rb +10 -0
- data/unittests/all_tests_concurrent.rb +57 -0
- data/unittests/attachToExistingWindow_test.rb +40 -0
- data/unittests/buttons_test.rb +131 -0
- data/unittests/checkbox_test.rb +149 -0
- data/unittests/core_tests.rb +9 -0
- data/unittests/css_test.rb +60 -0
- data/unittests/div_test.rb +179 -0
- data/unittests/errorchecker_test.rb +29 -0
- data/unittests/filefield_test.rb +35 -0
- data/unittests/form_test.rb +279 -0
- data/unittests/frame_test.rb +141 -0
- data/unittests/html/blankpage.html +12 -0
- data/unittests/html/buttons1.html +40 -0
- data/unittests/html/checkboxes1.html +69 -0
- data/unittests/html/complex_table.html +36 -0
- data/unittests/html/cssTest.html +42 -0
- data/unittests/html/div.html +105 -0
- data/unittests/html/fileupload.html +45 -0
- data/unittests/html/formTest1.html +39 -0
- data/unittests/html/forms2.html +45 -0
- data/unittests/html/forms3.html +132 -0
- data/unittests/html/forms4.html +27 -0
- data/unittests/html/frame_buttons.html +4 -0
- data/unittests/html/frame_links.html +4 -0
- data/unittests/html/frame_multi.html +5 -0
- data/unittests/html/iframeTest.html +13 -0
- data/unittests/html/iframeTest1.html +7 -0
- data/unittests/html/iframeTest2.html +6 -0
- data/unittests/html/images/1.gif +0 -0
- data/unittests/html/images/2.GIF +0 -0
- data/unittests/html/images/3.GIF +0 -0
- data/unittests/html/images/button.jpg +0 -0
- data/unittests/html/images/circle.jpg +0 -0
- data/unittests/html/images/minus.GIF +0 -0
- data/unittests/html/images/originaltriangle.jpg +0 -0
- data/unittests/html/images/plus.gif +0 -0
- data/unittests/html/images/square.jpg +0 -0
- data/unittests/html/images/triangle.jpg +0 -0
- data/unittests/html/images1.html +52 -0
- data/unittests/html/javascriptevents.html +39 -0
- data/unittests/html/link_pass.html +11 -0
- data/unittests/html/links1.html +37 -0
- data/unittests/html/links2.html +11 -0
- data/unittests/html/nestedFrames.html +6 -0
- data/unittests/html/pass.html +10 -0
- data/unittests/html/popups1.html +60 -0
- data/unittests/html/radioButtons1.html +71 -0
- data/unittests/html/select_tealeaf.html +54 -0
- data/unittests/html/selectboxes1.html +55 -0
- data/unittests/html/simple_table.html +26 -0
- data/unittests/html/simple_table_buttons.html +104 -0
- data/unittests/html/simple_table_columns.html +76 -0
- data/unittests/html/table1.html +142 -0
- data/unittests/html/textarea.html +30 -0
- data/unittests/html/textfields1.html +87 -0
- data/unittests/html/textsearch.html +44 -0
- data/unittests/ie_mock.rb +93 -0
- data/unittests/ie_test.rb +50 -0
- data/unittests/images_test.rb +179 -0
- data/unittests/iostring.rb +30 -0
- data/unittests/iostring_test.rb +48 -0
- data/unittests/js_events_test.rb +77 -0
- data/unittests/jscriptExtraAlert.rb +6 -0
- data/unittests/jscriptExtraConfirmCancel.rb +7 -0
- data/unittests/jscriptExtraConfirmOk.rb +7 -0
- data/unittests/jscriptPushButton.rb +5 -0
- data/unittests/jscript_test.rb +57 -0
- data/unittests/links_test.rb +169 -0
- data/unittests/minmax_test.rb +31 -0
- data/unittests/navigate_test.rb +56 -0
- data/unittests/non_core_tests.rb +9 -0
- data/unittests/pagecontainstext_test.rb +49 -0
- data/unittests/popups_test.rb +44 -0
- data/unittests/radios_test.rb +164 -0
- data/unittests/screen_capture_test.rb +53 -0
- data/unittests/selectbox_test.rb +197 -0
- data/unittests/send_keys_test.rb +29 -0
- data/unittests/setup.rb +47 -0
- data/unittests/table_test.rb +306 -0
- data/unittests/textAreafields_test.rb +81 -0
- data/unittests/textfields_test.rb +239 -0
- data/watir.rb +3744 -0
- data/watir/AutoItX3.dll +0 -0
- data/watir/WindowHelper.rb +47 -0
- data/watir/camel_case.rb +37 -0
- data/watir/clickJSDialog.rb +19 -0
- data/watir/cookiemanager.rb +53 -0
- data/watir/exceptions.rb +60 -0
- data/watir/screen_capture.rb +115 -0
- data/watir/setFileDialog.rb +16 -0
- data/watir/testUnitAddons.rb +47 -0
- data/watir/watir_simple.rb +475 -0
- data/watir/winClicker.rb +505 -0
- metadata +152 -0
@@ -0,0 +1,44 @@
|
|
1
|
+
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
</head>
|
5
|
+
<body>
|
6
|
+
To be, or not to be: that is the question:<br>
|
7
|
+
Whether 'tis nobler in the mind to suffer<br>
|
8
|
+
The slings and arrows of outrageous fortune,<br>
|
9
|
+
Or to take arms against a sea of troubles,<br>
|
10
|
+
And by opposing end them? To die: to sleep:<br>
|
11
|
+
No more; and by a sleep to say we end<br>
|
12
|
+
The heartache and the thousand natural shocks<br>
|
13
|
+
That flesh is heir to,--'t is a consummation<br>
|
14
|
+
Devoutly to be wish'd. To die, to sleep;<br>
|
15
|
+
To sleep: perchance to dream: ay, there's the rub:<br>
|
16
|
+
For in that sleep of death what dreams may come,<br>
|
17
|
+
When we have shuffled off this mortal coil,<br>
|
18
|
+
Must give us pause: there's the respect<br>
|
19
|
+
That makes calamity of so long life;<br>
|
20
|
+
For who would bear the whips and scorns of time,<br>
|
21
|
+
The oppressor's wrong, the proud man's contumely,<br>
|
22
|
+
The pangs of despised love, the law's delay,<br>
|
23
|
+
The insolence of office and the spurns<br>
|
24
|
+
That patient merit of the unworthy takes,<br>
|
25
|
+
When he himself might his quietus make<br>
|
26
|
+
With a bare bodkin? who would fardels bear,<br>
|
27
|
+
To grunt and sweat under a weary life,<br>
|
28
|
+
But that the dread of something after death,<br>
|
29
|
+
The undiscover'd country from whose bourn<br>
|
30
|
+
No traveller returns, puzzles the will<br>
|
31
|
+
And makes us rather bear those ills we have<br>
|
32
|
+
Than fly to others that we know not of?<br>
|
33
|
+
Thus conscience does make cowards of us all;<br>
|
34
|
+
And thus the native hue of resolution<br>
|
35
|
+
Is sicklied o'er with the pale cast of thought,<br>
|
36
|
+
And enterprises of great pith and moment<br>
|
37
|
+
With this regard their currents turn awry,<br>
|
38
|
+
And lose the name of action.<br>
|
39
|
+
<br>
|
40
|
+
Messages 42<br>
|
41
|
+
<br>
|
42
|
+
<br>
|
43
|
+
</body>
|
44
|
+
</html>
|
@@ -0,0 +1,93 @@
|
|
1
|
+
# mock library for testing the IE controller
|
2
|
+
require 'watir'
|
3
|
+
|
4
|
+
class FakeFrame
|
5
|
+
def length
|
6
|
+
return 0
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
class FakeAll
|
11
|
+
def initialize(doc)
|
12
|
+
@doc = doc
|
13
|
+
end
|
14
|
+
def tags(tag)
|
15
|
+
@doc.links
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
|
20
|
+
class FakeDoc
|
21
|
+
|
22
|
+
attr_accessor :links, :all
|
23
|
+
|
24
|
+
def initialize()
|
25
|
+
@links = ""
|
26
|
+
@all = FakeAll.new(self)
|
27
|
+
end
|
28
|
+
|
29
|
+
def frames
|
30
|
+
return FakeFrame.new()
|
31
|
+
end
|
32
|
+
|
33
|
+
def readyState
|
34
|
+
return "complete"
|
35
|
+
end
|
36
|
+
|
37
|
+
def addLink(value)
|
38
|
+
if @links.nil?
|
39
|
+
@links = value
|
40
|
+
else
|
41
|
+
@links << value
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def url
|
46
|
+
return "file://fake"
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
|
51
|
+
class StubExplorer
|
52
|
+
|
53
|
+
attr_accessor :timeToWait
|
54
|
+
|
55
|
+
def initialize()
|
56
|
+
@timeToWait = 1
|
57
|
+
@visible = $HIDE_IE
|
58
|
+
@document = FakeDoc.new()
|
59
|
+
end
|
60
|
+
|
61
|
+
def document
|
62
|
+
return @document
|
63
|
+
end
|
64
|
+
|
65
|
+
def busy ()
|
66
|
+
sleep @timeToWait
|
67
|
+
return FALSE
|
68
|
+
end
|
69
|
+
|
70
|
+
def readyState
|
71
|
+
return 4
|
72
|
+
end
|
73
|
+
|
74
|
+
def visible=(value)
|
75
|
+
end
|
76
|
+
|
77
|
+
end
|
78
|
+
|
79
|
+
class TestIE < Watir::IE
|
80
|
+
|
81
|
+
def create_browser_window
|
82
|
+
@ie = StubExplorer.new()
|
83
|
+
end
|
84
|
+
|
85
|
+
def addLink(link)
|
86
|
+
@ie.document.addLink(link)
|
87
|
+
end
|
88
|
+
|
89
|
+
def setTimeToWait(time = 1)
|
90
|
+
@ie.timeToWait = time
|
91
|
+
end
|
92
|
+
|
93
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# Unit Test for Internet Explorer
|
2
|
+
# revision: $Revision: 1.14 $
|
3
|
+
|
4
|
+
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') if $0 == __FILE__
|
5
|
+
require 'win32ole'
|
6
|
+
require 'unittests/ie_mock'
|
7
|
+
require 'test/unit'
|
8
|
+
|
9
|
+
class TC_ie < Test::Unit::TestCase
|
10
|
+
include Watir
|
11
|
+
|
12
|
+
def setup
|
13
|
+
@faked_ie = TestIE.new
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_waitForIE
|
17
|
+
wait_time = 1
|
18
|
+
# @faked_ie.logger.level = Logger::DEBUG
|
19
|
+
|
20
|
+
@faked_ie.setTimeToWait wait_time
|
21
|
+
begin_time = Time.now
|
22
|
+
@faked_ie.wait
|
23
|
+
elapsed_time = Time.now - begin_time
|
24
|
+
assert_in_delta(wait_time, elapsed_time, 0.5)
|
25
|
+
end
|
26
|
+
|
27
|
+
# is this correct?
|
28
|
+
def test_getLink_ByIndexReturnsNilOnNoLinks
|
29
|
+
assert_nil(@faked_ie.getLink(:index, 1))
|
30
|
+
assert_nil(@faked_ie.getLink(:index, 1))
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_getLink_ByBadHow
|
34
|
+
@faked_ie.addLink "foo"
|
35
|
+
assert_raise(MissingWayOfFindingObjectException) do
|
36
|
+
@faked_ie.getLink(:no_such_mechanism, "verifying error handling")
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
# is this correct?
|
41
|
+
def test_getLink_ByUrlReturnsNilOnNoLinks
|
42
|
+
assert_nil(@faked_ie.getLink(:url, "whatever"))
|
43
|
+
end
|
44
|
+
|
45
|
+
# is this correct?
|
46
|
+
def test_getLink_ByTextReturnsNilOnNoLinks
|
47
|
+
assert_nil(@faked_ie.getLink(:text, "whatever"))
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
@@ -0,0 +1,179 @@
|
|
1
|
+
# feature tests for Images
|
2
|
+
# revision: $Revision: 1.32.2.1 $
|
3
|
+
|
4
|
+
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') if $0 == __FILE__
|
5
|
+
require 'unittests/setup'
|
6
|
+
require 'ftools'
|
7
|
+
require 'webrick'
|
8
|
+
require 'watir/cookiemanager'
|
9
|
+
|
10
|
+
class TC_Images < Test::Unit::TestCase
|
11
|
+
include Watir
|
12
|
+
|
13
|
+
def setup
|
14
|
+
gotoImagePage
|
15
|
+
@saved_img_path = build_path("sample.img.dat");
|
16
|
+
end
|
17
|
+
|
18
|
+
def gotoImagePage()
|
19
|
+
$ie.goto($htmlRoot + "images1.html")
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_imageExists
|
23
|
+
assert_false( $ie.image(:name , "missing_name").exists? )
|
24
|
+
assert( $ie.image(:name , "circle").exists? )
|
25
|
+
assert( $ie.image(:name , /circ/ ).exists? )
|
26
|
+
|
27
|
+
assert_false( $ie.image(:id , "missing_id").exists? )
|
28
|
+
assert( $ie.image(:id , "square").exists? )
|
29
|
+
assert( $ie.image(:id , /squ/ ).exists? )
|
30
|
+
|
31
|
+
assert_false( $ie.image(:src, "missingsrc.gif").exists? )
|
32
|
+
|
33
|
+
# BP -- This fails for me but not for Paul. It doesn't make sense to me that it should pass.
|
34
|
+
# assert( $ie.image(:src , "file:///#{$myDir}/html/images/triangle.jpg").exists? )
|
35
|
+
assert( $ie.image(:src , /triangle/ ).exists? )
|
36
|
+
|
37
|
+
assert( $ie.image(:alt , "circle" ).exists? )
|
38
|
+
assert( $ie.image(:alt , /cir/ ).exists? )
|
39
|
+
|
40
|
+
assert_false( $ie.image(:alt , "triangle" ).exists? )
|
41
|
+
assert_false( $ie.image(:alt , /tri/ ).exists? )
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_image_click
|
45
|
+
assert_raises(UnknownObjectException ) { $ie.image(:name, "no_image_with_this").click }
|
46
|
+
assert_raises(UnknownObjectException ) { $ie.image(:id, "no_image_with_this").click }
|
47
|
+
assert_raises(UnknownObjectException ) { $ie.image(:src, "no_image_with_this").click}
|
48
|
+
assert_raises(UnknownObjectException ) { $ie.image(:alt, "no_image_with_this").click}
|
49
|
+
|
50
|
+
# test for bug 1882
|
51
|
+
$ie.text_field(:name , "text1").clear
|
52
|
+
$ie.button(:value , /Pos/ ).click
|
53
|
+
assert_equal('clicked' , $ie.text_field(:name , "text1" ).value )
|
54
|
+
|
55
|
+
# # test for disabled button
|
56
|
+
# assert_false( $ie.image(:name , 'disabler_test').disabled )
|
57
|
+
# $ie.button(:name , 'disable_img').click
|
58
|
+
#
|
59
|
+
# assert( $ie.image(:name , 'disabler_test').disabled )
|
60
|
+
# $ie.button(:name , 'disable_img').click
|
61
|
+
|
62
|
+
$ie.image(:src, /button/).click
|
63
|
+
assert($ie.contains_text("PASS") )
|
64
|
+
|
65
|
+
end
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
def test_imageHasLoaded
|
70
|
+
assert_raises(UnknownObjectException ) { $ie.image(:name, "no_image_with_this").hasLoaded? }
|
71
|
+
assert_raises(UnknownObjectException ) { $ie.image(:id, "no_image_with_this").hasLoaded? }
|
72
|
+
assert_raises(UnknownObjectException ) { $ie.image(:src, "no_image_with_this").hasLoaded? }
|
73
|
+
assert_raises(UnknownObjectException ) { $ie.image(:alt, "no_image_with_this").hasLoaded? }
|
74
|
+
|
75
|
+
assert_false( $ie.image(:name, "themissingimage").hasLoaded? )
|
76
|
+
assert( $ie.image(:name, "circle").hasLoaded? )
|
77
|
+
|
78
|
+
assert( $ie.image(:alt, "circle").hasLoaded? )
|
79
|
+
assert( $ie.image(:alt, /cir/ ).hasLoaded? )
|
80
|
+
end
|
81
|
+
|
82
|
+
def test_image_properties
|
83
|
+
assert_raises(UnknownObjectException ) { $ie.image(:name, "no_image_with_this").hasLoaded? }
|
84
|
+
assert_raises(UnknownObjectException ) { $ie.image(:id, "no_image_with_this").hasLoaded? }
|
85
|
+
assert_raises(UnknownObjectException ) { $ie.image(:src, "no_image_with_this").hasLoaded? }
|
86
|
+
assert_raises(UnknownObjectException ) { $ie.image(:index, 82).hasLoaded? }
|
87
|
+
|
88
|
+
assert_raises(UnknownObjectException ) { $ie.image(:index, 82).name }
|
89
|
+
assert_raises(UnknownObjectException ) { $ie.image(:index, 82).id }
|
90
|
+
assert_raises(UnknownObjectException ) { $ie.image(:index, 82).src }
|
91
|
+
assert_raises(UnknownObjectException ) { $ie.image(:index, 82).value }
|
92
|
+
assert_raises(UnknownObjectException ) { $ie.image(:index, 82).height }
|
93
|
+
assert_raises(UnknownObjectException ) { $ie.image(:index, 82).width }
|
94
|
+
assert_raises(UnknownObjectException ) { $ie.image(:index, 82).fileCreatedDate }
|
95
|
+
assert_raises(UnknownObjectException ) { $ie.image(:index, 82).fileSize }
|
96
|
+
assert_raises(UnknownObjectException ) { $ie.image(:index, 82).alt}
|
97
|
+
|
98
|
+
|
99
|
+
assert_equal( "image" , $ie.image(:index, 2).type )
|
100
|
+
assert_equal( "" , $ie.image(:index, 2).name )
|
101
|
+
assert_equal( "square" , $ie.image(:index, 2).id )
|
102
|
+
assert_match( /square\.jpg/i ,$ie.image(:index, 2).src )
|
103
|
+
assert_equal( "" , $ie.image(:index, 2).value )
|
104
|
+
assert_equal( "88" , $ie.image(:index, 2).height )
|
105
|
+
assert_equal( "88" , $ie.image(:index, 2).width )
|
106
|
+
|
107
|
+
|
108
|
+
# this line fails, as the date is when it is installed on the local oc, not the date the file was really created
|
109
|
+
#assert_equal( "03/10/2005" , $ie.image(:index, 2).fileCreatedDate )
|
110
|
+
assert_equal( "788", $ie.image(:index, 2).fileSize )
|
111
|
+
|
112
|
+
# alt text
|
113
|
+
assert_equal('circle' , $ie.image(:index, 6).alt)
|
114
|
+
assert_equal( "" , $ie.image(:index, 2).alt)
|
115
|
+
|
116
|
+
|
117
|
+
# to string tests -- output should be verified!
|
118
|
+
puts $ie.image(:name , "circle").to_s
|
119
|
+
puts $ie.image(:index , 2).to_s
|
120
|
+
end
|
121
|
+
|
122
|
+
def test_image_iterator
|
123
|
+
assert_equal(6 , $ie.images.length)
|
124
|
+
assert_equal("" , $ie.images[2].name )
|
125
|
+
assert_equal("square" , $ie.images[2].id )
|
126
|
+
assert_match(/square/ , $ie.images[2].src )
|
127
|
+
|
128
|
+
index = 1
|
129
|
+
$ie.images.each do |i|
|
130
|
+
assert_equal( $ie.image(:index, index).id , i.id )
|
131
|
+
assert_equal( $ie.image(:index, index).name , i.name )
|
132
|
+
assert_equal( $ie.image(:index, index).src , i.src )
|
133
|
+
assert_equal( $ie.image(:index, index).height , i.height )
|
134
|
+
assert_equal( $ie.image(:index, index).width , i.width )
|
135
|
+
|
136
|
+
index+=1
|
137
|
+
end
|
138
|
+
assert_equal( index-1 , $ie.images.length )
|
139
|
+
end
|
140
|
+
|
141
|
+
def test_save_local_image
|
142
|
+
gotoImagePage()
|
143
|
+
safe_file_block(1) do
|
144
|
+
assert(File.compare(@saved_img_path, $ie.images[1].src.gsub(/^file:\/\/\//, '')))
|
145
|
+
end
|
146
|
+
safe_file_block(2) do
|
147
|
+
assert(File.compare(@saved_img_path, $ie.images[2].src.gsub(/^file:\/\/\//, '')))
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
def test_save_local_image_returns_original_page
|
152
|
+
gotoImagePage()
|
153
|
+
safe_file_block(1) {}
|
154
|
+
assert_equal(6 , $ie.images.length)
|
155
|
+
end
|
156
|
+
|
157
|
+
def safe_file_block(*imgstosave)
|
158
|
+
clean_saved_image
|
159
|
+
begin
|
160
|
+
imgstosave.each {|imgidx| $ie.images[imgidx].save(build_windows_path("sample.img.dat"))}
|
161
|
+
yield
|
162
|
+
ensure
|
163
|
+
clean_saved_image
|
164
|
+
end
|
165
|
+
end
|
166
|
+
|
167
|
+
def clean_saved_image
|
168
|
+
File.unlink(@saved_img_path) if (File.exists?(@saved_img_path))
|
169
|
+
end
|
170
|
+
|
171
|
+
def build_windows_path(part)
|
172
|
+
build_path(part).gsub(/\//, "\\")
|
173
|
+
end
|
174
|
+
|
175
|
+
def build_path(part)
|
176
|
+
"#{$myDir}/#{part}"
|
177
|
+
end
|
178
|
+
end
|
179
|
+
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# class useful for testing output to stdout
|
2
|
+
class IOString < String
|
3
|
+
def write x
|
4
|
+
self.<< x
|
5
|
+
end
|
6
|
+
def readline!
|
7
|
+
line = slice!(/^.*(\n|$)/)
|
8
|
+
if $1 == "\n" then line.chop!
|
9
|
+
elsif line == "" then nil
|
10
|
+
else line
|
11
|
+
end
|
12
|
+
end
|
13
|
+
def puts( x )
|
14
|
+
stdout_orig = $stdout
|
15
|
+
$stdout = self
|
16
|
+
Kernel.puts x
|
17
|
+
$stdout = stdout_orig
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
module MockStdoutTestCase
|
22
|
+
def setup
|
23
|
+
@mockout = IOString.new ""
|
24
|
+
end
|
25
|
+
def teardown
|
26
|
+
$stdout = STDOUT
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# unit tests for IOString in iostring.rb
|
2
|
+
|
3
|
+
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') if $0 == __FILE__
|
4
|
+
require 'unittests/iostring'
|
5
|
+
require 'test/unit'
|
6
|
+
|
7
|
+
class IOStringTests < Test::Unit::TestCase
|
8
|
+
include MockStdoutTestCase
|
9
|
+
def setup
|
10
|
+
@mockout = IOString.new ""
|
11
|
+
$stdout = @mockout
|
12
|
+
end
|
13
|
+
def test_io_string_write
|
14
|
+
puts "hello"
|
15
|
+
assert_equal "hello\n", @mockout
|
16
|
+
end
|
17
|
+
def test_iostring_readline
|
18
|
+
puts "hello"
|
19
|
+
puts "there"
|
20
|
+
$stdout = STDOUT
|
21
|
+
assert_equal "hello", @mockout.readline!
|
22
|
+
assert_equal "there", @mockout.readline!
|
23
|
+
end
|
24
|
+
def test_iostring_realine_no_final_cr
|
25
|
+
print "hello"
|
26
|
+
$stdout = STDOUT
|
27
|
+
assert_equal "hello", @mockout.readline!
|
28
|
+
end
|
29
|
+
def test_ending_with_cr
|
30
|
+
puts "hello"
|
31
|
+
@mockout.readline!
|
32
|
+
assert_equal nil, @mockout.readline!
|
33
|
+
end
|
34
|
+
def test_ending_without_cr
|
35
|
+
print "hello"
|
36
|
+
@mockout.readline!
|
37
|
+
assert_equal nil, @mockout.readline!
|
38
|
+
end
|
39
|
+
def test_blank_line
|
40
|
+
puts "hello"
|
41
|
+
puts
|
42
|
+
puts "there"
|
43
|
+
@mockout.readline!
|
44
|
+
assert_equal "", @mockout.readline!
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
|