celerity 0.0.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/History.txt +4 -0
- data/License.txt +621 -0
- data/README.txt +58 -0
- data/Rakefile +4 -0
- data/lib/celerity.rb +47 -0
- data/lib/celerity/clickable_element.rb +11 -0
- data/lib/celerity/collections.rb +99 -0
- data/lib/celerity/container.rb +369 -0
- data/lib/celerity/disabled_element.rb +20 -0
- data/lib/celerity/element.rb +114 -0
- data/lib/celerity/element_collections.rb +67 -0
- data/lib/celerity/elements/button.rb +13 -0
- data/lib/celerity/elements/file_field.rb +12 -0
- data/lib/celerity/elements/form.rb +15 -0
- data/lib/celerity/elements/frame.rb +44 -0
- data/lib/celerity/elements/image.rb +70 -0
- data/lib/celerity/elements/label.rb +10 -0
- data/lib/celerity/elements/link.rb +13 -0
- data/lib/celerity/elements/radio_check.rb +59 -0
- data/lib/celerity/elements/select_list.rb +84 -0
- data/lib/celerity/elements/table.rb +94 -0
- data/lib/celerity/elements/table_body.rb +38 -0
- data/lib/celerity/elements/table_cell.rb +30 -0
- data/lib/celerity/elements/table_row.rb +34 -0
- data/lib/celerity/elements/text_field.rb +80 -0
- data/lib/celerity/exception.rb +48 -0
- data/lib/celerity/htmlunit/commons-codec-1.3.jar +0 -0
- data/lib/celerity/htmlunit/commons-collections-3.2.jar +0 -0
- data/lib/celerity/htmlunit/commons-httpclient-3.1.jar +0 -0
- data/lib/celerity/htmlunit/commons-io-1.4.jar +0 -0
- data/lib/celerity/htmlunit/commons-lang-2.4.jar +0 -0
- data/lib/celerity/htmlunit/commons-logging-1.1.1.jar +0 -0
- data/lib/celerity/htmlunit/cssparser-0.9.5.jar +0 -0
- data/lib/celerity/htmlunit/htmlunit-2.2-SNAPSHOT.jar +0 -0
- data/lib/celerity/htmlunit/js-1.7R1.jar +0 -0
- data/lib/celerity/htmlunit/nekohtml-1.9.7.jar +0 -0
- data/lib/celerity/htmlunit/sac-1.3.jar +0 -0
- data/lib/celerity/htmlunit/xalan-2.7.0.jar +0 -0
- data/lib/celerity/htmlunit/xercesImpl-2.8.1.jar +0 -0
- data/lib/celerity/htmlunit/xml-apis-1.0.b2.jar +0 -0
- data/lib/celerity/ie.rb +126 -0
- data/lib/celerity/input_element.rb +29 -0
- data/lib/celerity/non_control_elements.rb +50 -0
- data/lib/celerity/version.rb +9 -0
- data/setup.rb +1585 -0
- data/spec/area_spec.rb +79 -0
- data/spec/areas_spec.rb +41 -0
- data/spec/button_spec.rb +171 -0
- data/spec/buttons_spec.rb +40 -0
- data/spec/checkbox_spec.rb +259 -0
- data/spec/checkboxes_spec.rb +39 -0
- data/spec/div_spec.rb +174 -0
- data/spec/divs_spec.rb +40 -0
- data/spec/element_spec.rb +29 -0
- data/spec/filefield_spec.rb +110 -0
- data/spec/filefields_spec.rb +41 -0
- data/spec/form_spec.rb +53 -0
- data/spec/forms_spec.rb +42 -0
- data/spec/frame_spec.rb +103 -0
- data/spec/hidden_spec.rb +105 -0
- data/spec/hiddens_spec.rb +40 -0
- data/spec/html/forms_with_input_elements.html +107 -0
- data/spec/html/frame_1.html +17 -0
- data/spec/html/frame_2.html +16 -0
- data/spec/html/frames.html +11 -0
- data/spec/html/iframes.html +12 -0
- data/spec/html/images.html +24 -0
- data/spec/html/images/1.gif +0 -0
- data/spec/html/images/2.gif +0 -0
- data/spec/html/images/3.gif +0 -0
- data/spec/html/images/button.jpg +0 -0
- data/spec/html/images/circle.jpg +0 -0
- data/spec/html/images/map.gif +0 -0
- data/spec/html/images/map2.gif +0 -0
- data/spec/html/images/minus.gif +0 -0
- data/spec/html/images/originaltriangle.jpg +0 -0
- data/spec/html/images/plus.gif +0 -0
- data/spec/html/images/square.jpg +0 -0
- data/spec/html/images/triangle.jpg +0 -0
- data/spec/html/non_control_elements.html +85 -0
- data/spec/html/tables.html +119 -0
- data/spec/ie_spec.rb +146 -0
- data/spec/image_spec.rb +210 -0
- data/spec/images_spec.rb +39 -0
- data/spec/label_spec.rb +65 -0
- data/spec/labels_spec.rb +41 -0
- data/spec/li_spec.rb +114 -0
- data/spec/link_spec.rb +147 -0
- data/spec/links_spec.rb +43 -0
- data/spec/lis_spec.rb +40 -0
- data/spec/map_spec.rb +83 -0
- data/spec/maps_spec.rb +41 -0
- data/spec/p_spec.rb +140 -0
- data/spec/pre_spec.rb +110 -0
- data/spec/pres_spec.rb +41 -0
- data/spec/ps_spec.rb +40 -0
- data/spec/radio_spec.rb +260 -0
- data/spec/radios_spec.rb +43 -0
- data/spec/select_list_spec.rb +286 -0
- data/spec/select_lists_spec.rb +47 -0
- data/spec/span_spec.rb +156 -0
- data/spec/spans_spec.rb +65 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +90 -0
- data/spec/table_bodies.rb +40 -0
- data/spec/table_bodies_spec.rb +42 -0
- data/spec/table_body_spec.rb +72 -0
- data/spec/table_cell_spec.rb +61 -0
- data/spec/table_cells_spec.rb +60 -0
- data/spec/table_row_spec.rb +59 -0
- data/spec/table_rows_spec.rb +57 -0
- data/spec/table_spec.rb +111 -0
- data/spec/tables_spec.rb +42 -0
- data/spec/text_field_spec.rb +234 -0
- data/spec/text_fields_spec.rb +45 -0
- data/tasks/environment.rake +7 -0
- data/tasks/rspec.rake +23 -0
- data/tasks/simple_ci.rake +94 -0
- data/tasks/testserver.rake +17 -0
- metadata +174 -0
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper.rb'
|
|
2
|
+
|
|
3
|
+
# TODO: specs for exceptions
|
|
4
|
+
|
|
5
|
+
describe "TextField" do
|
|
6
|
+
|
|
7
|
+
before :all do
|
|
8
|
+
@ie = IE.new
|
|
9
|
+
add_spec_checker(@ie)
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
before :each do
|
|
13
|
+
@ie.goto(TEST_HOST + "/forms_with_input_elements.html")
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# Exist method
|
|
17
|
+
describe "#exists?" do
|
|
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
|
|
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
|
|
34
|
+
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
|
|
37
|
+
end
|
|
38
|
+
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
|
|
51
|
+
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)
|
|
54
|
+
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)
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
# Attribute methods
|
|
62
|
+
describe "#id" do
|
|
63
|
+
it "should return the id attribute if the text field exists" do
|
|
64
|
+
@ie.text_field(:index, 4).id.should == "new_user_occupation"
|
|
65
|
+
end
|
|
66
|
+
it "should raise UnknownObjectException if the text field doesn't exist" do
|
|
67
|
+
lambda { @ie.text_field(:index, 1337).id }.should raise_error(UnknownObjectException)
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
describe "#name" do
|
|
72
|
+
it "should return the name attribute if the text field exists" do
|
|
73
|
+
@ie.text_field(:index, 4).name.should == "new_user_occupation"
|
|
74
|
+
end
|
|
75
|
+
it "should raise UnknownObjectException if the text field doesn't exist" do
|
|
76
|
+
lambda { @ie.text_field(:index, 1337).name }.should raise_error(UnknownObjectException)
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
describe "#title" do
|
|
81
|
+
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"
|
|
83
|
+
end
|
|
84
|
+
it "should raise UnknownObjectException if the text field doesn't exist" do
|
|
85
|
+
lambda { @ie.text_field(:index, 1337).title }.should raise_error(UnknownObjectException)
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
describe "#type" do
|
|
90
|
+
#TODO: What if the type attribute is non-existent or invalid?
|
|
91
|
+
it "should return the type attribute if the text field exists" do
|
|
92
|
+
@ie.text_field(:index, 4).type.should == "text"
|
|
93
|
+
end
|
|
94
|
+
it "should raise UnknownObjectException if the text field doesn't exist" do
|
|
95
|
+
lambda { @ie.text_field(:index, 1337).type }.should raise_error(UnknownObjectException)
|
|
96
|
+
end
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
describe "#value" do
|
|
100
|
+
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"
|
|
104
|
+
end
|
|
105
|
+
it "should raise UnknownObjectException if the text field doesn't exist" do
|
|
106
|
+
lambda { @ie.text_field(:index, 1337).value }.should raise_error(UnknownObjectException)
|
|
107
|
+
end
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
# Access methods
|
|
111
|
+
describe "#enabled?" do
|
|
112
|
+
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
|
|
115
|
+
end
|
|
116
|
+
it "should return false for disabled text fields" do
|
|
117
|
+
@ie.text_field(:name, "new_user_species").should_not be_enabled
|
|
118
|
+
end
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
describe "#disabled?" do
|
|
122
|
+
it "should return true if the text field is disabled" do
|
|
123
|
+
@ie.text_field(:id, 'new_user_species').should be_disabled
|
|
124
|
+
end
|
|
125
|
+
it "should return false if the text field is enabled" do
|
|
126
|
+
@ie.text_field(:index, 1).should_not be_disabled
|
|
127
|
+
end
|
|
128
|
+
it "should raise UnknownObjectException if the text field doesn't exist" do
|
|
129
|
+
lambda { @ie.text_field(:index, 1337).disabled? }.should raise_error(UnknownObjectException)
|
|
130
|
+
end
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
describe "#readonly?" do
|
|
134
|
+
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
|
|
137
|
+
end
|
|
138
|
+
it "should return false for writeable text fields" do
|
|
139
|
+
@ie.text_field(:name, "new_user_email").should_not be_readonly
|
|
140
|
+
end
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
# Manipulation methods
|
|
145
|
+
|
|
146
|
+
describe "#append" do
|
|
147
|
+
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"
|
|
150
|
+
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"
|
|
154
|
+
end
|
|
155
|
+
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)
|
|
157
|
+
end
|
|
158
|
+
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)
|
|
160
|
+
end
|
|
161
|
+
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)
|
|
163
|
+
end
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
describe "#clear" do
|
|
167
|
+
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
|
|
172
|
+
end
|
|
173
|
+
end
|
|
174
|
+
|
|
175
|
+
describe "#drag_contents_to" do
|
|
176
|
+
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"
|
|
181
|
+
end
|
|
182
|
+
end
|
|
183
|
+
|
|
184
|
+
describe "#get_contents" do
|
|
185
|
+
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)
|
|
187
|
+
end
|
|
188
|
+
end
|
|
189
|
+
|
|
190
|
+
describe "#value=" do
|
|
191
|
+
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'
|
|
196
|
+
end
|
|
197
|
+
end
|
|
198
|
+
|
|
199
|
+
describe "#set" do
|
|
200
|
+
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'
|
|
205
|
+
end
|
|
206
|
+
|
|
207
|
+
it "should fire events"
|
|
208
|
+
|
|
209
|
+
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'
|
|
212
|
+
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"
|
|
216
|
+
end
|
|
217
|
+
end
|
|
218
|
+
|
|
219
|
+
describe "#verify_contains" do
|
|
220
|
+
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
|
|
223
|
+
end
|
|
224
|
+
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
|
|
227
|
+
end
|
|
228
|
+
end
|
|
229
|
+
|
|
230
|
+
after :all do
|
|
231
|
+
@ie.close
|
|
232
|
+
end
|
|
233
|
+
end
|
|
234
|
+
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper.rb'
|
|
2
|
+
|
|
3
|
+
describe "TextFields" do
|
|
4
|
+
|
|
5
|
+
before :all do
|
|
6
|
+
@ie = IE.new
|
|
7
|
+
add_spec_checker(@ie)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
before :each do
|
|
11
|
+
@ie.goto(TEST_HOST + "/forms_with_input_elements.html")
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
describe "#length" do
|
|
15
|
+
it "should return the number of text fields" do
|
|
16
|
+
@ie.text_fields.length.should == 9
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
describe "#[]" do
|
|
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"
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
describe "#each" do
|
|
29
|
+
it "should iterate through text fields correctly" do
|
|
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
|
|
35
|
+
index += 1
|
|
36
|
+
end
|
|
37
|
+
@ie.text_fields.length.should == index - 1
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
after :all do
|
|
42
|
+
@ie.close
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
|
data/tasks/rspec.rake
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
begin
|
|
2
|
+
require 'spec'
|
|
3
|
+
rescue LoadError
|
|
4
|
+
require 'rubygems'
|
|
5
|
+
require 'spec'
|
|
6
|
+
end
|
|
7
|
+
begin
|
|
8
|
+
require 'spec/rake/spectask'
|
|
9
|
+
rescue LoadError
|
|
10
|
+
puts <<-EOS
|
|
11
|
+
To use rspec for testing you must install rspec gem:
|
|
12
|
+
gem install rspec
|
|
13
|
+
EOS
|
|
14
|
+
exit(0)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
desc "Run the specs under spec/models"
|
|
18
|
+
Spec::Rake::SpecTask.new do |t|
|
|
19
|
+
t.spec_opts = ['--options', "spec/spec.opts"]
|
|
20
|
+
t.spec_files = FileList['spec/**/*_spec.rb']
|
|
21
|
+
t.rcov = true
|
|
22
|
+
t.rcov_opts = ['--exclude', 'spec,fcntl,path_helper']
|
|
23
|
+
end
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
require "rubygems"
|
|
2
|
+
require "fileutils"
|
|
3
|
+
require "erb"
|
|
4
|
+
require "pp"
|
|
5
|
+
|
|
6
|
+
begin
|
|
7
|
+
require "mongrel"
|
|
8
|
+
rescue LoadError
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
task :simple_ci do
|
|
12
|
+
INTERVAL = (60*5)
|
|
13
|
+
CI_ROOT = File.dirname(__FILE__) + "/../simple_ci"
|
|
14
|
+
ROOT = File.expand_path(CI_ROOT + "/..")
|
|
15
|
+
Dir.mkdir(CI_ROOT) unless File.exist?(CI_ROOT)
|
|
16
|
+
|
|
17
|
+
class SpecFile < Struct.new(:file, :describes)
|
|
18
|
+
attr_accessor :passed
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def get_specs
|
|
22
|
+
Dir[File.dirname(__FILE__) + '/../spec/**/*_spec.rb'].map do |file|
|
|
23
|
+
SpecFile.new(file, File.read(file)[/describe\(?\s*["'](.+?)["']/, 1] || File.basename(file) )
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
class SimpleCI < Mongrel::HttpHandler
|
|
28
|
+
def self.template=(rhtml); @@template = rhtml; end
|
|
29
|
+
|
|
30
|
+
def initialize(results)
|
|
31
|
+
@results = results
|
|
32
|
+
super()
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def process(request, response)
|
|
36
|
+
response.start(200) do |header, io|
|
|
37
|
+
if @results
|
|
38
|
+
io.write ERB.new(@@template).result
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
@results = {}
|
|
46
|
+
SimpleCI.template = <<-HTML
|
|
47
|
+
<html>
|
|
48
|
+
<head>
|
|
49
|
+
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
|
|
50
|
+
<title>Celerity Simple CI</title>
|
|
51
|
+
<style type="text/css" media="screen">
|
|
52
|
+
body {font: 10px/16px "Lucida Grande", Geneva, Arial, Verdana, sans-serif; background-color: #fff;color: #333;}
|
|
53
|
+
a{color:#2971a7;}
|
|
54
|
+
a:link,a:visited,a:active{text-decoration:none}
|
|
55
|
+
a:hover{text-decoration:underline}
|
|
56
|
+
table{border-collapse:collapse;border-spacing:0;margin-left:24px;}
|
|
57
|
+
</style>
|
|
58
|
+
</head>
|
|
59
|
+
|
|
60
|
+
<h1> Celerity </h1>
|
|
61
|
+
<h3><a href="result/">Test Results</a></h3>
|
|
62
|
+
<h3><a href="coverage/">Code Coverage</a></h3>
|
|
63
|
+
</html>
|
|
64
|
+
HTML
|
|
65
|
+
|
|
66
|
+
begin
|
|
67
|
+
@server = Mongrel::HttpServer.new('0.0.0.0', '8080')
|
|
68
|
+
rescue NameError
|
|
69
|
+
abort("Run `(jruby -S) gem install mongrel` to use this task.")
|
|
70
|
+
end
|
|
71
|
+
@server.register("/result", Mongrel::DirHandler.new(CI_ROOT))
|
|
72
|
+
@server.register("/coverage", Mongrel::DirHandler.new(CI_ROOT + "/coverage/coverage"))
|
|
73
|
+
@server.register("/", SimpleCI.new(@results))
|
|
74
|
+
Thread.new { @server.run.join }
|
|
75
|
+
puts "simple_ci started on #{@server.host}:#{@server.port}"
|
|
76
|
+
loop do
|
|
77
|
+
puts %x{svn up}
|
|
78
|
+
puts "*** running specs at #{Time.now}"
|
|
79
|
+
specs = get_specs
|
|
80
|
+
|
|
81
|
+
pp specs if $DEBUG
|
|
82
|
+
puts "*** running rcov at #{Time.now}"
|
|
83
|
+
puts %x{jruby -S rake --silent spec > #{CI_ROOT}/index2.html}
|
|
84
|
+
FileUtils.mv(CI_ROOT + "/index2.html", CI_ROOT + "/index.html", :verbose => true)
|
|
85
|
+
Dir[CI_ROOT + "/coverage/*"].each { |f| FileUtils.rm_r(f, :verbose => true) }
|
|
86
|
+
FileUtils.mv(CI_ROOT + "/../coverage", CI_ROOT + "/coverage", :verbose => true)
|
|
87
|
+
puts "\n*** sleeping #{Time.now}"
|
|
88
|
+
sleep(INTERVAL)
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
desc "Run webserver for tests (when using MRI)"
|
|
2
|
+
task :testserver do
|
|
3
|
+
# ========= WEBRick stuff ==========
|
|
4
|
+
require 'webrick'
|
|
5
|
+
doc_root = File.join(File.dirname(__FILE__),"..", "spec", "html")
|
|
6
|
+
log_file = File.join(File.dirname(__FILE__), "..", "log", "webrick_log.txt")
|
|
7
|
+
server_port = 2000
|
|
8
|
+
TEST_HOST = "http://localhost:#{server_port.to_s}"
|
|
9
|
+
|
|
10
|
+
server = WEBrick::HTTPServer.new(:Port => server_port,
|
|
11
|
+
:DocumentRoot => doc_root,
|
|
12
|
+
:Logger => WEBrick::Log.new(log_file, WEBrick::BasicLog::WARN),
|
|
13
|
+
:AccessLog => [])
|
|
14
|
+
server.mount("/", WEBrick::HTTPServlet::FileHandler, doc_root, {:FancyIndexing=>true})
|
|
15
|
+
WEBRICK_SERVER = Thread.new { server.start }
|
|
16
|
+
WEBRICK_SERVER.join
|
|
17
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,174 @@
|
|
|
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
|
|
9
|
+
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:
|
|
14
|
+
extra_rdoc_files:
|
|
15
|
+
- History.txt
|
|
16
|
+
- License.txt
|
|
17
|
+
- 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
|
+
files:
|
|
33
|
+
- History.txt
|
|
34
|
+
- License.txt
|
|
35
|
+
- README.txt
|
|
36
|
+
- Rakefile
|
|
37
|
+
- lib/celerity.rb
|
|
38
|
+
- lib/celerity/clickable_element.rb
|
|
39
|
+
- lib/celerity/collections.rb
|
|
40
|
+
- lib/celerity/container.rb
|
|
41
|
+
- lib/celerity/disabled_element.rb
|
|
42
|
+
- lib/celerity/element.rb
|
|
43
|
+
- lib/celerity/element_collections.rb
|
|
44
|
+
- lib/celerity/elements/button.rb
|
|
45
|
+
- lib/celerity/elements/file_field.rb
|
|
46
|
+
- lib/celerity/elements/form.rb
|
|
47
|
+
- lib/celerity/elements/frame.rb
|
|
48
|
+
- lib/celerity/elements/image.rb
|
|
49
|
+
- lib/celerity/elements/label.rb
|
|
50
|
+
- lib/celerity/elements/link.rb
|
|
51
|
+
- lib/celerity/elements/radio_check.rb
|
|
52
|
+
- lib/celerity/elements/select_list.rb
|
|
53
|
+
- lib/celerity/elements/table.rb
|
|
54
|
+
- lib/celerity/elements/table_body.rb
|
|
55
|
+
- lib/celerity/elements/table_cell.rb
|
|
56
|
+
- lib/celerity/elements/table_row.rb
|
|
57
|
+
- lib/celerity/elements/text_field.rb
|
|
58
|
+
- lib/celerity/exception.rb
|
|
59
|
+
- lib/celerity/htmlunit/commons-codec-1.3.jar
|
|
60
|
+
- lib/celerity/htmlunit/commons-collections-3.2.jar
|
|
61
|
+
- lib/celerity/htmlunit/commons-httpclient-3.1.jar
|
|
62
|
+
- lib/celerity/htmlunit/commons-io-1.4.jar
|
|
63
|
+
- lib/celerity/htmlunit/commons-lang-2.4.jar
|
|
64
|
+
- lib/celerity/htmlunit/commons-logging-1.1.1.jar
|
|
65
|
+
- lib/celerity/htmlunit/cssparser-0.9.5.jar
|
|
66
|
+
- lib/celerity/htmlunit/htmlunit-2.2-SNAPSHOT.jar
|
|
67
|
+
- lib/celerity/htmlunit/js-1.7R1.jar
|
|
68
|
+
- lib/celerity/htmlunit/nekohtml-1.9.7.jar
|
|
69
|
+
- lib/celerity/htmlunit/sac-1.3.jar
|
|
70
|
+
- lib/celerity/htmlunit/xalan-2.7.0.jar
|
|
71
|
+
- lib/celerity/htmlunit/xercesImpl-2.8.1.jar
|
|
72
|
+
- lib/celerity/htmlunit/xml-apis-1.0.b2.jar
|
|
73
|
+
- lib/celerity/ie.rb
|
|
74
|
+
- lib/celerity/input_element.rb
|
|
75
|
+
- lib/celerity/non_control_elements.rb
|
|
76
|
+
- lib/celerity/version.rb
|
|
77
|
+
- setup.rb
|
|
78
|
+
- spec/area_spec.rb
|
|
79
|
+
- spec/areas_spec.rb
|
|
80
|
+
- spec/button_spec.rb
|
|
81
|
+
- spec/buttons_spec.rb
|
|
82
|
+
- spec/checkbox_spec.rb
|
|
83
|
+
- spec/checkboxes_spec.rb
|
|
84
|
+
- spec/div_spec.rb
|
|
85
|
+
- spec/divs_spec.rb
|
|
86
|
+
- spec/element_spec.rb
|
|
87
|
+
- spec/filefield_spec.rb
|
|
88
|
+
- spec/filefields_spec.rb
|
|
89
|
+
- spec/form_spec.rb
|
|
90
|
+
- spec/forms_spec.rb
|
|
91
|
+
- spec/frame_spec.rb
|
|
92
|
+
- spec/hidden_spec.rb
|
|
93
|
+
- spec/hiddens_spec.rb
|
|
94
|
+
- spec/html/forms_with_input_elements.html
|
|
95
|
+
- spec/html/frame_1.html
|
|
96
|
+
- spec/html/frame_2.html
|
|
97
|
+
- spec/html/frames.html
|
|
98
|
+
- spec/html/iframes.html
|
|
99
|
+
- spec/html/images.html
|
|
100
|
+
- spec/html/images/1.gif
|
|
101
|
+
- spec/html/images/2.gif
|
|
102
|
+
- spec/html/images/3.gif
|
|
103
|
+
- spec/html/images/button.jpg
|
|
104
|
+
- spec/html/images/circle.jpg
|
|
105
|
+
- spec/html/images/map.gif
|
|
106
|
+
- spec/html/images/map2.gif
|
|
107
|
+
- spec/html/images/minus.gif
|
|
108
|
+
- spec/html/images/originaltriangle.jpg
|
|
109
|
+
- spec/html/images/plus.gif
|
|
110
|
+
- spec/html/images/square.jpg
|
|
111
|
+
- spec/html/images/triangle.jpg
|
|
112
|
+
- spec/html/non_control_elements.html
|
|
113
|
+
- spec/html/tables.html
|
|
114
|
+
- spec/ie_spec.rb
|
|
115
|
+
- spec/image_spec.rb
|
|
116
|
+
- spec/images_spec.rb
|
|
117
|
+
- spec/label_spec.rb
|
|
118
|
+
- spec/labels_spec.rb
|
|
119
|
+
- spec/li_spec.rb
|
|
120
|
+
- spec/link_spec.rb
|
|
121
|
+
- spec/links_spec.rb
|
|
122
|
+
- spec/lis_spec.rb
|
|
123
|
+
- spec/map_spec.rb
|
|
124
|
+
- spec/maps_spec.rb
|
|
125
|
+
- spec/p_spec.rb
|
|
126
|
+
- spec/pre_spec.rb
|
|
127
|
+
- spec/pres_spec.rb
|
|
128
|
+
- spec/ps_spec.rb
|
|
129
|
+
- spec/radio_spec.rb
|
|
130
|
+
- spec/radios_spec.rb
|
|
131
|
+
- spec/select_list_spec.rb
|
|
132
|
+
- spec/select_lists_spec.rb
|
|
133
|
+
- spec/span_spec.rb
|
|
134
|
+
- spec/spans_spec.rb
|
|
135
|
+
- spec/spec.opts
|
|
136
|
+
- spec/spec_helper.rb
|
|
137
|
+
- spec/table_bodies.rb
|
|
138
|
+
- spec/table_bodies_spec.rb
|
|
139
|
+
- spec/table_body_spec.rb
|
|
140
|
+
- spec/table_cell_spec.rb
|
|
141
|
+
- spec/table_cells_spec.rb
|
|
142
|
+
- spec/table_row_spec.rb
|
|
143
|
+
- spec/table_rows_spec.rb
|
|
144
|
+
- spec/table_spec.rb
|
|
145
|
+
- spec/tables_spec.rb
|
|
146
|
+
- spec/text_field_spec.rb
|
|
147
|
+
- spec/text_fields_spec.rb
|
|
148
|
+
- tasks/environment.rake
|
|
149
|
+
- tasks/rspec.rake
|
|
150
|
+
- tasks/simple_ci.rake
|
|
151
|
+
- tasks/testserver.rake
|
|
152
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
153
|
+
requirements:
|
|
154
|
+
- - '>='
|
|
155
|
+
- !ruby/object:Gem::Version
|
|
156
|
+
version: !str 0
|
|
157
|
+
version:
|
|
158
|
+
extensions: []
|
|
159
|
+
rubygems_version: 1.0.1
|
|
160
|
+
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
|
|
167
|
+
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
|