webrat 0.7.1 → 0.7.2.beta.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/lib/webrat.rb +1 -1
- data/lib/webrat/core/locators/link_locator.rb +15 -7
- data/lib/webrat/core/locators/select_option_locator.rb +1 -1
- data/lib/webrat/core/methods.rb +9 -0
- data/lib/webrat/core/save_and_open_page.rb +1 -1
- data/lib/webrat/integrations/rack.rb +9 -0
- data/lib/webrat/selenium/application_server_factory.rb +3 -0
- data/lib/webrat/selenium/application_servers/rack.rb +36 -0
- data/lib/webrat/selenium/application_servers/rails.rb +3 -3
- data/lib/webrat/selenium/selenium_session.rb +6 -2
- data/spec/public/click_link_spec.rb +12 -0
- data/spec/public/select_spec.rb +19 -0
- data/vendor/selenium-server.jar +0 -0
- data/webrat.gemspec +7 -5
- metadata +24 -7
data/lib/webrat.rb
CHANGED
@@ -10,7 +10,11 @@ module Webrat
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def link_element
|
13
|
-
matching_links.min { |a, b|
|
13
|
+
matching_links.min { |a, b|
|
14
|
+
a_score = a.inner_text =~ matcher ? a.inner_text.length : 100
|
15
|
+
b_score = b.inner_text =~ matcher ? b.inner_text.length : 100
|
16
|
+
a_score <=> b_score
|
17
|
+
}
|
14
18
|
end
|
15
19
|
|
16
20
|
def matching_links
|
@@ -21,16 +25,20 @@ module Webrat
|
|
21
25
|
end
|
22
26
|
|
23
27
|
def matches_text?(link)
|
24
|
-
if @value.is_a?(Regexp)
|
25
|
-
matcher = @value
|
26
|
-
else
|
27
|
-
matcher = /#{Regexp.escape(@value.to_s)}/i
|
28
|
-
end
|
29
|
-
|
30
28
|
replace_nbsp(link.inner_text) =~ matcher ||
|
31
29
|
replace_nbsp_ref(link.inner_html) =~ matcher ||
|
32
30
|
link["title"] =~ matcher
|
33
31
|
end
|
32
|
+
|
33
|
+
def matcher
|
34
|
+
@matcher ||= begin
|
35
|
+
if @value.is_a?(Regexp)
|
36
|
+
@value
|
37
|
+
else
|
38
|
+
/#{Regexp.escape(@value.to_s)}/i
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
34
42
|
|
35
43
|
def matches_id?(link)
|
36
44
|
if @value.is_a?(Regexp)
|
@@ -15,7 +15,7 @@ module Webrat
|
|
15
15
|
|
16
16
|
def locate
|
17
17
|
if @id_or_name_or_label
|
18
|
-
field = FieldLocator.new(@session, @dom, @id_or_name_or_label, SelectField).locate!
|
18
|
+
field = FieldLocator.new(@session, @dom, @id_or_name_or_label, SelectField, MultipleSelectField).locate!
|
19
19
|
|
20
20
|
field.options.detect do |o|
|
21
21
|
if @option_text.is_a?(Regexp)
|
data/lib/webrat/core/methods.rb
CHANGED
@@ -23,6 +23,15 @@ module Webrat
|
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
|
+
# Temporary hack to work with Rails 3
|
27
|
+
def response
|
28
|
+
if Webrat.configuration.mode == :rack
|
29
|
+
webrat_session.response
|
30
|
+
else
|
31
|
+
super
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
26
35
|
# all of these methods delegate to the @session, which should
|
27
36
|
# be created transparently.
|
28
37
|
#
|
@@ -14,6 +14,9 @@ module Webrat
|
|
14
14
|
when :rails
|
15
15
|
require "webrat/selenium/application_servers/rails"
|
16
16
|
return Webrat::Selenium::ApplicationServers::Rails.new
|
17
|
+
when :rack
|
18
|
+
require "webrat/selenium/application_servers/rack"
|
19
|
+
return Webrat::Selenium::ApplicationServers::Rack.new
|
17
20
|
when :external
|
18
21
|
require "webrat/selenium/application_servers/external"
|
19
22
|
return Webrat::Selenium::ApplicationServers::External.new
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require "webrat/selenium/application_servers/base"
|
2
|
+
|
3
|
+
module Webrat
|
4
|
+
module Selenium
|
5
|
+
module ApplicationServers
|
6
|
+
class Rack < Webrat::Selenium::ApplicationServers::Base
|
7
|
+
|
8
|
+
def start
|
9
|
+
@pid = fork do
|
10
|
+
exec start_command
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def stop
|
15
|
+
Process.kill("TERM", @pid)
|
16
|
+
end
|
17
|
+
|
18
|
+
def fail
|
19
|
+
$stderr.puts
|
20
|
+
$stderr.puts
|
21
|
+
$stderr.puts "==> Failed to boot the application server... exiting!"
|
22
|
+
$stderr.puts
|
23
|
+
$stderr.puts "Verify you can start a server on port #{Webrat.configuration.application_port} with the following command:"
|
24
|
+
$stderr.puts
|
25
|
+
$stderr.puts " #{start_command}"
|
26
|
+
exit
|
27
|
+
end
|
28
|
+
|
29
|
+
def start_command
|
30
|
+
"rackup --port #{Webrat.configuration.application_port} --env #{Webrat.configuration.application_environment}"
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -27,15 +27,15 @@ module Webrat
|
|
27
27
|
end
|
28
28
|
|
29
29
|
def pid_file
|
30
|
-
prepare_pid_file("#{
|
30
|
+
prepare_pid_file("#{::Rails.root}/tmp/pids", "mongrel_selenium.pid")
|
31
31
|
end
|
32
32
|
|
33
33
|
def start_command
|
34
|
-
|
34
|
+
"mongrel_rails start -d --chdir='#{::Rails.root}' --port=#{Webrat.configuration.application_port} --environment=#{Webrat.configuration.application_environment} --pid #{pid_file} &"
|
35
35
|
end
|
36
36
|
|
37
37
|
def stop_command
|
38
|
-
|
38
|
+
"mongrel_rails stop -c #{::Rails.root} --pid #{pid_file}"
|
39
39
|
end
|
40
40
|
|
41
41
|
end
|
@@ -236,8 +236,12 @@ EOS
|
|
236
236
|
|
237
237
|
|
238
238
|
def create_browser
|
239
|
-
$browser = ::Selenium::Client::Driver.new(
|
240
|
-
|
239
|
+
$browser = ::Selenium::Client::Driver.new(
|
240
|
+
Webrat.configuration.selenium_server_address || "localhost",
|
241
|
+
Webrat.configuration.selenium_server_port,
|
242
|
+
Webrat.configuration.selenium_browser_key,
|
243
|
+
"http://#{Webrat.configuration.application_address}:#{Webrat.configuration.application_port_for_selenium}"
|
244
|
+
)
|
241
245
|
$browser.set_speed(0) unless Webrat.configuration.selenium_server_address
|
242
246
|
|
243
247
|
at_exit do
|
@@ -370,6 +370,18 @@ describe "click_link" do
|
|
370
370
|
click_link "Link"
|
371
371
|
end
|
372
372
|
|
373
|
+
it "should choose the shortest link text match, preferring text" do
|
374
|
+
with_html <<-HTML
|
375
|
+
<html>
|
376
|
+
<a href="/page1">Linkerama</a>
|
377
|
+
<a title="Link" href="/page2">Foo</a>
|
378
|
+
</html>
|
379
|
+
HTML
|
380
|
+
|
381
|
+
webrat_session.should_receive(:get).with("/page1", {})
|
382
|
+
click_link "Link"
|
383
|
+
end
|
384
|
+
|
373
385
|
it "should treat non-breaking spaces as spaces" do
|
374
386
|
with_html <<-HTML
|
375
387
|
<html>
|
data/spec/public/select_spec.rb
CHANGED
@@ -362,6 +362,25 @@ describe "select" do
|
|
362
362
|
click_button
|
363
363
|
end
|
364
364
|
|
365
|
+
it "should allow selection of multiple fields when including from" do
|
366
|
+
with_html <<-HTML
|
367
|
+
<html>
|
368
|
+
<form method="post" action="/login">
|
369
|
+
<select name="clothes[]" multiple="multiple">
|
370
|
+
<option value="tshirt">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" => ['pants'])
|
379
|
+
select 'pants', :from => 'clothes[]'
|
380
|
+
click_button
|
381
|
+
end
|
382
|
+
|
383
|
+
|
365
384
|
it "should not overwrite preselected multiples" do
|
366
385
|
with_html <<-HTML
|
367
386
|
<html>
|
data/vendor/selenium-server.jar
CHANGED
Binary file
|
data/webrat.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{webrat}
|
5
|
-
s.version = "0.7.1"
|
5
|
+
s.version = "0.7.2.beta.1"
|
6
6
|
|
7
|
-
s.required_rubygems_version = Gem::Requirement.new("
|
7
|
+
s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Bryan Helmkamp"]
|
9
|
-
s.date = %q{2010-
|
9
|
+
s.date = %q{2010-07-25}
|
10
10
|
s.description = %q{Webrat lets you quickly write expressive and robust acceptance tests
|
11
11
|
for a Ruby web application. It supports simulating a browser inside
|
12
12
|
a Ruby process to avoid the performance hit and browser dependency of
|
@@ -75,6 +75,7 @@ Most Ruby web frameworks and testing frameworks are supported.}
|
|
75
75
|
"lib/webrat/core_extensions/nil_to_query_string.rb",
|
76
76
|
"lib/webrat/core_extensions/tcp_socket.rb",
|
77
77
|
"lib/webrat/integrations/merb.rb",
|
78
|
+
"lib/webrat/integrations/rack.rb",
|
78
79
|
"lib/webrat/integrations/rails.rb",
|
79
80
|
"lib/webrat/integrations/rspec-rails.rb",
|
80
81
|
"lib/webrat/integrations/selenium.rb",
|
@@ -86,6 +87,7 @@ Most Ruby web frameworks and testing frameworks are supported.}
|
|
86
87
|
"lib/webrat/selenium/application_servers/base.rb",
|
87
88
|
"lib/webrat/selenium/application_servers/external.rb",
|
88
89
|
"lib/webrat/selenium/application_servers/merb.rb",
|
90
|
+
"lib/webrat/selenium/application_servers/rack.rb",
|
89
91
|
"lib/webrat/selenium/application_servers/rails.rb",
|
90
92
|
"lib/webrat/selenium/application_servers/sinatra.rb",
|
91
93
|
"lib/webrat/selenium/location_strategy_javascript/button.js",
|
@@ -239,7 +241,7 @@ Most Ruby web frameworks and testing frameworks are supported.}
|
|
239
241
|
s.homepage = %q{http://github.com/brynary/webrat}
|
240
242
|
s.require_paths = ["lib"]
|
241
243
|
s.rubyforge_project = %q{webrat}
|
242
|
-
s.rubygems_version = %q{1.3.
|
244
|
+
s.rubygems_version = %q{1.3.7}
|
243
245
|
s.summary = %q{Ruby Acceptance Testing for Web applications}
|
244
246
|
s.test_files = [
|
245
247
|
"spec/fakes/test_adapter.rb",
|
@@ -336,7 +338,7 @@ Most Ruby web frameworks and testing frameworks are supported.}
|
|
336
338
|
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
337
339
|
s.specification_version = 3
|
338
340
|
|
339
|
-
if Gem::Version.new(Gem::
|
341
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
340
342
|
s.add_runtime_dependency(%q<nokogiri>, [">= 1.2.0"])
|
341
343
|
s.add_runtime_dependency(%q<rack>, [">= 1.0"])
|
342
344
|
s.add_runtime_dependency(%q<rack-test>, [">= 0.5.3"])
|
metadata
CHANGED
@@ -1,12 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: webrat
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
hash: 62196417
|
5
|
+
prerelease: true
|
5
6
|
segments:
|
6
7
|
- 0
|
7
8
|
- 7
|
9
|
+
- 2
|
10
|
+
- beta
|
8
11
|
- 1
|
9
|
-
version: 0.7.1
|
12
|
+
version: 0.7.2.beta.1
|
10
13
|
platform: ruby
|
11
14
|
authors:
|
12
15
|
- Bryan Helmkamp
|
@@ -14,16 +17,18 @@ autorequire:
|
|
14
17
|
bindir: bin
|
15
18
|
cert_chain: []
|
16
19
|
|
17
|
-
date: 2010-
|
20
|
+
date: 2010-07-25 00:00:00 -04:00
|
18
21
|
default_executable:
|
19
22
|
dependencies:
|
20
23
|
- !ruby/object:Gem::Dependency
|
21
24
|
name: nokogiri
|
22
25
|
prerelease: false
|
23
26
|
requirement: &id001 !ruby/object:Gem::Requirement
|
27
|
+
none: false
|
24
28
|
requirements:
|
25
29
|
- - ">="
|
26
30
|
- !ruby/object:Gem::Version
|
31
|
+
hash: 31
|
27
32
|
segments:
|
28
33
|
- 1
|
29
34
|
- 2
|
@@ -35,9 +40,11 @@ dependencies:
|
|
35
40
|
name: rack
|
36
41
|
prerelease: false
|
37
42
|
requirement: &id002 !ruby/object:Gem::Requirement
|
43
|
+
none: false
|
38
44
|
requirements:
|
39
45
|
- - ">="
|
40
46
|
- !ruby/object:Gem::Version
|
47
|
+
hash: 15
|
41
48
|
segments:
|
42
49
|
- 1
|
43
50
|
- 0
|
@@ -48,9 +55,11 @@ dependencies:
|
|
48
55
|
name: rack-test
|
49
56
|
prerelease: false
|
50
57
|
requirement: &id003 !ruby/object:Gem::Requirement
|
58
|
+
none: false
|
51
59
|
requirements:
|
52
60
|
- - ">="
|
53
61
|
- !ruby/object:Gem::Version
|
62
|
+
hash: 13
|
54
63
|
segments:
|
55
64
|
- 0
|
56
65
|
- 5
|
@@ -130,6 +139,7 @@ files:
|
|
130
139
|
- lib/webrat/core_extensions/nil_to_query_string.rb
|
131
140
|
- lib/webrat/core_extensions/tcp_socket.rb
|
132
141
|
- lib/webrat/integrations/merb.rb
|
142
|
+
- lib/webrat/integrations/rack.rb
|
133
143
|
- lib/webrat/integrations/rails.rb
|
134
144
|
- lib/webrat/integrations/rspec-rails.rb
|
135
145
|
- lib/webrat/integrations/selenium.rb
|
@@ -141,6 +151,7 @@ files:
|
|
141
151
|
- lib/webrat/selenium/application_servers/base.rb
|
142
152
|
- lib/webrat/selenium/application_servers/external.rb
|
143
153
|
- lib/webrat/selenium/application_servers/merb.rb
|
154
|
+
- lib/webrat/selenium/application_servers/rack.rb
|
144
155
|
- lib/webrat/selenium/application_servers/rails.rb
|
145
156
|
- lib/webrat/selenium/application_servers/sinatra.rb
|
146
157
|
- lib/webrat/selenium/location_strategy_javascript/button.js
|
@@ -300,23 +311,29 @@ rdoc_options: []
|
|
300
311
|
require_paths:
|
301
312
|
- lib
|
302
313
|
required_ruby_version: !ruby/object:Gem::Requirement
|
314
|
+
none: false
|
303
315
|
requirements:
|
304
316
|
- - ">="
|
305
317
|
- !ruby/object:Gem::Version
|
318
|
+
hash: 3
|
306
319
|
segments:
|
307
320
|
- 0
|
308
321
|
version: "0"
|
309
322
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
323
|
+
none: false
|
310
324
|
requirements:
|
311
|
-
- - "
|
325
|
+
- - ">"
|
312
326
|
- !ruby/object:Gem::Version
|
327
|
+
hash: 25
|
313
328
|
segments:
|
314
|
-
-
|
315
|
-
|
329
|
+
- 1
|
330
|
+
- 3
|
331
|
+
- 1
|
332
|
+
version: 1.3.1
|
316
333
|
requirements: []
|
317
334
|
|
318
335
|
rubyforge_project: webrat
|
319
|
-
rubygems_version: 1.3.
|
336
|
+
rubygems_version: 1.3.7
|
320
337
|
signing_key:
|
321
338
|
specification_version: 3
|
322
339
|
summary: Ruby Acceptance Testing for Web applications
|