davidtrogers-webrat 0.4.4.2 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +3 -1
- data/Gemfile +19 -0
- data/History.txt +99 -9
- data/Rakefile +141 -207
- data/Thorfile +118 -0
- data/lib/webrat.rb +10 -23
- data/lib/webrat/{mechanize.rb → adapters/mechanize.rb} +6 -2
- data/lib/webrat/adapters/merb.rb +11 -0
- data/lib/webrat/adapters/rack.rb +25 -0
- data/lib/webrat/{rails.rb → adapters/rails.rb} +5 -37
- data/lib/webrat/adapters/sinatra.rb +9 -0
- data/lib/webrat/core.rb +0 -1
- data/lib/webrat/core/configuration.rb +22 -18
- data/lib/webrat/core/elements/area.rb +2 -2
- data/lib/webrat/core/elements/element.rb +3 -3
- data/lib/webrat/core/elements/field.rb +113 -31
- data/lib/webrat/core/elements/form.rb +4 -4
- data/lib/webrat/core/elements/label.rb +4 -4
- data/lib/webrat/core/elements/link.rb +8 -7
- data/lib/webrat/core/elements/select_option.rb +15 -2
- data/lib/webrat/core/locators.rb +1 -1
- data/lib/webrat/core/locators/area_locator.rb +3 -3
- data/lib/webrat/core/locators/button_locator.rb +6 -6
- data/lib/webrat/core/locators/field_by_id_locator.rb +3 -3
- data/lib/webrat/core/locators/field_labeled_locator.rb +2 -2
- data/lib/webrat/core/locators/field_named_locator.rb +3 -3
- data/lib/webrat/core/locators/form_locator.rb +1 -1
- data/lib/webrat/core/locators/label_locator.rb +2 -2
- data/lib/webrat/core/locators/link_locator.rb +16 -8
- data/lib/webrat/core/locators/select_option_locator.rb +5 -5
- data/lib/webrat/core/logging.rb +4 -5
- data/lib/webrat/core/matchers/have_content.rb +3 -8
- data/lib/webrat/core/matchers/have_xpath.rb +3 -28
- data/lib/webrat/core/methods.rb +5 -4
- data/lib/webrat/core/mime.rb +11 -22
- data/lib/webrat/core/save_and_open_page.rb +7 -29
- data/lib/webrat/core/scope.rb +17 -2
- data/lib/webrat/core/session.rb +31 -19
- data/lib/webrat/core/xml.rb +41 -84
- data/lib/webrat/integrations/merb.rb +10 -0
- data/lib/webrat/integrations/rails.rb +25 -0
- data/lib/webrat/integrations/rspec-rails.rb +11 -0
- data/lib/webrat/integrations/selenium.rb +11 -0
- data/lib/webrat/rspec-rails.rb +2 -13
- data/lib/webrat/selenium.rb +0 -11
- data/lib/webrat/selenium/application_server_factory.rb +40 -0
- data/lib/webrat/selenium/application_servers.rb +5 -0
- data/lib/webrat/selenium/application_servers/base.rb +46 -0
- data/lib/webrat/selenium/application_servers/external.rb +26 -0
- data/lib/webrat/selenium/application_servers/merb.rb +50 -0
- data/lib/webrat/selenium/application_servers/rails.rb +44 -0
- data/lib/webrat/selenium/application_servers/sinatra.rb +37 -0
- data/lib/webrat/selenium/location_strategy_javascript/label.js +30 -3
- data/lib/webrat/selenium/location_strategy_javascript/webrat.js +1 -0
- data/lib/webrat/selenium/location_strategy_javascript/webratlink.js +24 -4
- data/lib/webrat/selenium/matchers/have_content.rb +22 -10
- data/lib/webrat/selenium/matchers/have_selector.rb +8 -0
- data/lib/webrat/selenium/matchers/have_xpath.rb +8 -0
- data/lib/webrat/selenium/selenium_rc_server.rb +8 -6
- data/lib/webrat/selenium/selenium_session.rb +43 -14
- data/lib/webrat/selenium/silence_stream.rb +2 -2
- data/spec/fakes/{test_session.rb → test_adapter.rb} +4 -5
- data/spec/integration/mechanize/Rakefile +7 -0
- data/spec/integration/mechanize/config.ru +2 -0
- data/spec/integration/mechanize/sample_app.rb +20 -0
- data/spec/integration/mechanize/spec/mechanize_spec.rb +22 -0
- data/spec/integration/mechanize/spec/spec_helper.rb +29 -0
- data/spec/integration/merb/app/controllers/testing.rb +9 -0
- data/spec/integration/merb/app/views/testing/upload.html.erb +9 -0
- data/spec/integration/merb/config/router.rb +1 -0
- data/spec/integration/merb/spec/spec_helper.rb +2 -0
- data/spec/integration/merb/spec/webrat_spec.rb +7 -0
- data/spec/integration/rack/app.rb +89 -0
- data/spec/integration/rack/test/helper.rb +21 -0
- data/spec/integration/rack/test/webrat_rack_test.rb +57 -51
- data/spec/integration/rails/app/controllers/{application.rb → application_controller.rb} +0 -0
- data/spec/integration/rails/app/controllers/webrat_controller.rb +16 -9
- data/spec/integration/rails/app/views/buttons/show.html.erb +0 -2
- data/spec/integration/rails/app/views/links/show.html.erb +2 -1
- data/spec/integration/rails/app/views/webrat/buttons.html.erb +0 -2
- data/spec/integration/rails/app/views/webrat/within.html.erb +3 -0
- data/spec/integration/rails/config/environment.rb +1 -1
- data/spec/integration/rails/config/routes.rb +2 -0
- data/spec/integration/rails/test/integration/button_click_test.rb +12 -26
- data/spec/integration/rails/test/integration/fill_in_test.rb +1 -1
- data/spec/integration/rails/test/integration/link_click_test.rb +8 -2
- data/spec/integration/rails/test/integration/webrat_test.rb +53 -5
- data/spec/integration/rails/test/test_helper.rb +7 -5
- data/spec/integration/sinatra/test/test_helper.rb +3 -2
- data/spec/private/core/configuration_spec.rb +8 -27
- data/spec/private/core/field_spec.rb +14 -16
- data/spec/private/core/link_spec.rb +1 -1
- data/spec/private/core/session_spec.rb +23 -26
- data/spec/private/mechanize/{mechanize_session_spec.rb → mechanize_adapter_spec.rb} +4 -12
- data/spec/private/nokogiri_spec.rb +2 -2
- data/spec/private/rails/{rails_session_spec.rb → rails_adapter_spec.rb} +11 -42
- data/spec/private/selenium/application_servers/rails_spec.rb +26 -0
- data/spec/public/basic_auth_spec.rb +13 -2
- data/spec/public/click_button_spec.rb +10 -12
- data/spec/public/click_link_spec.rb +21 -0
- data/spec/public/fill_in_spec.rb +15 -0
- data/spec/public/matchers/contain_spec.rb +12 -19
- data/spec/public/matchers/have_selector_spec.rb +6 -2
- data/spec/public/matchers/have_xpath_spec.rb +3 -3
- data/spec/public/save_and_open_spec.rb +15 -17
- data/spec/public/select_spec.rb +232 -26
- data/spec/public/selenium/application_server_factory_spec.rb +49 -0
- data/spec/public/selenium/application_servers/external_spec.rb +12 -0
- data/spec/public/selenium/selenium_session_spec.rb +37 -0
- data/spec/spec_helper.rb +5 -1
- data/vendor/selenium-server.jar +0 -0
- metadata +119 -69
- data/.dotest/0001 +0 -34
- data/.dotest/0002 +0 -34
- data/.dotest/binary +0 -1
- data/.dotest/final-commit +0 -1
- data/.dotest/head-name +0 -1
- data/.dotest/info +0 -5
- data/.dotest/keep +0 -1
- data/.dotest/last +0 -1
- data/.dotest/msg +0 -0
- data/.dotest/msg-clean +0 -0
- data/.dotest/next +0 -1
- data/.dotest/onto +0 -1
- data/.dotest/orig-head +0 -1
- data/.dotest/patch +0 -29
- data/.dotest/sign +0 -1
- data/.dotest/utf8 +0 -1
- data/.dotest/whitespace +0 -1
- data/VERSION +0 -1
- data/lib/webrat/core/xml/hpricot.rb +0 -19
- data/lib/webrat/core/xml/nokogiri.rb +0 -76
- data/lib/webrat/core/xml/rexml.rb +0 -24
- data/lib/webrat/merb_session.rb +0 -65
- data/lib/webrat/rack.rb +0 -24
- data/lib/webrat/rack_test.rb +0 -32
- data/lib/webrat/selenium/application_server.rb +0 -73
- data/lib/webrat/selenium/merb_application_server.rb +0 -48
- data/lib/webrat/selenium/rails_application_server.rb +0 -42
- data/lib/webrat/selenium/sinatra_application_server.rb +0 -35
- data/lib/webrat/sinatra.rb +0 -44
- data/spec/integration/rack/rack_app.rb +0 -16
- data/spec/integration/rack/test/test_helper.rb +0 -20
- data/spec/private/core/logging_spec.rb +0 -10
- data/spec/private/merb/merb_session_spec.rb +0 -42
@@ -61,6 +61,10 @@ describe "have_selector" do
|
|
61
61
|
@body.should have_selector("li", :count => 4)
|
62
62
|
}.should raise_error(Spec::Expectations::ExpectationNotMetError)
|
63
63
|
end
|
64
|
+
|
65
|
+
it "should convert a string to an integer for count" do
|
66
|
+
@body.should have_selector("li", :count => "3")
|
67
|
+
end
|
64
68
|
end
|
65
69
|
|
66
70
|
describe "specifying nested elements" do
|
@@ -122,7 +126,7 @@ describe "have_selector" do
|
|
122
126
|
it "should throw an exception when the body doesnt have matching selection" do
|
123
127
|
lambda {
|
124
128
|
assert_have_selector("p")
|
125
|
-
}.should raise_error(
|
129
|
+
}.should raise_error(AssertionFailedError)
|
126
130
|
end
|
127
131
|
end
|
128
132
|
|
@@ -134,7 +138,7 @@ describe "have_selector" do
|
|
134
138
|
it "should throw an exception when the body does contain the selection" do
|
135
139
|
lambda {
|
136
140
|
assert_have_no_selector("div")
|
137
|
-
}.should raise_error(
|
141
|
+
}.should raise_error(AssertionFailedError)
|
138
142
|
end
|
139
143
|
end
|
140
144
|
end
|
@@ -94,7 +94,7 @@ describe "have_xpath" do
|
|
94
94
|
node.should have_xpath("//a[@href='http://example.org']")
|
95
95
|
end
|
96
96
|
end
|
97
|
-
|
97
|
+
|
98
98
|
it "should allow descendant selectors in the block" do
|
99
99
|
@body.should have_xpath("//div[@id='main']") do |node|
|
100
100
|
node.should have_xpath("//ul//a")
|
@@ -117,7 +117,7 @@ describe "have_xpath" do
|
|
117
117
|
it "should throw an exception when the body doesnt have matching xpath" do
|
118
118
|
lambda {
|
119
119
|
assert_have_xpath("//p")
|
120
|
-
}.should raise_error(
|
120
|
+
}.should raise_error(AssertionFailedError)
|
121
121
|
end
|
122
122
|
end
|
123
123
|
|
@@ -129,7 +129,7 @@ describe "have_xpath" do
|
|
129
129
|
it "should throw an exception when the body does contain the xpath" do
|
130
130
|
lambda {
|
131
131
|
assert_have_no_xpath("//div")
|
132
|
-
}.should raise_error(
|
132
|
+
}.should raise_error(AssertionFailedError)
|
133
133
|
end
|
134
134
|
end
|
135
135
|
end
|
@@ -10,42 +10,40 @@ describe "save_and_open_page" do
|
|
10
10
|
<body>
|
11
11
|
<h1>Hello world</h1>
|
12
12
|
<img src="/images/bar.png" />
|
13
|
+
<img src='/images/foo.png' />
|
13
14
|
</body>
|
14
15
|
</html>
|
15
16
|
HTML
|
16
17
|
|
17
18
|
File.stub!(:exist? => true)
|
18
19
|
Time.stub!(:now => 1234)
|
19
|
-
|
20
|
+
|
21
|
+
require "launchy"
|
22
|
+
Launchy::Browser.stub!(:run)
|
20
23
|
|
21
24
|
@file_handle = mock("file handle")
|
22
|
-
File.stub!(:open).
|
25
|
+
File.stub!(:open).and_yield(@file_handle)
|
23
26
|
@file_handle.stub!(:write)
|
24
27
|
end
|
25
28
|
|
26
|
-
it "should
|
27
|
-
|
28
|
-
|
29
|
-
end
|
29
|
+
it "should save pages to the directory configured" do
|
30
|
+
Webrat.configuration.stub!(:saved_pages_dir => "path/to/dir")
|
31
|
+
File.should_receive(:open).with("path/to/dir/webrat-1234.html", "w").and_yield(@file_handle)
|
30
32
|
|
31
33
|
save_and_open_page
|
32
34
|
end
|
33
35
|
|
34
|
-
it "should
|
35
|
-
|
36
|
-
html.should =~ %r|#{webrat_session.doc_root}/images/bar.png|s
|
37
|
-
end
|
38
|
-
|
36
|
+
it "should open the temp file in a browser with Launchy" do
|
37
|
+
Launchy::Browser.should_receive(:run)
|
39
38
|
save_and_open_page
|
40
39
|
end
|
41
40
|
|
42
|
-
it "should
|
43
|
-
|
44
|
-
save_and_open_page
|
45
|
-
end
|
41
|
+
it "should fail gracefully if Launchy is not available" do
|
42
|
+
Launchy::Browser.should_receive(:run).and_raise(LoadError)
|
46
43
|
|
47
|
-
|
48
|
-
|
44
|
+
lambda do
|
45
|
+
save_and_open_page
|
46
|
+
end.should_not raise_error
|
49
47
|
end
|
50
48
|
|
51
49
|
end
|
data/spec/public/select_spec.rb
CHANGED
@@ -168,6 +168,36 @@ describe "select" do
|
|
168
168
|
click_button
|
169
169
|
end
|
170
170
|
|
171
|
+
it "should find options by regexp with HTML entities" do
|
172
|
+
with_html <<-HTML
|
173
|
+
<html>
|
174
|
+
<form method="post" action="/login">
|
175
|
+
<select name="month"><option>Peanut butter & jelly</option></select>
|
176
|
+
<input type="submit" />
|
177
|
+
</form>
|
178
|
+
</html>
|
179
|
+
HTML
|
180
|
+
|
181
|
+
webrat_session.should_receive(:post).with("/login", "month" => "Peanut butter & jelly")
|
182
|
+
select /Peanut butter & jelly/
|
183
|
+
click_button
|
184
|
+
end
|
185
|
+
|
186
|
+
it "should not find options by regexp with HTML entities in the regexp" do
|
187
|
+
with_html <<-HTML
|
188
|
+
<html>
|
189
|
+
<form method="post" action="/login">
|
190
|
+
<select name="month"><option>Peanut butter & jelly</option></select>
|
191
|
+
<input type="submit" />
|
192
|
+
</form>
|
193
|
+
</html>
|
194
|
+
HTML
|
195
|
+
|
196
|
+
lambda {
|
197
|
+
select /Peanut butter & jelly/
|
198
|
+
}.should raise_error(Webrat::NotFoundError)
|
199
|
+
end
|
200
|
+
|
171
201
|
it "should fail if no option matching the regexp exists" do
|
172
202
|
with_html <<-HTML
|
173
203
|
<html>
|
@@ -201,35 +231,47 @@ describe "select" do
|
|
201
231
|
end
|
202
232
|
|
203
233
|
it "should properly handle submitting HTML entities in select values" do
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
<
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
end
|
234
|
+
with_html <<-HTML
|
235
|
+
<html>
|
236
|
+
<form method="post" action="/login">
|
237
|
+
<select name="month"><option>Peanut butter & jelly</option></select>
|
238
|
+
<input type="submit" />
|
239
|
+
</form>
|
240
|
+
</html>
|
241
|
+
HTML
|
242
|
+
|
243
|
+
webrat_session.should_receive(:post).with("/login", "month" => "Peanut butter & jelly")
|
244
|
+
click_button
|
216
245
|
end
|
217
246
|
|
218
247
|
it "should properly handle locating with HTML entities in select values" do
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
<
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
248
|
+
with_html <<-HTML
|
249
|
+
<html>
|
250
|
+
<form method="post" action="/login">
|
251
|
+
<select name="month"><option>Peanut butter & jelly</option></select>
|
252
|
+
<input type="submit" />
|
253
|
+
</form>
|
254
|
+
</html>
|
255
|
+
HTML
|
256
|
+
|
257
|
+
webrat_session.should_receive(:post).with("/login", "month" => "Peanut butter & jelly")
|
258
|
+
select "Peanut butter & jelly"
|
259
|
+
click_button
|
260
|
+
end
|
261
|
+
|
262
|
+
it "should not locate based on HTML entities" do
|
263
|
+
with_html <<-HTML
|
264
|
+
<html>
|
265
|
+
<form method="post" action="/login">
|
266
|
+
<select name="month"><option>Peanut butter & jelly</option></select>
|
267
|
+
<input type="submit" />
|
268
|
+
</form>
|
269
|
+
</html>
|
270
|
+
HTML
|
271
|
+
|
272
|
+
lambda {
|
273
|
+
select "Peanut butter & jelly"
|
274
|
+
}.should raise_error(Webrat::NotFoundError)
|
233
275
|
end
|
234
276
|
|
235
277
|
it "should submit duplicates selected options as a single value" do
|
@@ -246,4 +288,168 @@ describe "select" do
|
|
246
288
|
click_button
|
247
289
|
end
|
248
290
|
|
291
|
+
it "should allow fields to be unselected" do
|
292
|
+
with_html <<-HTML
|
293
|
+
<html>
|
294
|
+
<form method="post" action="/login">
|
295
|
+
<select name="clothes">
|
296
|
+
<option value="tshirt" selected="selected">tshirt</option>
|
297
|
+
<option value="pants">pants</option>
|
298
|
+
</select>
|
299
|
+
<input type="submit" />
|
300
|
+
</form>
|
301
|
+
</html>
|
302
|
+
HTML
|
303
|
+
|
304
|
+
webrat_session.should_receive(:post).with("/login", {"clothes"=>""})
|
305
|
+
unselect "tshirt"
|
306
|
+
click_button
|
307
|
+
end
|
308
|
+
|
309
|
+
#
|
310
|
+
# Mutliple Selection Fields
|
311
|
+
#
|
312
|
+
|
313
|
+
it "should not submit any values for multiples without any selected" do
|
314
|
+
with_html <<-HTML
|
315
|
+
<html>
|
316
|
+
<form method="post" action="/login">
|
317
|
+
<select name="clothes[]" multiple="multiple">
|
318
|
+
<option value="tshirt">tshirt</option>
|
319
|
+
<option value="pants">pants</option>
|
320
|
+
</select>
|
321
|
+
<input type="submit" />
|
322
|
+
</form>
|
323
|
+
</html>
|
324
|
+
HTML
|
325
|
+
|
326
|
+
webrat_session.should_receive(:post).with("/login", {})
|
327
|
+
click_button
|
328
|
+
end
|
329
|
+
|
330
|
+
it "should submit with preselected values" do
|
331
|
+
with_html <<-HTML
|
332
|
+
<html>
|
333
|
+
<form method="post" action="/login">
|
334
|
+
<select name="clothes[]" multiple="multiple">
|
335
|
+
<option value="tshirt" selected="selected">tshirt</option>
|
336
|
+
<option value="pants" selected="selected">pants</option>
|
337
|
+
</select>
|
338
|
+
<input type="submit" />
|
339
|
+
</form>
|
340
|
+
</html>
|
341
|
+
HTML
|
342
|
+
|
343
|
+
webrat_session.should_receive(:post).with("/login", "clothes" => ['tshirt', 'pants'])
|
344
|
+
click_button
|
345
|
+
end
|
346
|
+
|
347
|
+
it "should allow selection of multiple fields" do
|
348
|
+
with_html <<-HTML
|
349
|
+
<html>
|
350
|
+
<form method="post" action="/login">
|
351
|
+
<select name="clothes[]" multiple="multiple">
|
352
|
+
<option value="tshirt">tshirt</option>
|
353
|
+
<option value="pants">pants</option>
|
354
|
+
</select>
|
355
|
+
<input type="submit" />
|
356
|
+
</form>
|
357
|
+
</html>
|
358
|
+
HTML
|
359
|
+
|
360
|
+
webrat_session.should_receive(:post).with("/login", "clothes" => ['pants'])
|
361
|
+
select 'pants'
|
362
|
+
click_button
|
363
|
+
end
|
364
|
+
|
365
|
+
it "should not overwrite preselected multiples" do
|
366
|
+
with_html <<-HTML
|
367
|
+
<html>
|
368
|
+
<form method="post" action="/login">
|
369
|
+
<select name="clothes[]" multiple="multiple">
|
370
|
+
<option value="tshirt" selected="selected">tshirt</option>
|
371
|
+
<option value="pants">pants</option>
|
372
|
+
</select>
|
373
|
+
<input type="submit" />
|
374
|
+
</form>
|
375
|
+
</html>
|
376
|
+
HTML
|
377
|
+
|
378
|
+
webrat_session.should_receive(:post).with("/login", "clothes" => ['tshirt', 'pants'])
|
379
|
+
select 'pants'
|
380
|
+
click_button
|
381
|
+
end
|
382
|
+
|
383
|
+
it "should allow fields that exist to be selected or throw errors" do
|
384
|
+
with_html <<-HTML
|
385
|
+
<html>
|
386
|
+
<form method="post" action="/login">
|
387
|
+
<select name="clothes[]" multiple="multiple">
|
388
|
+
<option value="top" selected="selected">shirt</option>
|
389
|
+
<option value="pants">trousers</option>
|
390
|
+
</select>
|
391
|
+
<input type="submit" />
|
392
|
+
</form>
|
393
|
+
</html>
|
394
|
+
HTML
|
395
|
+
|
396
|
+
lambda { select "shirt" }.should_not raise_error(Webrat::NotFoundError)
|
397
|
+
lambda { select "trousers" }.should_not raise_error(Webrat::NotFoundError)
|
398
|
+
lambda { select "shoes" }.should raise_error(Webrat::NotFoundError)
|
399
|
+
end
|
400
|
+
|
401
|
+
it "should allow selected fields to be unselected" do
|
402
|
+
with_html <<-HTML
|
403
|
+
<html>
|
404
|
+
<form method="post" action="/login">
|
405
|
+
<select name="clothes[]" multiple="multiple">
|
406
|
+
<option value="tshirt" selected="selected">tshirt</option>
|
407
|
+
<option value="pants" selected="selected">pants</option>
|
408
|
+
</select>
|
409
|
+
<input type="submit" />
|
410
|
+
</form>
|
411
|
+
</html>
|
412
|
+
HTML
|
413
|
+
|
414
|
+
webrat_session.should_receive(:post).with("/login", "clothes" => ['pants'])
|
415
|
+
unselect 'tshirt'
|
416
|
+
click_button
|
417
|
+
end
|
418
|
+
|
419
|
+
it "should be able to select options with special characters" do
|
420
|
+
with_html <<-HTML
|
421
|
+
<html>
|
422
|
+
<form method="post" action="/login">
|
423
|
+
<select name="clothes[]" multiple="multiple">
|
424
|
+
<option>tshirt & sweater</option>
|
425
|
+
<option>pants & socks</option>
|
426
|
+
</select>
|
427
|
+
<input type="submit" />
|
428
|
+
</form>
|
429
|
+
</html>
|
430
|
+
HTML
|
431
|
+
|
432
|
+
webrat_session.should_receive(:post).with("/login", "clothes" => ['pants & socks'])
|
433
|
+
select 'pants & socks'
|
434
|
+
click_button
|
435
|
+
end
|
436
|
+
|
437
|
+
it "should be able to unselect options with special characters" do
|
438
|
+
with_html <<-HTML
|
439
|
+
<html>
|
440
|
+
<form method="post" action="/login">
|
441
|
+
<select name="clothes[]" multiple="multiple">
|
442
|
+
<option selected="selected">tshirt & sweater</option>
|
443
|
+
<option selected="selected">pants & socks</option>
|
444
|
+
</select>
|
445
|
+
<input type="submit" />
|
446
|
+
</form>
|
447
|
+
</html>
|
448
|
+
HTML
|
449
|
+
|
450
|
+
webrat_session.should_receive(:post).with("/login", "clothes" => ['tshirt & sweater'])
|
451
|
+
unselect 'pants & socks'
|
452
|
+
click_button
|
453
|
+
end
|
454
|
+
|
249
455
|
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
|
2
|
+
|
3
|
+
require "webrat/selenium/silence_stream"
|
4
|
+
require "webrat/selenium/application_server_factory"
|
5
|
+
|
6
|
+
require "webrat/selenium/application_servers"
|
7
|
+
|
8
|
+
describe Webrat::Selenium::ApplicationServerFactory do
|
9
|
+
|
10
|
+
it "should require and create a sinatra server in sinatra mode" do
|
11
|
+
server = mock(Webrat::Selenium::ApplicationServers::Sinatra)
|
12
|
+
Webrat.configuration.application_framework = :sinatra
|
13
|
+
Webrat::Selenium::ApplicationServerFactory.should_receive(:require).with("webrat/selenium/application_servers/sinatra")
|
14
|
+
Webrat::Selenium::ApplicationServers::Sinatra.should_receive(:new).and_return(server)
|
15
|
+
Webrat::Selenium::ApplicationServerFactory.app_server_instance.should == server
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should require and create a merb server in merb mode" do
|
19
|
+
server = mock(Webrat::Selenium::ApplicationServers::Merb)
|
20
|
+
Webrat.configuration.application_framework = :merb
|
21
|
+
Webrat::Selenium::ApplicationServerFactory.should_receive(:require).with("webrat/selenium/application_servers/merb")
|
22
|
+
Webrat::Selenium::ApplicationServers::Merb.should_receive(:new).and_return(server)
|
23
|
+
Webrat::Selenium::ApplicationServerFactory.app_server_instance
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should require and create a rails server in rails mode" do
|
27
|
+
server = mock(Webrat::Selenium::ApplicationServers::Rails)
|
28
|
+
Webrat.configuration.application_framework = :rails
|
29
|
+
Webrat::Selenium::ApplicationServerFactory.should_receive(:require).with("webrat/selenium/application_servers/rails")
|
30
|
+
Webrat::Selenium::ApplicationServers::Rails.should_receive(:new).and_return(server)
|
31
|
+
Webrat::Selenium::ApplicationServerFactory.app_server_instance
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should require and create a rails server in external mode" do
|
35
|
+
server = mock(Webrat::Selenium::ApplicationServers::External)
|
36
|
+
Webrat.configuration.application_framework = :external
|
37
|
+
Webrat::Selenium::ApplicationServerFactory.should_receive(:require).with("webrat/selenium/application_servers/external")
|
38
|
+
Webrat::Selenium::ApplicationServers::External.should_receive(:new).and_return(server)
|
39
|
+
Webrat::Selenium::ApplicationServerFactory.app_server_instance
|
40
|
+
end
|
41
|
+
|
42
|
+
it "should handle unknown servers with an exception in unknown modes" do
|
43
|
+
Webrat.configuration.application_framework = :unknown
|
44
|
+
lambda {
|
45
|
+
Webrat::Selenium::ApplicationServerFactory.app_server_instance
|
46
|
+
}.should raise_error(Webrat::WebratError)
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
|
2
|
+
|
3
|
+
require "webrat/selenium/application_servers/base"
|
4
|
+
require "webrat/selenium/application_servers/external"
|
5
|
+
|
6
|
+
describe Webrat::Selenium::ApplicationServers::External do
|
7
|
+
|
8
|
+
it "should just boot up with no exceptions" do
|
9
|
+
Webrat::Selenium::ApplicationServers::External.new.boot
|
10
|
+
end
|
11
|
+
|
12
|
+
end
|