celerity 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (93) hide show
  1. data/History.txt +10 -0
  2. data/README.txt +8 -11
  3. data/Rakefile +5 -3
  4. data/benchmark/bm_2000_spans.rb +48 -0
  5. data/benchmark/bm_digg.rb +26 -0
  6. data/benchmark/bm_google_images.rb +36 -0
  7. data/benchmark/bm_input_locator.rb +69 -0
  8. data/benchmark/loader.rb +9 -0
  9. data/lib/celerity.rb +3 -1
  10. data/lib/celerity/container.rb +23 -171
  11. data/lib/celerity/disabled_element.rb +1 -1
  12. data/lib/celerity/element.rb +78 -47
  13. data/lib/celerity/element_collections.rb +16 -32
  14. data/lib/celerity/element_locator.rb +135 -0
  15. data/lib/celerity/elements/button.rb +15 -0
  16. data/lib/celerity/elements/file_field.rb +1 -1
  17. data/lib/celerity/elements/form.rb +2 -1
  18. data/lib/celerity/elements/frame.rb +18 -21
  19. data/lib/celerity/elements/image.rb +2 -8
  20. data/lib/celerity/elements/label.rb +1 -3
  21. data/lib/celerity/elements/link.rb +1 -1
  22. data/lib/celerity/elements/option.rb +16 -0
  23. data/lib/celerity/elements/radio_check.rb +18 -7
  24. data/lib/celerity/elements/select_list.rb +1 -17
  25. data/lib/celerity/elements/table.rb +4 -4
  26. data/lib/celerity/elements/table_body.rb +6 -8
  27. data/lib/celerity/elements/table_cell.rb +3 -14
  28. data/lib/celerity/elements/table_row.rb +4 -10
  29. data/lib/celerity/elements/text_field.rb +16 -4
  30. data/lib/celerity/extra/method_generator.rb +144 -0
  31. data/lib/celerity/identifier.rb +10 -0
  32. data/lib/celerity/ie.rb +28 -13
  33. data/lib/celerity/input_element.rb +0 -4
  34. data/lib/celerity/non_control_elements.rb +12 -12
  35. data/lib/celerity/version.rb +1 -1
  36. data/spec/area_spec.rb +41 -41
  37. data/spec/areas_spec.rb +11 -11
  38. data/spec/button_spec.rb +73 -68
  39. data/spec/buttons_spec.rb +10 -10
  40. data/spec/checkbox_spec.rb +102 -96
  41. data/spec/checkboxes_spec.rb +10 -10
  42. data/spec/div_spec.rb +78 -73
  43. data/spec/divs_spec.rb +10 -10
  44. data/spec/element_spec.rb +20 -11
  45. data/spec/filefield_spec.rb +36 -41
  46. data/spec/filefields_spec.rb +10 -10
  47. data/spec/form_spec.rb +29 -29
  48. data/spec/forms_spec.rb +11 -11
  49. data/spec/frame_spec.rb +54 -49
  50. data/spec/hidden_spec.rb +43 -43
  51. data/spec/hiddens_spec.rb +10 -10
  52. data/spec/html/2000_spans.html +2009 -0
  53. data/spec/html/forms_with_input_elements.html +15 -9
  54. data/spec/html/non_control_elements.html +4 -2
  55. data/spec/ie_spec.rb +82 -48
  56. data/spec/image_spec.rb +83 -100
  57. data/spec/images_spec.rb +10 -10
  58. data/spec/label_spec.rb +29 -29
  59. data/spec/labels_spec.rb +10 -10
  60. data/spec/li_spec.rb +41 -41
  61. data/spec/link_spec.rb +65 -59
  62. data/spec/links_spec.rb +11 -11
  63. data/spec/lis_spec.rb +10 -10
  64. data/spec/map_spec.rb +30 -30
  65. data/spec/maps_spec.rb +10 -10
  66. data/spec/p_spec.rb +49 -49
  67. data/spec/pre_spec.rb +41 -41
  68. data/spec/pres_spec.rb +10 -10
  69. data/spec/ps_spec.rb +10 -10
  70. data/spec/radio_spec.rb +104 -97
  71. data/spec/radios_spec.rb +11 -11
  72. data/spec/select_list_spec.rb +118 -106
  73. data/spec/select_lists_spec.rb +15 -15
  74. data/spec/span_spec.rb +54 -54
  75. data/spec/spans_spec.rb +11 -11
  76. data/spec/spec.opts +1 -1
  77. data/spec/spec_helper.rb +23 -3
  78. data/spec/table_bodies.rb +8 -8
  79. data/spec/table_bodies_spec.rb +9 -9
  80. data/spec/table_body_spec.rb +28 -27
  81. data/spec/table_cell_spec.rb +25 -25
  82. data/spec/table_cells_spec.rb +16 -16
  83. data/spec/table_row_spec.rb +16 -16
  84. data/spec/table_rows_spec.rb +12 -12
  85. data/spec/table_spec.rb +36 -36
  86. data/spec/tables_spec.rb +12 -12
  87. data/spec/text_field_spec.rb +111 -92
  88. data/spec/text_fields_spec.rb +13 -13
  89. data/tasks/benchmark.rake +3 -0
  90. data/tasks/rspec.rake +2 -2
  91. data/tasks/testserver.rake +15 -0
  92. metadata +58 -46
  93. data/tasks/simple_ci.rake +0 -94
