celerity 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (136) hide show
  1. data.tar.gz.sig +0 -0
  2. data/History.txt +14 -0
  3. data/Manifest.txt +127 -151
  4. data/README.txt +15 -20
  5. data/lib/celerity.rb +13 -5
  6. data/lib/celerity/browser.rb +296 -0
  7. data/lib/celerity/clickable_element.rb +1 -0
  8. data/lib/celerity/collections.rb +4 -0
  9. data/lib/celerity/container.rb +69 -2
  10. data/lib/celerity/disabled_element.rb +1 -0
  11. data/lib/celerity/element.rb +103 -38
  12. data/lib/celerity/element_collections.rb +14 -8
  13. data/lib/celerity/element_locator.rb +61 -50
  14. data/lib/celerity/element_map.rb +51 -0
  15. data/lib/celerity/elements/button.rb +1 -0
  16. data/lib/celerity/elements/file_field.rb +3 -2
  17. data/lib/celerity/elements/form.rb +1 -0
  18. data/lib/celerity/elements/frame.rb +16 -1
  19. data/lib/celerity/elements/image.rb +15 -13
  20. data/lib/celerity/elements/link.rb +4 -1
  21. data/lib/celerity/elements/option.rb +1 -0
  22. data/lib/celerity/elements/radio_check.rb +19 -7
  23. data/lib/celerity/elements/select_list.rb +17 -2
  24. data/lib/celerity/elements/table.rb +34 -20
  25. data/lib/celerity/elements/table_body.rb +2 -2
  26. data/lib/celerity/elements/table_cell.rb +3 -1
  27. data/lib/celerity/elements/table_footer.rb +2 -2
  28. data/lib/celerity/elements/table_header.rb +2 -2
  29. data/lib/celerity/elements/table_row.rb +4 -2
  30. data/lib/celerity/elements/text_field.rb +20 -9
  31. data/lib/celerity/exception.rb +11 -18
  32. data/lib/celerity/extra/method_generator.rb +13 -8
  33. data/lib/celerity/htmlunit/download.sh +23 -0
  34. data/lib/celerity/htmlunit/htmlunit-2.2.jar +0 -0
  35. data/lib/celerity/htmlunit/htmlunit-core-js-2.2.jar +0 -0
  36. data/lib/celerity/htmlunit/{nekohtml-1.9.7.jar → nekohtml-1.9.8.jar} +0 -0
  37. data/lib/celerity/input_element.rb +1 -1
  38. data/lib/celerity/version.rb +1 -1
  39. data/lib/celerity/watir_compatibility.rb +37 -23
  40. data/spec/area_spec.rb +19 -4
  41. data/spec/areas_spec.rb +2 -3
  42. data/spec/{ie_spec.rb → browser_spec.rb} +66 -15
  43. data/spec/button_spec.rb +36 -3
  44. data/spec/buttons_spec.rb +2 -3
  45. data/spec/checkbox_spec.rb +43 -8
  46. data/spec/checkboxes_spec.rb +2 -3
  47. data/spec/div_spec.rb +31 -4
  48. data/spec/divs_spec.rb +2 -3
  49. data/spec/element_spec.rb +36 -6
  50. data/spec/filefield_spec.rb +28 -13
  51. data/spec/filefields_spec.rb +2 -3
  52. data/spec/form_spec.rb +6 -3
  53. data/spec/forms_spec.rb +2 -3
  54. data/spec/frame_spec.rb +14 -5
  55. data/spec/frames_spec.rb +71 -0
  56. data/spec/hidden_spec.rb +21 -3
  57. data/spec/hiddens_spec.rb +2 -3
  58. data/spec/hn_spec.rb +30 -12
  59. data/spec/hns_spec.rb +14 -10
  60. data/spec/html/form_js_bug.html +11 -0
  61. data/spec/html/forms_with_input_elements.html +2 -1
  62. data/spec/html/invalid_js.html +11 -0
  63. data/spec/html/latin1_text.html +1 -0
  64. data/spec/html/non_control_elements.html +8 -4
  65. data/spec/html/simple_ajax.html +22 -0
  66. data/spec/htmlunit_spec.rb +4 -5
  67. data/spec/image_spec.rb +33 -3
  68. data/spec/images_spec.rb +2 -3
  69. data/spec/label_spec.rb +16 -3
  70. data/spec/labels_spec.rb +2 -3
  71. data/spec/li_spec.rb +25 -3
  72. data/spec/link_spec.rb +35 -3
  73. data/spec/links_spec.rb +2 -3
  74. data/spec/lis_spec.rb +2 -3
  75. data/spec/map_spec.rb +19 -3
  76. data/spec/maps_spec.rb +2 -3
  77. data/spec/meta_spec.rb +3 -1
  78. data/spec/ol_spec.rb +17 -3
  79. data/spec/ols_spec.rb +2 -3
  80. data/spec/option_spec.rb +28 -3
  81. data/spec/p_spec.rb +30 -2
  82. data/spec/pre_spec.rb +25 -3
  83. data/spec/pres_spec.rb +2 -3
  84. data/spec/ps_spec.rb +2 -3
  85. data/spec/radio_spec.rb +47 -3
  86. data/spec/radios_spec.rb +2 -3
  87. data/spec/select_list_spec.rb +42 -3
  88. data/spec/select_lists_spec.rb +2 -3
  89. data/spec/span_spec.rb +32 -7
  90. data/spec/spans_spec.rb +2 -4
  91. data/spec/spec_helper.rb +5 -25
  92. data/spec/table_bodies_spec.rb +7 -5
  93. data/spec/table_body_spec.rb +11 -4
  94. data/spec/table_cell_spec.rb +15 -4
  95. data/spec/table_cells_spec.rb +3 -4
  96. data/spec/table_footer_spec.rb +11 -4
  97. data/spec/table_footers_spec.rb +7 -5
  98. data/spec/table_header_spec.rb +11 -4
  99. data/spec/table_headers_spec.rb +7 -5
  100. data/spec/table_row_spec.rb +31 -7
  101. data/spec/table_rows_spec.rb +5 -4
  102. data/spec/table_spec.rb +36 -7
  103. data/spec/tables_spec.rb +2 -3
  104. data/spec/text_field_spec.rb +51 -13
  105. data/spec/text_fields_spec.rb +2 -3
  106. data/spec/ul_spec.rb +18 -3
  107. data/spec/uls_spec.rb +2 -3
  108. data/spec/{watir_compatability_spec.rb → watir_compatibility_spec.rb} +42 -35
  109. data/support/spec_server.rb +9 -0
  110. metadata +167 -161
  111. metadata.gz.sig +0 -0
  112. data/benchmark/bm_2000_spans.rb +0 -48
  113. data/benchmark/bm_digg.rb +0 -26
  114. data/benchmark/bm_google_images.rb +0 -36
  115. data/benchmark/bm_input_locator.rb +0 -69
  116. data/benchmark/loader.rb +0 -9
  117. data/config/hoe.rb +0 -68
  118. data/config/requirements.rb +0 -15
  119. data/lib/celerity/htmlunit/htmlunit-2.2-SNAPSHOT.jar +0 -0
  120. data/lib/celerity/htmlunit/js-1.7R1.jar +0 -0
  121. data/lib/celerity/ie.rb +0 -195
  122. data/setup.rb +0 -1583
  123. data/support/celerity_viewer/rubycocoa/CelerityViewer.icns +0 -0
  124. data/support/celerity_viewer/rubycocoa/English.lproj/Main.nib/classes.nib +0 -37
  125. data/support/celerity_viewer/rubycocoa/English.lproj/Main.nib/info.nib +0 -19
  126. data/support/celerity_viewer/rubycocoa/English.lproj/Main.nib/keyedobjects.nib +0 -0
  127. data/support/celerity_viewer/rubycocoa/Info.plist.erb +0 -28
  128. data/support/celerity_viewer/rubycocoa/MainController.rb +0 -23
  129. data/support/celerity_viewer/rubycocoa/README +0 -94
  130. data/support/celerity_viewer/rubycocoa/Rakefile +0 -100
  131. data/support/celerity_viewer/rubycocoa/distributed_viewer.rb +0 -86
  132. data/support/celerity_viewer/rubycocoa/main.m +0 -7
  133. data/support/celerity_viewer/rubycocoa/main.rb +0 -27
  134. data/tasks/benchmark.rake +0 -4
  135. data/tasks/environment.rake +0 -7
  136. data/tasks/simple_ci.rake +0 -94
@@ -1,10 +1,9 @@
1
1
  require File.dirname(__FILE__) + '/spec_helper.rb'
2
2
 
3
- describe Radios do
3
+ describe "Radios" do
4
4
 
5
5
  before :all do
6
- @browser = IE.new
7
- add_spec_checker(@browser)
6
+ @browser = Browser.new
8
7
  end
9
8
 
10
9
  before :each do
@@ -1,10 +1,9 @@
1
1
  require File.dirname(__FILE__) + '/spec_helper.rb'
2
2
 
3
- describe SelectList do
3
+ describe "SelectList" do
4
4
 
5
5
  before :all do
6
- @browser = Celerity::IE.new
7
- add_spec_checker(@browser)
6
+ @browser = Browser.new
8
7
  end
9
8
 
10
9
  before :each do
@@ -28,9 +27,11 @@ describe SelectList do
28
27
  @browser.select_list(:index, 1).should exist
29
28
  @browser.select_list(:xpath, "//select[@id='new_user_country']").should exist
30
29
  end
30
+
31
31
  it "should return true if the element exists (default how = :name)" do
32
32
  @browser.select_list("new_user_country").should exist
33
33
  end
34
+
34
35
  it "should return false if the select list doesn't exist" do
35
36
  @browser.select_list(:id, 'no_such_id').should_not exist