@@ -5,55 +5,60 @@ require File.dirname(__FILE__) + '/spec_helper.rb'
5
5
  describe "TextField" do
6
6
 
7
7
  before :all do
8
- @ie = IE.new
9
- add_spec_checker(@ie)
8
+ @browser = IE.new
9
+ add_spec_checker(@browser)
10
10
  end
11
11
 
12
12
  before :each do
13
- @ie.goto(TEST_HOST + "/forms_with_input_elements.html")
13
+ @browser.goto(TEST_HOST + "/forms_with_input_elements.html")
14
14
  end
15
15
 
16
16
  # Exist method
17
17
  describe "#exists?" do
18
18
  it "should return true if the element exists" do
19
- @ie.text_field(:id, 'new_user_email').should exist
20
- @ie.text_field(:id, /new_user_email/).should exist
21
- @ie.text_field(:name, 'new_user_email').should exist
22
- @ie.text_field(:name, /new_user_email/).should exist
23
- @ie.text_field(:value, 'Developer').should exist
24
- @ie.text_field(:value, /Developer/).should exist
25
- @ie.text_field(:text, 'Developer').should exist
26
- @ie.text_field(:text, /Developer/).should exist
27
- @ie.text_field(:class, 'name').should exist
28
- @ie.text_field(:class, /name/).should exist
29
- @ie.text_field(:index, 1).should exist
30
- @ie.text_field(:xpath, "//input[@id='new_user_email']").should exist
19
+ @browser.text_field(:id, 'new_user_email').should exist
20
+ @browser.text_field(:id, /new_user_email/).should exist
21
+ @browser.text_field(:name, 'new_user_email').should exist
22
+ @browser.text_field(:name, /new_user_email/).should exist
23
+ @browser.text_field(:value, 'Developer').should exist
24
+ @browser.text_field(:value, /Developer/).should exist
25
+ @browser.text_field(:text, 'Developer').should exist
26
+ @browser.text_field(:text, /Developer/).should exist
27
+ @browser.text_field(:class, 'name').should exist
28
+ @browser.text_field(:class, /name/).should exist
29
+ @browser.text_field(:index, 1).should exist
30
+ @browser.text_field(:xpath, "//input[@id='new_user_email']").should exist
31
31
  end
32
- it "should retun true if the element exists (no type attribute)" do
33
- @ie.text_field(:id, 'new_user_first_name').should exist
32
+
33
+ it "should return true if the element exists (no type attribute)" do
34
+ @browser.text_field(:id, 'new_user_first_name').should exist
34
35
  end
35
- it "should retun true if the element exists (invalid type attribute)" do
36
- @ie.text_field(:id, 'new_user_last_name').should exist
36
+
37
+ it "should return true if the element exists (invalid type attribute)" do
38
+ @browser.text_field(:id, 'new_user_last_name').should exist
37
39
  end
40
+
38
41
  it "should return false if the element does not exist" do