36
37
  @browser.select_list(:id, /no_such_id/).should_not exist
@@ -45,9 +46,11 @@ describe SelectList do
45
46
  @browser.select_list(:index, 1337).should_not exist
46
47
  @browser.select_list(:xpath, "//select[@id='no_such_id']").should_not exist
47
48
  end
49
+
48
50
  it "should raise ArgumentError when 'what' argument is invalid" do
49
51
  lambda { @browser.select_list(:id, 3.14).exists? }.should raise_error(ArgumentError)
50
52
  end
53
+
51
54
  it "should raise MissingWayOfFindingObjectException when 'how' argument is invalid" do
52
55
  lambda { @browser.select_list(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
53
56
  end
@@ -59,6 +62,7 @@ describe SelectList do
59
62
  it "should return the class name of the select list" do
60
63
  @browser.select_list(:name, 'new_user_country').class_name.should == 'country'
61
64
  end
65
+
62
66
  it "should raise UnknownObjectException if the select list doesn't exist" do
63
67
  lambda { @browser.select_list(:name, 'no_such_name').class_name }.should raise_error(UnknownObjectException)
64
68
  end
@@ -68,6 +72,7 @@ describe SelectList do
68
72
  it "should return the id of the element" do
69
73
  @browser.select_list(:index, 1).id.should == "new_user_country"
70
74
  end
75
+
71
76
  it "should raise UnknownObjectException if the select list doesn't exist" do
72
77
  lambda { @browser.select_list(:index, 1337).id }.should raise_error(UnknownObjectException)
73
78
  end
@@ -77,6 +82,7 @@ describe SelectList do
77
82
  it "should return the name of the element" do
78
83
  @browser.select_list(:index, 1).name.should == "new_user_country"
79
84
  end
85
+
80
86
  it "should raise UnknownObjectException if the select list doesn't exist" do
81
87
  lambda { @browser.select_list(:index, 1337).name }.should raise_error(UnknownObjectException)
82
88
  end
@@ -87,6 +93,7 @@ describe SelectList do
87
93
  @browser.select_list(:index, 1).type.should == "select-one"
88
94
  @browser.select_list(:index, 2).type.should == "select-multiple"
89
95
  end
96
+
90
97
  it "should raise UnknownObjectException if the select list doesn't exist" do
91
98
  lambda { @browser.select_list(:index, 1337).type }.should raise_error(UnknownObjectException)
92
99
  end
@@ -98,19 +105,33 @@ describe SelectList do
98
105
  @browser.select_list(:index, 1).select(/Sweden/)
99
106
  @browser.select_list(:index, 1).value.should == "3"
100
107
  end
108
+
101
109
  it "should raise UnknownObjectException if the select list doesn't exist" do
102
110
  lambda { @browser.select_list(:index, 1337).value }.should raise_error(UnknownObjectException)
103
111
  end
104
112
  end
105
113
 
114
+ describe "#respond_to?" do
115
+ it "should return true for all attribute methods" do
116
+ @browser.select_list(:index, 1).should respond_to(:class_name)
117
+ @browser.select_list(:index, 1).should respond_to(:id)
118
+ @browser.select_list(:index, 1).should respond_to(:name)
119
+ @browser.select_list(:index, 1).should respond_to(:type)
120
+ @browser.select_list(:index, 1).should respond_to(:value)
121
+ end
122
+ end
123
+
124
+
106
125
  # Access methods
107
126
  describe "#enabled?" do
108
127
  it "should return true if the select list is enabled" do
109
128
  @browser.select_list(:name, 'new_user_country').should be_enabled
110
129
  end
130
+
111
131
  it "should return false if the select list is disabled" do
112
132
  @browser.select_list(:name, 'new_user_role').should_not be_enabled
113
133
  end
134
+
114
135
  it "should raise UnknownObjectException if the select_list doesn't exist" do
115
136
  lambda { @browser.select_list(:name, 'no_such_name').enabled? }.should raise_error(UnknownObjectException)
116
137
  end
@@ -120,9 +141,11 @@ describe SelectList do
120
141
  it "should return true if the select list is disabled" do
121
142
  @browser.select_list(:index, 3).should be_disabled
122
143
  end
144
+
123
145
  it "should return false if the select list is enabled" do
124
146
  @browser.select_list(:index, 1).should_not be_disabled
125
147
  end
148
+
126
149
  it "should should raise UnknownObjectException when the select list does not exist" do
127
150
  lambda { @browser.select_list(:index, 1337).disabled? }.should raise_error(UnknownObjectException)
128
151
  end
@@ -141,6 +164,7 @@ describe SelectList do
141
164
  it "should should raise UnknownObjectException if the select list doesn't exist" do
142
165
  lambda { @browser.select_list(:name, 'no_such_name').get_all_contents }.should raise_error(UnknownObjectException)
143
166
  end
167
+
144
168
  it "should return all the options as an Array" do
145
169
  @browser.select_list(:name, "new_user_country").get_all_contents.should == ["Denmark" ,"Norway" , "Sweden" , "United Kingdom", "USA"]
146
170
  end
@@ -150,6 +174,7 @@ describe SelectList do
150
174
  it "should should raise UnknownObjectException if the select list doesn't exist" do
151
175
  lambda { @browser.select_list(:name, 'no_such_name').get_selected_items }.should raise_error(UnknownObjectException)
152
176
  end
177
+
153
178
  it "should get the currently selected item(s)" do
154
179
  @browser.select_list(:name, "new_user_country").get_selected_items.should == ["Norway"]
155
180
  @browser.select_list(:name, "new_user_languages").get_selected_items.should == ["English", "Norwegian"]
@@ -161,10 +186,12 @@ describe SelectList do
161
186
  @browser.select_list(:name, "new_user_languages").clear_selection
162
187
  @browser.select_list(:name, "new_user_languages").get_selected_items.should be_empty
163
188
  end
189
+
164
190
  it "should not clear selections when not possible" do
165
191
  @browser.select_list(:name , "new_user_country").clear_selection
166
192
  @browser.select_list(:name, "new_user_country").get_selected_items.should == ["Norway"]
167
193
  end
194
+
168
195
  it "should should raise UnknownObjectException if the select list doesn't exist" do
169
196
  lambda { @browser.select_list(:name, 'no_such_name').clear_selection }.should raise_error(UnknownObjectException)
170
197
  end
@@ -174,6 +201,7 @@ describe SelectList do
174
201
  it "should return true if the given option exists" do
175
202
  @browser.select_list(:name, 'new_user_country').includes?('Denmark').should be_true
176
203
  end
204
+
177
205
  it "should return false if the given option doesn't exist" do
178
206
  @browser.select_list(:name, 'new_user_country').includes?('Ireland').should be_false
179
207
  end
@@ -184,9 +212,11 @@ describe SelectList do
184
212
  @browser.select_list(:name, 'new_user_country').select('Denmark')
185
213
  @browser.select_list(:name, 'new_user_country').selected?('Denmark').should be_true
186
214
  end
215
+
187
216
  it "should return false if the given option is not selected" do
188
217
  @browser.select_list(:name, 'new_user_country').selected?('Sweden').should be_false
189
218
  end
219
+
190
220
  it "should raise UnknonwObjectException if the option doesn't exist" do
191
221
  lambda { @browser.select_list(:name, 'new_user_country').selected?('missing_option') }.should raise_error(UnknownObjectException)
192
222
  end
@@ -197,36 +227,43 @@ describe SelectList do
197
227
  @browser.select_list(:name, "new_user_country").select("Denmark")
198
228
  @browser.select_list(:name, "new_user_country").get_selected_items.should == ["Denmark"]
199
229
  end
230
+
200
231
  it "should select the given item when given a Regexp" do
201
232
  @browser.select_list(:name, "new_user_country").select(/Denmark/)
202
233
  @browser.select_list(:name, "new_user_country").get_selected_items.should == ["Denmark"]
203
234
  end
235
+
204
236
  it "should select the given item when given an Xpath" do
205
237
  @browser.select_list(:xpath, "//select[@name='new_user_country']").select("Denmark")
206
238
  @browser.select_list(:xpath, "//select[@name='new_user_country']").get_selected_items.should == ["Denmark"]
207
239
  end
240
+
208
241
  it "should be able to select multiple items using :name and a String" do
209
242
  @browser.select_list(:name, "new_user_languages").clear_selection
210
243
  @browser.select_list(:name, "new_user_languages").select("Danish")
211
244
  @browser.select_list(:name, "new_user_languages").select("Swedish")
212
245
  @browser.select_list(:name, "new_user_languages").get_selected_items.should == ["Danish", "Swedish"]
213
246
  end
247
+
214
248
  it "should be able to select multiple items using :name and a Regexp" do
215
249
  @browser.select_list(:name, "new_user_languages").clear_selection
216
250
  @browser.select_list(:name, "new_user_languages").select(/ish/)
217
251
  @browser.select_list(:name, "new_user_languages").get_selected_items.should == ["Danish", "English", "Swedish"]
218
252
  end
253
+
219
254
  it "should be able to select multiple items using :xpath" do
220
255
  @browser.select_list(:xpath, "//select[@name='new_user_languages']").clear_selection
221
256
  @browser.select_list(:xpath, "//select[@name='new_user_languages']").select(/ish/)
222
257
  @browser.select_list(:xpath, "//select[@name='new_user_languages']").get_selected_items.should == ["Danish", "English", "Swedish"]
223
258
  end
259
+
224
260
  it "should fire onchange event when selecting an item" do
225
261
  @browser.div(:id, "changed_language").text.should be_empty
226
262
  @browser.select_list(:id, "new_user_languages").select("Danish")
227
263
  @browser.div(:id, "changed_language").text.should == "changed language"
228
264
  @browser.refresh # to reset js
229
265
  end
266
+
230
267
  it "should not fire onchange event when selecting an already selected item" do
231
268
  @browser.select_list(:id, "new_user_languages").clear_selection # removes the two pre-selected options
232
269
  @browser.div(:id, "changed_language").text.should == "changed languagechanged language"
@@ -235,6 +272,7 @@ describe SelectList do
235
272
  @browser.select_list(:id, "new_user_languages").select("English")
236
273
  @browser.div(:id, "changed_language").text.should == "changed languagechanged languagechanged language"
237
274
  end
275
+
238
276
  it "should raise NoValueFoundException if the option doesn't exist" do
239
277
  lambda { @browser.select_list(:name, "new_user_country").select("missing_option") }.should raise_error(NoValueFoundException)
240
278
  lambda { @browser.select_list(:name, "new_user_country").select(/missing_option/) }.should raise_error(NoValueFoundException)
@@ -247,6 +285,7 @@ describe SelectList do
247
285
  @browser.select_list(:name, "new_user_languages").select("Swedish")
248
286
  @browser.select_list(:name, "new_user_languages").get_selected_items.should == ["Swedish"]
249
287
  end
288
+
250
289
  it "should raise NoValueFoundException if the option doesn't exist" do
251
290
  lambda { @browser.select_list(:name, "new_user_languages").select_value("no_such_option") }.should raise_error(NoValueFoundException)
252
291
  lambda { @browser.select_list(:name, "new_user_languages").select_value(/no_such_option/) }.should raise_error(NoValueFoundException)
@@ -1,10 +1,9 @@
1
1
  require File.dirname(__FILE__) + '/spec_helper.rb'
2
2
 
3
- describe SelectLists do
3
+ describe "SelectLists" do
4
4
 
5
5
  before :all do
6
- @browser = Celerity::IE.new
7
- add_spec_checker(@browser)
6
+ @browser = Browser.new
8
7
  end
9
8
 
10
9
  before :each do
@@ -1,10 +1,9 @@
1
1
  require File.dirname(__FILE__) + '/spec_helper.rb'
2
2
 
3
- describe Span do
3
+ describe "Span" do
4
4
 
5
5
  before :all do
6
- @browser = IE.new
7
- add_spec_checker(@browser)
6
+ @browser = Browser.new
8
7
  end
9
8
 
10
9
  before :each do
@@ -23,9 +22,11 @@ describe Span do
23
22
  @browser.span(:index, 1).should exist
24
23
  @browser.span(:xpath, "//span[@id='lead']").should exist
25
24
  end
25
+
26
26
  it "should return true if the element exists (default how = :id)" do
27
27
  @browser.span("lead").should exist
28
28
  end
29
+
29
30
  it "should return false if the 'p' doesn't exist" do
30
31
  @browser.span(:id, "no_such_id").should_not exist
31
32
  @browser.span(:id, /no_such_id/).should_not exist
@@ -36,9 +37,11 @@ describe Span do
36
37
  @browser.span(:index, 1337).should_not exist
37
38
  @browser.span(:xpath, "//span[@id='no_such_id']").should_not exist
38
39
  end
40
+
39
41
  it "should raise ArgumentError when 'what' argument is invalid" do
40
42
  lambda { @browser.span(:id, 3.14).exists? }.should raise_error(ArgumentError)
41
43
  end
44
+
42
45
  it "should raise MissingWayOfFindingObjectException when 'how' argument is invalid" do
43
46
  lambda { @browser.span(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
44
47
  end
@@ -49,9 +52,11 @@ describe Span do
49
52
  it "should return the class attribute" do
50
53
  @browser.span(:index, 1).class_name.should == 'lead'
51
54
  end
55
+
52
56
  it "should return an empty string if the element exists and the attribute doesn't" do
53
57
  @browser.span(:index, 3).class_name.should == ''
54
58
  end
59
+
55
60
  it "should raise UnknownObjectException if the span doesn't exist" do
56
61
  lambda { @browser.span(:id, 'no_such_id').class_name }.should raise_error(UnknownObjectException)
57
62
  end
@@ -61,9 +66,11 @@ describe Span do
61
66
  it "should return the id attribute" do
62
67
  @browser.span(:index, 1).id.should == "lead"
63
68
  end
69
+
64
70
  it "should return an empty string if the element exists and the attribute doesn't" do
65
71
  @browser.span(:index, 3).id.should == ''
66
72
  end
73
+
67
74
  it "should raise UnknownObjectException if the span doesn't exist" do
68
75
  lambda { @browser.span(:id, "no_such_id").id }.should raise_error(UnknownObjectException)
69
76
  lambda { @browser.span(:index, 1337).id }.should raise_error(UnknownObjectException)
@@ -74,9 +81,11 @@ describe Span do
74
81
  it "should return the name attribute" do
75
82
  @browser.span(:index, 2).name.should == "invalid_attribute"
76
83
  end
84
+
77
85
  it "should return an empty string if the element exists and the attribute doesn't" do
78
86
  @browser.span(:index, 3).name.should == ''
79
87
  end
88
+
80
89
  it "should raise UnknownObjectException if the span doesn't exist" do
81
90
  lambda { @browser.span(:id, "no_such_id").name }.should raise_error(UnknownObjectException)
82
91
  lambda { @browser.span(:index, 1337).name }.should raise_error(UnknownObjectException)
@@ -87,9 +96,11 @@ describe Span do
87
96
  it "should return the title attribute" do
88
97
  @browser.span(:index, 1).title.should == 'Lorem ipsum'
89
98
  end
99
+
90
100
  it "should return an empty string if the element exists and the attribute doesn't" do
91
101
  @browser.span(:index, 3).title.should == ''
92
102
  end
103
+
93
104
  it "should raise UnknownObjectException if the span doesn't exist" do
94
105
  lambda { @browser.span(:id, 'no_such_id').title }.should raise_error( UnknownObjectException)
95
106
  lambda { @browser.span(:xpath, "//span[@id='no_such_id']").title }.should raise_error( UnknownObjectException)
@@ -100,9 +111,11 @@ describe Span do
100
111
  it "should return the text of the span" do
101
112
  @browser.span(:index, 2).text.should == 'Sed pretium metus et quam. Nullam odio dolor, vestibulum non, tempor ut, vehicula sed, sapien. Vestibulum placerat ligula at quam. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.'
102
113
  end
114
+
103
115
  it "should return an empty string if the element doesn't contain any text" do
104
116
  @browser.span(:index, 5).text.should == ''
105
117
  end
118
+
106
119
  it "should raise UnknownObjectException if the p doesn't exist" do
107
120
  lambda { @browser.span(:id, 'no_such_id').text }.should raise_error( UnknownObjectException)
108
121
  lambda { @browser.span(:xpath , "//span[@id='no_such_id']").text }.should raise_error( UnknownObjectException)
@@ -113,14 +126,28 @@ describe Span do
113
126
  it "should return the value attribute" do
114
127
  @browser.span(:index, 2).value.should == "invalid_attribute"
115
128
  end
129
+
116
130
  it "should return an empty string if the element exists and the attribute doesn't" do
117
131
  @browser.span(:index, 3).value.should == ''
118
132
  end
133
+
119
134
  it "should raise UnknownObjectException if the span doesn't exist" do
120
135
  lambda { @browser.span(:id , "no_such_id").value }.should raise_error(UnknownObjectException)
121
136
  lambda { @browser.span(:index , 1337).value }.should raise_error(UnknownObjectException)
122
137
  end
123
138
  end
139
+
140
+ describe "#respond_to?" do
141
+ it "should return true for all attribute methods" do
142
+ @browser.image(:index, 1).should respond_to(:class_name)
143
+ @browser.image(:index, 1).should respond_to(:id)
144
+ @browser.image(:index, 1).should respond_to(:name)
145
+ @browser.image(:index, 1).should respond_to(:title)
146
+ @browser.image(:index, 1).should respond_to(:text)
147
+ @browser.image(:index, 1).should respond_to(:value)
148
+ end
149
+ end
150
+
124
151
 
125
152
  # Other
126
153
  describe "#click" do
@@ -129,6 +156,7 @@ describe Span do
129
156
  @browser.span(:name, 'footer').click
130
157
  @browser.span(:name, 'footer').text.should include('Javascript')
131
158
  end
159
+
132
160
  it "should raise UnknownObjectException if the span doesn't exist" do
133
161
  lambda { @browser.span(:id, "no_such_id").click }.should raise_error(UnknownObjectException)
134
162
  lambda { @browser.span(:title, "no_such_title").click }.should raise_error(UnknownObjectException)
@@ -142,15 +170,12 @@ describe Span do
142
170
  " value: invalid_attribute\n" +
143
171
  " text: Sed pretium metus et quam. Nullam odio dolor, vestibulum non, tempor ut, vehicula sed, sapien. Vestibulum placerat ligula at quam. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas."
144
172
  end
173
+
145
174
  it "should raise UnknownObjectException if the p doesn't exist" do
146
175
  lambda { @browser.span(:xpath, "//span[@id='no_such_id']").to_s }.should raise_error( UnknownObjectException)
147
176
  end
148
177
  end
149
178
 
150
-
151
-
152
-
153
-
154
179
  after :all do
155
180
  @browser.close
156
181
  end
@@ -1,17 +1,15 @@
1
1
  require File.dirname(__FILE__) + '/spec_helper.rb'
2
2
 
3
- describe Spans do
3
+ describe "Spans" do
4
4
 
5
5
  before :all do
6
- @browser = IE.new
7
- add_spec_checker(@browser)
6
+ @browser = Browser.new
8
7
  end
9
8
 
10
9
  before :each do
11
10
  @browser.goto(TEST_HOST + "/non_control_elements.html")
12
11
  end
13
12
 
14
-
15
13
  describe "#length" do
16
14
  it "should return the number of spans" do
17
15
  @browser.spans.length.should == 6
@@ -42,34 +42,14 @@ if RUBY_PLATFORM =~ /java/ || ENV['WATIR_SPEC']
42
42
  # cleaner way to do this?
43
43
  require File.dirname(__FILE__) + "/../support/spec_server"
44
44
  s = Celerity::SpecServer.new
45
- s.run
45
+ begin
46
+ s.run
47
+ rescue Errno::EADDRINUSE
48
+ end
46
49
  TEST_HOST = s.host
47
50
  end
51
+ # TEST_HOST = "file://#{File.dirname(__FILE__)}/html"
48
52
  else
49
53
  puts "Remember to run \"rake specserver\" before running these tests!"
50
54
  TEST_HOST = "http://localhost:2000"
51
55
  end
52
-
53
- # ===========================
54
- # = RubyCocoa CelerityViewer =
55
- # ===========================
56
- begin
57
- if `uname`.chomp == "Darwin" && `ps ax`[/CelerityViewer/]
58
- WEB_VIEWER = DRbObject.new_with_uri("druby://127.0.0.1:1337")
59
- end
60
- rescue IOError, Errno::ENOENT
61
- end
62
-
63
- # ================
64
- # = Spec Checker =
65
- # ================
66
-
67
- # define a checker that is run on every page
68
- def add_spec_checker(browser)
69
- if defined? WEB_VIEWER
70
- browser.add_checker { WEB_VIEWER.render_html(browser.html, browser.base_url) }
71
- end
72
- end
73
-
74
-
75
-