39
- @ie.text_field(:id, 'no_such_id').should_not exist
40
- @ie.text_field(:id, /no_such_id/).should_not exist
41
- @ie.text_field(:name, 'no_such_name').should_not exist
42
- @ie.text_field(:name, /no_such_name/).should_not exist
43
- @ie.text_field(:value, 'no_such_value').should_not exist
44
- @ie.text_field(:value, /no_such_value/).should_not exist
45
- @ie.text_field(:text, 'no_such_text').should_not exist
46
- @ie.text_field(:text, /no_such_text/).should_not exist
47
- @ie.text_field(:class, 'no_such_class').should_not exist
48
- @ie.text_field(:class, /no_such_class/).should_not exist
49
- @ie.text_field(:index, 1337).should_not exist
50
- @ie.text_field(:xpath, "//input[@id='no_such_id']").should_not exist
42
+ @browser.text_field(:id, 'no_such_id').should_not exist
43
+ @browser.text_field(:id, /no_such_id/).should_not exist
44
+ @browser.text_field(:name, 'no_such_name').should_not exist
45
+ @browser.text_field(:name, /no_such_name/).should_not exist
46
+ @browser.text_field(:value, 'no_such_value').should_not exist
47
+ @browser.text_field(:value, /no_such_value/).should_not exist
48
+ @browser.text_field(:text, 'no_such_text').should_not exist
49
+ @browser.text_field(:text, /no_such_text/).should_not exist
50
+ @browser.text_field(:class, 'no_such_class').should_not exist
51
+ @browser.text_field(:class, /no_such_class/).should_not exist
52
+ @browser.text_field(:index, 1337).should_not exist
53
+ @browser.text_field(:xpath, "//input[@id='no_such_id']").should_not exist
51
54
  end
52
- it "should raise ArgumentError when what argument is invalid" do
53
- lambda { @ie.text_field(:id, 3.14).exists? }.should raise_error(ArgumentError)
55
+
56
+ it "should raise ArgumentError when 'what' argument is invalid" do
57
+ lambda { @browser.text_field(:id, 3.14).exists? }.should raise_error(ArgumentError)
54
58
  end
55
- it "should raise MissingWayOfFindingObjectException when how argument is invalid" do
56
- lambda { @ie.text_field(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
59
+
60
+ it "should raise MissingWayOfFindingObjectException when 'how' argument is invalid" do
61
+ lambda { @browser.text_field(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
57
62
  end
58
63
  end
59
64
 
@@ -61,82 +66,82 @@ describe "TextField" do
61
66
  # Attribute methods
62
67
  describe "#id" do
63
68
  it "should return the id attribute if the text field exists" do
64
- @ie.text_field(:index, 4).id.should == "new_user_occupation"
69
+ @browser.text_field(:index, 4).id.should == "new_user_occupation"
65
70
  end
66
71
  it "should raise UnknownObjectException if the text field doesn't exist" do
67
- lambda { @ie.text_field(:index, 1337).id }.should raise_error(UnknownObjectException)
72
+ lambda { @browser.text_field(:index, 1337).id }.should raise_error(UnknownObjectException)
68
73
  end
69
74
  end
70
75
 
71
76
  describe "#name" do
72
77
  it "should return the name attribute if the text field exists" do
73
- @ie.text_field(:index, 4).name.should == "new_user_occupation"
78
+ @browser.text_field(:index, 4).name.should == "new_user_occupation"
74
79
  end
75
80
  it "should raise UnknownObjectException if the text field doesn't exist" do
76
- lambda { @ie.text_field(:index, 1337).name }.should raise_error(UnknownObjectException)
81
+ lambda { @browser.text_field(:index, 1337).name }.should raise_error(UnknownObjectException)
77
82
  end
78
83
  end
79
84
 
80
85
  describe "#title" do
81
86
  it "should return the title attribute if the text field exists" do
82
- @ie.text_field(:id, "new_user_code").title.should == "Your personal code"
87
+ @browser.text_field(:id, "new_user_code").title.should == "Your personal code"
83
88
  end
84
89
  it "should raise UnknownObjectException if the text field doesn't exist" do
85
- lambda { @ie.text_field(:index, 1337).title }.should raise_error(UnknownObjectException)
90
+ lambda { @browser.text_field(:index, 1337).title }.should raise_error(UnknownObjectException)
86
91
  end
87
92
  end
88
93
 
89
94
  describe "#type" do
90
95
  #TODO: What if the type attribute is non-existent or invalid?
91
96
  it "should return the type attribute if the text field exists" do
92
- @ie.text_field(:index, 4).type.should == "text"
97
+ @browser.text_field(:index, 4).type.should == "text"
93
98
  end
94
99
  it "should raise UnknownObjectException if the text field doesn't exist" do
95
- lambda { @ie.text_field(:index, 1337).type }.should raise_error(UnknownObjectException)
100
+ lambda { @browser.text_field(:index, 1337).type }.should raise_error(UnknownObjectException)
96
101
  end
97
102
  end
98
103
 
99
104
  describe "#value" do
100
105
  it "should return the value attribute if the text field exists" do
101
- @ie.text_field(:name, "new_user_occupation").value.should == "Developer"
102
- @ie.text_field(:index, 4).value.should == "Developer"
103
- @ie.text_field(:name, /new_user_occupation/i).value.should == "Developer"
106
+ @browser.text_field(:name, "new_user_occupation").value.should == "Developer"
107
+ @browser.text_field(:index, 4).value.should == "Developer"
108
+ @browser.text_field(:name, /new_user_occupation/i).value.should == "Developer"
104
109
  end
105
110
  it "should raise UnknownObjectException if the text field doesn't exist" do
106
- lambda { @ie.text_field(:index, 1337).value }.should raise_error(UnknownObjectException)
111
+ lambda { @browser.text_field(:index, 1337).value }.should raise_error(UnknownObjectException)
107
112
  end
108
113
  end
109
114
 
110
115
  # Access methods
111
116
  describe "#enabled?" do
112
117
  it "should return true for enabled text fields" do
113
- @ie.text_field(:name, "new_user_occupation").should be_enabled
114
- @ie.text_field(:id, "new_user_email").should be_enabled
118
+ @browser.text_field(:name, "new_user_occupation").should be_enabled
119
+ @browser.text_field(:id, "new_user_email").should be_enabled
115
120
  end
116
121
  it "should return false for disabled text fields" do
117
- @ie.text_field(:name, "new_user_species").should_not be_enabled
122
+ @browser.text_field(:name, "new_user_species").should_not be_enabled
118
123
  end
119
124
  end
120
125
 
121
126
  describe "#disabled?" do
122
127
  it "should return true if the text field is disabled" do
123
- @ie.text_field(:id, 'new_user_species').should be_disabled
128
+ @browser.text_field(:id, 'new_user_species').should be_disabled
124
129
  end
125
130
  it "should return false if the text field is enabled" do
126
- @ie.text_field(:index, 1).should_not be_disabled
131
+ @browser.text_field(:index, 1).should_not be_disabled
127
132
  end
128
133
  it "should raise UnknownObjectException if the text field doesn't exist" do
129
- lambda { @ie.text_field(:index, 1337).disabled? }.should raise_error(UnknownObjectException)
134
+ lambda { @browser.text_field(:index, 1337).disabled? }.should raise_error(UnknownObjectException)
130
135
  end
131
136
  end
132
137
 
133
138
  describe "#readonly?" do
134
139
  it "should return true for read-only text fields" do
135
- @ie.text_field(:name, "new_user_code").should be_readonly
136
- @ie.text_field(:id, "new_user_code").should be_readonly
140
+ @browser.text_field(:name, "new_user_code").should be_readonly
141
+ @browser.text_field(:id, "new_user_code").should be_readonly
137
142
  end
138
143
  it "should return false for writeable text fields" do
139
- @ie.text_field(:name, "new_user_email").should_not be_readonly
144
+ @browser.text_field(:name, "new_user_email").should_not be_readonly
140
145
  end
141
146
  end
142
147
 
@@ -145,90 +150,104 @@ describe "TextField" do
145
150
 
146
151
  describe "#append" do
147
152
  it "should append the text to the text field" do
148
- @ie.text_field(:name, "new_user_occupation").append(" Append This")
149
- @ie.text_field(:name, "new_user_occupation").get_contents.should == "Developer Append This"
153
+ @browser.text_field(:name, "new_user_occupation").append(" Append This")
154
+ @browser.text_field(:name, "new_user_occupation").get_contents.should == "Developer Append This"
150
155
  end
151
- it "should append Chinese characters" do
152
- @ie.text_field(:name, "new_user_occupation").append(" ijij")
153
- @ie.text_field(:name, "new_user_occupation").get_contents.should == "Developer ijij"
156
+ it "should append multi-byte characters" do
157
+ @browser.text_field(:name, "new_user_occupation").append(" ijij")
158
+ @browser.text_field(:name, "new_user_occupation").get_contents.should == "Developer ijij"
154
159
  end
155
160
  it "should raise ObjectReadOnlyException if the object is read only" do
156
- lambda { @ie.text_field(:id, "new_user_code").append("Append This") }.should raise_error(ObjectReadOnlyException)
161
+ lambda { @browser.text_field(:id, "new_user_code").append("Append This") }.should raise_error(ObjectReadOnlyException)
157
162
  end
158
163
  it "should raise ObjectDisabledException if the object is disabled" do
159
- lambda { @ie.text_field(:name, "new_user_species").append("Append This") }.should raise_error(ObjectDisabledException)
164
+ lambda { @browser.text_field(:name, "new_user_species").append("Append This") }.should raise_error(ObjectDisabledException)
160
165
  end
161
166
  it "should raise UnknownObjectException if the object doesn't exist" do
162
- lambda { @ie.text_field(:name, "no_such_name").append("Append This") }.should raise_error(UnknownObjectException)
167
+ lambda { @browser.text_field(:name, "no_such_name").append("Append This") }.should raise_error(UnknownObjectException)
163
168
  end
164
169
  end
165
170
 
166
171
  describe "#clear" do
167
172
  it "should remove all text from the text field" do
168
- @ie.text_field(:name, "new_user_occupation").clear
169
- @ie.text_field(:name, "new_user_occupation").get_contents.should be_empty
170
- @ie.text_field(:id, "delete_user_comment").clear
171
- @ie.text_field(:id, "delete_user_comment").get_contents.should be_empty
173
+ @browser.text_field(:name, "new_user_occupation").clear
174
+ @browser.text_field(:name, "new_user_occupation").get_contents.should be_empty
175
+ @browser.text_field(:id, "delete_user_comment").clear
176
+ @browser.text_field(:id, "delete_user_comment").get_contents.should be_empty
172
177
  end
173
178
  end
174
179
 
175
180
  describe "#drag_contents_to" do
176
181
  it "should drag contents to another text field" do
177
- @ie.text_field(:name, "new_user_first_name").set("Smith")
178
- @ie.text_field(:name, "new_user_first_name").drag_contents_to(:name, "new_user_last_name")
179
- @ie.text_field(:name, "new_user_first_name").value.should be_empty
180
- @ie.text_field(:id, "new_user_last_name").value.should == "Smith"
182
+ @browser.text_field(:name, "new_user_first_name").set("Smith")
183
+ @browser.text_field(:name, "new_user_first_name").drag_contents_to(:name, "new_user_last_name")
184
+ @browser.text_field(:name, "new_user_first_name").value.should be_empty
185
+ @browser.text_field(:id, "new_user_last_name").value.should == "Smith"
181
186
  end
182
187
  end
183
188
 
184
189
  describe "#get_contents" do
185
190
  it "should raise UnknownObjectException when accessing a non-existing element" do
186
- lambda { @ie.text_field(:name, "no_such_name").get_contents }.should raise_error(UnknownObjectException)
191
+ lambda { @browser.text_field(:name, "no_such_name").get_contents }.should raise_error(UnknownObjectException)
187
192
  end
188
193
  end
189
194
 
190
195
  describe "#value=" do
191
196
  it "should set the value of the element" do
192
- @ie.text_field(:id, 'new_user_email').value = 'Hello Cruel World'
193
- @ie.text_field(:id, "new_user_email").value.should == 'Hello Cruel World'
194
- @ie.text_field(:id, 'delete_user_comment').value = 'Hello Cruel World'
195
- @ie.text_field(:id, "delete_user_comment").value.should == 'Hello Cruel World'
197
+ @browser.text_field(:id, 'new_user_email').value = 'Hello Cruel World'
198
+ @browser.text_field(:id, "new_user_email").value.should == 'Hello Cruel World'
199
+ end
200
+
201
+ it "should be able to set multi-byte characters" do
202
+ @browser.text_field(:name, "new_user_occupation").value = "ijij"
203
+ @browser.text_field(:name, "new_user_occupation").get_contents.should == "ijij"
204
+ end
205
+
206
+ it "should set the value of a textarea element" do
207
+ @browser.text_field(:id, 'delete_user_comment').value = 'Hello Cruel World'
208
+ @browser.text_field(:id, "delete_user_comment").value.should == 'Hello Cruel World'
196
209
  end
197
210
  end
198
211
 
199
212
  describe "#set" do
200
213
  it "should set the value of the element" do
201
- @ie.text_field(:id, 'new_user_email').set('Bye Cruel World')
202
- @ie.text_field(:id, "new_user_email").value.should == 'Bye Cruel World'
203
- @ie.text_field(:id, 'delete_user_comment').set('Hello Cruel World')
204
- @ie.text_field(:id, "delete_user_comment").value.should == 'Hello Cruel World'
214
+ @browser.text_field(:id, 'new_user_email').set('Bye Cruel World')
215
+ @browser.text_field(:id, "new_user_email").value.should == 'Bye Cruel World'
205
216
  end
206
217
 
207
- it "should fire events"
218
+ it "should set the value of a textarea element" do
219
+ @browser.text_field(:id, 'delete_user_comment').set('Hello Cruel World')
220
+ @browser.text_field(:id, "delete_user_comment").value.should == 'Hello Cruel World'
221
+ end
222
+
223
+ it "should fire events" do
224
+ @browser.text_field(:id, "new_user_username").set("Hello World")
225
+ @browser.span(:id, "current_length").text.should == "11"
226
+ end
208
227
 
209
228
  it "should be able to set the value of a password field" do
210
- @ie.text_field(:name , 'new_user_password').set('secret')
211
- @ie.text_field(:name , 'new_user_password').value.should == 'secret'
229
+ @browser.text_field(:name , 'new_user_password').set('secret')
230
+ @browser.text_field(:name , 'new_user_password').value.should == 'secret'
212
231
  end
213
- it "should be able to set chinese characters" do
214
- @ie.text_field(:name, "new_user_occupation").set("ijij")
215
- @ie.text_field(:name, "new_user_occupation").get_contents.should == "ijij"
232
+ it "should be able to set multi-byte characters" do
233
+ @browser.text_field(:name, "new_user_occupation").set("ijij")
234
+ @browser.text_field(:name, "new_user_occupation").get_contents.should == "ijij"
216
235
  end
217
236
  end
218
237
 
219
238
  describe "#verify_contains" do
220
239
  it "should verify that a text field contains its value" do
221
- @ie.text_field(:name, "new_user_occupation").verify_contains("Developer").should be_true
222
- @ie.text_field(:name, "new_user_occupation").verify_contains(/Developer/).should be_true
240
+ @browser.text_field(:name, "new_user_occupation").verify_contains("Developer").should be_true
241
+ @browser.text_field(:name, "new_user_occupation").verify_contains(/Developer/).should be_true
223
242
  end
224
243
  it "should not verify that a text field contains a non-existing value" do
225
- @ie.text_field(:name, "new_user_email").verify_contains("no_such_text").should be_false
226
- @ie.text_field(:name, "new_user_email").verify_contains(/no_such_text/).should be_false
244
+ @browser.text_field(:name, "new_user_email").verify_contains("no_such_text").should be_false
245
+ @browser.text_field(:name, "new_user_email").verify_contains(/no_such_text/).should be_false
227
246
  end
228
247
  end
229
248
 
230
249
  after :all do
231
- @ie.close
250
+ @browser.close
232
251
  end
233
252
  end
234
253
 
@@ -3,43 +3,43 @@ require File.dirname(__FILE__) + '/spec_helper.rb'
3
3
  describe "TextFields" do
4
4
 
5
5
  before :all do
6
- @ie = IE.new
7
- add_spec_checker(@ie)
6
+ @browser = IE.new
7
+ add_spec_checker(@browser)
8
8
  end
9
9
 
10
10
  before :each do
11
- @ie.goto(TEST_HOST + "/forms_with_input_elements.html")
11
+ @browser.goto(TEST_HOST + "/forms_with_input_elements.html")
12
12
  end
13
13
 
14
14
  describe "#length" do
15
15
  it "should return the number of text fields" do
16
- @ie.text_fields.length.should == 9
16
+ @browser.text_fields.length.should == 9
17
17
  end
18
18
  end
19
19
 
20
20
  describe "#[]" do
21
21
  it "should return the text field at the given index" do
22
- @ie.text_fields[1].id.should == "new_user_first_name"
23
- @ie.text_fields[2].id.should == "new_user_last_name"
24
- @ie.text_fields[3].id.should == "new_user_email"
22
+ @browser.text_fields[1].id.should == "new_user_first_name"
23
+ @browser.text_fields[2].id.should == "new_user_last_name"
24
+ @browser.text_fields[3].id.should == "new_user_email"
25
25
  end
26
26
  end
27
27
 
28
28
  describe "#each" do
29
29
  it "should iterate through text fields correctly" do
30
30
  index = 1
31
- @ie.text_fields.each do |r|
32
- r.name.should == @ie.text_field(:index, index).name
33
- r.id.should == @ie.text_field(:index, index).id
34
- r.value.should == @ie.text_field(:index, index).value
31
+ @browser.text_fields.each do |r|
32
+ r.name.should == @browser.text_field(:index, index).name
33
+ r.id.should == @browser.text_field(:index, index).id
34
+ r.value.should == @browser.text_field(:index, index).value
35
35
  index += 1
36
36
  end
37
- @ie.text_fields.length.should == index - 1
37
+ @browser.text_fields.length.should == index - 1
38
38
  end
39
39
  end
40
40
 
41
41
  after :all do
42
- @ie.close
42
+ @browser.close
43
43
  end
44
44
  end
45
45
 
@@ -0,0 +1,3 @@
1
+ task :benchmark do
2
+ Dir[File.dirname(__FILE__) + "/../benchmark/*.rb"].each { |f| load f }
3
+ end
data/tasks/rspec.rake CHANGED
@@ -18,6 +18,6 @@ desc "Run the specs under spec/models"
18
18
  Spec::Rake::SpecTask.new do |t|
19
19
  t.spec_opts = ['--options', "spec/spec.opts"]
20
20
  t.spec_files = FileList['spec/**/*_spec.rb']
21
- t.rcov = true
22
- t.rcov_opts = ['--exclude', 'spec,fcntl,path_helper']
21
+ # t.rcov = true
22
+ # t.rcov_opts = ['--exclude', 'spec,fcntl,path_helper']
23
23
  end
@@ -4,14 +4,29 @@ task :testserver do
4
4
  require 'webrick'
5
5
  doc_root = File.join(File.dirname(__FILE__),"..", "spec", "html")
6
6
  log_file = File.join(File.dirname(__FILE__), "..", "log", "webrick_log.txt")
7
+ unless File.exist?(log_file)
8
+ FileUtils.mkdir_p(File.dirname(log_file))
9
+ FileUtils.touch(log_file)
10
+ end
11
+
7
12
  server_port = 2000
8
13
  TEST_HOST = "http://localhost:#{server_port.to_s}"
9
14
 
15
+ class PostServlet < WEBrick::HTTPServlet::AbstractServlet
16
+ def do_POST(req, resp)
17
+ resp['content-type'] = 'text/plain'
18
+ resp.body << "You posted the following content:\n"
19
+ resp.body << req.body
20
+ end
21
+ end
22
+
10
23
  server = WEBrick::HTTPServer.new(:Port => server_port,
11
24
  :DocumentRoot => doc_root,
12
25
  :Logger => WEBrick::Log.new(log_file, WEBrick::BasicLog::WARN),
13
26
  :AccessLog => [])
14
27
  server.mount("/", WEBrick::HTTPServlet::FileHandler, doc_root, {:FancyIndexing=>true})
28
+ server.mount("/post_to_me", PostServlet)
29
+
15
30
  WEBRICK_SERVER = Thread.new { server.start }
16
31
  WEBRICK_SERVER.join
17
32
  end
metadata CHANGED
@@ -1,39 +1,40 @@
1
- --- !ruby/object:Gem::Specification
2
- required_ruby_version: !ruby/object:Gem::Requirement
3
- requirements:
4
- - - '>='
5
- - !ruby/object:Gem::Version
6
- version: !str 0
7
- version:
8
- email: alexander.lystad@finntech.no
1
+ --- !ruby/object:Gem::Specification
2
+ name: celerity
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - T. Alexander Lystad
8
+ - Knut Johannes Dahle
9
+ - Jari Bakken
10
+ autorequire:
11
+ bindir: bin
9
12
  cert_chain: []
10
- summary: Celerity is a JRuby wrapper around the HtmlUnit Java library (http://htmlunit.sourceforge.net/).
11
- The goal of the project is to duplicate the Watir API (http://wtf.rubyforge.org/)
12
- using HtmlUnit as the underlying engine.
13
- post_install_message:
13
+
14
+ date: 2008-05-15 00:00:00 +02:00
15
+ default_executable:
16
+ dependencies: []
17
+
18
+ description: Celerity is a JRuby wrapper around the HtmlUnit Java library (http://htmlunit.sourceforge.net/). The goal of the project is to duplicate the Watir API (http://wtf.rubyforge.org/) using HtmlUnit as the underlying engine.
19
+ email: alexander.lystad@finntech.no
20
+ executables: []
21
+
22
+ extensions: []
23
+
14
24
  extra_rdoc_files:
15
25
  - History.txt
16
26
  - License.txt
17
27
  - README.txt
18
- homepage: http://celerity.rubyforge.org
19
- signing_key:
20
- name: celerity
21
- rdoc_options:
22
- - --main
23
- - README.txt
24
- autorequire:
25
- rubyforge_project: celerity
26
- executables: []
27
- description: Celerity is a JRuby wrapper around the HtmlUnit Java library (http://htmlunit.sourceforge.net/).
28
- The goal of the project is to duplicate the Watir API (http://wtf.rubyforge.org/)
29
- using HtmlUnit as the underlying engine.
30
- specification_version: 2
31
- default_executable:
32
28
  files:
33
29
  - History.txt
34
30
  - License.txt
35
31
  - README.txt
36
32
  - Rakefile
33
+ - benchmark/bm_2000_spans.rb
34
+ - benchmark/bm_digg.rb
35
+ - benchmark/bm_google_images.rb
36
+ - benchmark/bm_input_locator.rb
37
+ - benchmark/loader.rb
37
38
  - lib/celerity.rb
38
39
  - lib/celerity/clickable_element.rb
39
40
  - lib/celerity/collections.rb
@@ -41,6 +42,7 @@ files:
41
42
  - lib/celerity/disabled_element.rb
42
43
  - lib/celerity/element.rb
43
44
  - lib/celerity/element_collections.rb
45
+ - lib/celerity/element_locator.rb
44
46
  - lib/celerity/elements/button.rb
45
47
  - lib/celerity/elements/file_field.rb
46
48
  - lib/celerity/elements/form.rb
@@ -48,6 +50,7 @@ files:
48
50
  - lib/celerity/elements/image.rb
49
51
  - lib/celerity/elements/label.rb
50
52
  - lib/celerity/elements/link.rb
53
+ - lib/celerity/elements/option.rb
51
54
  - lib/celerity/elements/radio_check.rb
52
55
  - lib/celerity/elements/select_list.rb
53
56
  - lib/celerity/elements/table.rb
@@ -56,6 +59,7 @@ files:
56
59
  - lib/celerity/elements/table_row.rb
57
60
  - lib/celerity/elements/text_field.rb
58
61
  - lib/celerity/exception.rb
62
+ - lib/celerity/extra/method_generator.rb
59
63
  - lib/celerity/htmlunit/commons-codec-1.3.jar
60
64
  - lib/celerity/htmlunit/commons-collections-3.2.jar
61
65
  - lib/celerity/htmlunit/commons-httpclient-3.1.jar
@@ -70,6 +74,7 @@ files:
70
74
  - lib/celerity/htmlunit/xalan-2.7.0.jar
71
75
  - lib/celerity/htmlunit/xercesImpl-2.8.1.jar
72
76
  - lib/celerity/htmlunit/xml-apis-1.0.b2.jar
77
+ - lib/celerity/identifier.rb
73
78
  - lib/celerity/ie.rb
74
79
  - lib/celerity/input_element.rb
75
80
  - lib/celerity/non_control_elements.rb
@@ -91,6 +96,7 @@ files:
91
96
  - spec/frame_spec.rb
92
97
  - spec/hidden_spec.rb
93
98
  - spec/hiddens_spec.rb
99
+ - spec/html/2000_spans.html
94
100
  - spec/html/forms_with_input_elements.html
95
101
  - spec/html/frame_1.html
96
102
  - spec/html/frame_2.html
@@ -147,28 +153,34 @@ files:
147
153
  - spec/text_fields_spec.rb
148
154
  - tasks/environment.rake
149
155
  - tasks/rspec.rake
150
- - tasks/simple_ci.rake
151
156
  - tasks/testserver.rake
152
- required_rubygems_version: !ruby/object:Gem::Requirement
157
+ - tasks/benchmark.rake
158
+ has_rdoc: true
159
+ homepage: http://celerity.rubyforge.org
160
+ post_install_message:
161
+ rdoc_options:
162
+ - --main
163
+ - README.txt
164
+ require_paths:
165
+ - lib
166
+ required_ruby_version: !ruby/object:Gem::Requirement
153
167
  requirements:
154
- - - '>='
155
- - !ruby/object:Gem::Version
156
- version: !str 0
168
+ - - ">="
169
+ - !ruby/object:Gem::Version
170
+ version: "0"
171
+ version:
172
+ required_rubygems_version: !ruby/object:Gem::Requirement
173
+ requirements:
174
+ - - ">="
175
+ - !ruby/object:Gem::Version
176
+ version: "0"
157
177
  version:
158
- extensions: []
159
- rubygems_version: 1.0.1
160
178
  requirements: []
161
- authors:
162
- - T. Alexander Lystad
163
- - Knut Johannes Dahle
164
- - Jari Bakken
165
- date: 2008-05-07 22:00:00 +00:00
166
- platform: ruby
179
+
180
+ rubyforge_project: celerity
181
+ rubygems_version: 1.1.1
182
+ signing_key:
183
+ specification_version: 2
184
+ summary: Celerity is a JRuby wrapper around the HtmlUnit Java library (http://htmlunit.sourceforge.net/). The goal of the project is to duplicate the Watir API (http://wtf.rubyforge.org/) using HtmlUnit as the underlying engine.
167
185
  test_files: []
168
- version: !ruby/object:Gem::Version
169
- version: 0.0.1
170
- require_paths:
171
- - lib
172
- dependencies: []
173
- bindir: bin
174
- has_rdoc: true
186
+