diabolo-webrat 0.4.4.2 → 0.5.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/.document +4 -0
- data/.gitignore +15 -0
- data/History.txt +60 -9
- data/Rakefile +90 -75
- data/VERSION +1 -0
- data/lib/webrat.rb +8 -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} +9 -18
- data/lib/webrat/adapters/sinatra.rb +9 -0
- data/lib/webrat/core.rb +0 -1
- data/lib/webrat/core/configuration.rb +7 -17
- 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 +33 -30
- 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 +7 -6
- data/lib/webrat/core/elements/select_option.rb +2 -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 +20 -12
- data/lib/webrat/core/locators/select_option_locator.rb +5 -5
- data/lib/webrat/core/logging.rb +1 -1
- data/lib/webrat/core/matchers/have_content.rb +2 -7
- data/lib/webrat/core/matchers/have_xpath.rb +2 -27
- data/lib/webrat/core/methods.rb +4 -4
- data/lib/webrat/core/mime.rb +11 -22
- data/lib/webrat/core/save_and_open_page.rb +5 -7
- data/lib/webrat/core/scope.rb +2 -2
- data/lib/webrat/core/session.rb +30 -14
- data/lib/webrat/core/xml.rb +41 -84
- data/lib/webrat/integrations/merb.rb +10 -0
- data/lib/webrat/integrations/rails.rb +9 -0
- data/lib/webrat/integrations/rspec-rails.rb +10 -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 +2 -1
- data/lib/webrat/selenium/selenium_rc_server.rb +7 -5
- data/lib/webrat/selenium/selenium_session.rb +20 -7
- data/lib/webrat/selenium/silence_stream.rb +1 -1
- data/spec/fakes/{test_session.rb → test_adapter.rb} +6 -3
- 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 +27 -0
- data/spec/integration/merb/.gitignore +21 -0
- data/spec/integration/merb/Rakefile +35 -0
- data/spec/integration/merb/app/controllers/testing.rb +9 -0
- data/spec/integration/merb/app/views/exceptions/not_acceptable.html.erb +63 -0
- data/spec/integration/merb/app/views/exceptions/not_found.html.erb +47 -0
- data/spec/integration/merb/app/views/layout/application.html.erb +12 -0
- data/spec/integration/merb/app/views/testing/show_form.html.erb +27 -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.opts +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/merb/tasks/merb.thor/main.thor +150 -0
- data/spec/integration/rack/Rakefile +5 -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/.gitignore +3 -0
- data/spec/integration/rails/Rakefile +30 -0
- data/spec/integration/rails/app/controllers/webrat_controller.rb +13 -9
- data/spec/integration/rails/app/views/buttons/show.html.erb +11 -0
- data/spec/integration/rails/app/views/fields/show.html.erb +9 -0
- data/spec/integration/rails/app/views/links/show.html.erb +5 -0
- data/spec/integration/rails/app/views/webrat/before_redirect_form.html.erb +4 -0
- data/spec/integration/rails/app/views/webrat/buttons.html.erb +11 -0
- data/spec/integration/rails/app/views/webrat/form.html.erb +28 -0
- data/spec/integration/rails/config/locales/en.yml +5 -0
- data/spec/integration/rails/config/routes.rb +1 -0
- data/spec/integration/rails/public/404.html +30 -0
- data/spec/integration/rails/public/422.html +30 -0
- data/spec/integration/rails/public/500.html +33 -0
- data/spec/integration/rails/script/about +4 -0
- data/spec/integration/rails/script/console +3 -0
- data/spec/integration/rails/script/dbconsole +3 -0
- data/spec/integration/rails/script/destroy +3 -0
- data/spec/integration/rails/script/generate +3 -0
- data/spec/integration/rails/script/performance/benchmarker +3 -0
- data/spec/integration/rails/script/performance/profiler +3 -0
- data/spec/integration/rails/script/performance/request +3 -0
- data/spec/integration/rails/script/plugin +3 -0
- data/spec/integration/rails/script/process/inspector +3 -0
- data/spec/integration/rails/script/process/reaper +3 -0
- data/spec/integration/rails/script/process/spawner +3 -0
- data/spec/integration/rails/script/runner +3 -0
- data/spec/integration/rails/script/server +3 -0
- data/spec/integration/rails/test/integration/button_click_test.rb +2 -2
- data/spec/integration/rails/test/integration/link_click_test.rb +7 -1
- data/spec/integration/rails/test/integration/webrat_test.rb +22 -0
- data/spec/integration/rails/test/test_helper.rb +6 -5
- data/spec/integration/sinatra/Rakefile +5 -0
- 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 +7 -7
- data/spec/private/core/link_spec.rb +1 -1
- data/spec/private/core/session_spec.rb +23 -21
- 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} +16 -16
- data/spec/private/selenium/application_servers/rails_spec.rb +26 -0
- data/spec/public/matchers/contain_spec.rb +4 -4
- data/spec/public/matchers/have_selector_spec.rb +2 -2
- data/spec/public/matchers/have_xpath_spec.rb +3 -3
- data/spec/public/save_and_open_spec.rb +25 -6
- 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/rcov.opts +1 -0
- data/spec/spec.opts +2 -0
- data/spec/spec_helper.rb +5 -1
- data/vendor/selenium-server.jar +0 -0
- data/webrat.gemspec +348 -0
- metadata +176 -23
- 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/merb/merb_session_spec.rb +0 -42
data/lib/webrat/core/xml.rb
CHANGED
|
@@ -1,115 +1,72 @@
|
|
|
1
|
-
require "webrat/
|
|
2
|
-
require "webrat/core/xml/hpricot"
|
|
3
|
-
require "webrat/core/xml/rexml"
|
|
1
|
+
require "webrat/core_extensions/meta_class"
|
|
4
2
|
|
|
5
3
|
module Webrat #:nodoc:
|
|
6
4
|
module XML #:nodoc:
|
|
7
5
|
|
|
8
6
|
def self.document(stringlike) #:nodoc:
|
|
9
|
-
if
|
|
10
|
-
|
|
7
|
+
return stringlike.dom if stringlike.respond_to?(:dom)
|
|
8
|
+
|
|
9
|
+
if Nokogiri::HTML::Document === stringlike
|
|
10
|
+
stringlike
|
|
11
|
+
elsif Nokogiri::XML::NodeSet === stringlike
|
|
12
|
+
stringlike
|
|
13
|
+
elsif stringlike.respond_to?(:body)
|
|
14
|
+
Nokogiri::HTML(stringlike.body.to_s)
|
|
11
15
|
else
|
|
12
|
-
|
|
16
|
+
Nokogiri::HTML(stringlike.to_s)
|
|
13
17
|
end
|
|
14
18
|
end
|
|
15
19
|
|
|
16
20
|
def self.html_document(stringlike) #:nodoc:
|
|
17
|
-
if
|
|
18
|
-
|
|
21
|
+
return stringlike.dom if stringlike.respond_to?(:dom)
|
|
22
|
+
|
|
23
|
+
if Nokogiri::HTML::Document === stringlike
|
|
24
|
+
stringlike
|
|
25
|
+
elsif Nokogiri::XML::NodeSet === stringlike
|
|
26
|
+
stringlike
|
|
27
|
+
elsif stringlike.respond_to?(:body)
|
|
28
|
+
Nokogiri::HTML(stringlike.body.to_s)
|
|
19
29
|
else
|
|
20
|
-
|
|
30
|
+
Nokogiri::HTML(stringlike.to_s)
|
|
21
31
|
end
|
|
22
32
|
end
|
|
23
33
|
|
|
24
34
|
def self.xml_document(stringlike) #:nodoc:
|
|
25
|
-
if
|
|
26
|
-
|
|
35
|
+
return stringlike.dom if stringlike.respond_to?(:dom)
|
|
36
|
+
|
|
37
|
+
if Nokogiri::HTML::Document === stringlike
|
|
38
|
+
stringlike
|
|
39
|
+
elsif Nokogiri::XML::NodeSet === stringlike
|
|
40
|
+
stringlike
|
|
41
|
+
elsif stringlike.respond_to?(:body)
|
|
42
|
+
Nokogiri::XML(stringlike.body.to_s)
|
|
27
43
|
else
|
|
28
|
-
|
|
44
|
+
Nokogiri::XML(stringlike.to_s)
|
|
29
45
|
end
|
|
30
46
|
end
|
|
31
47
|
|
|
32
|
-
def self.
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
else
|
|
36
|
-
element.to_s
|
|
48
|
+
def self.define_dom_method(object, dom) #:nodoc:
|
|
49
|
+
object.meta_class.send(:define_method, :dom) do
|
|
50
|
+
dom
|
|
37
51
|
end
|
|
38
52
|
end
|
|
39
53
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
element.inner_html
|
|
43
|
-
else
|
|
44
|
-
element.text
|
|
45
|
-
end
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
def self.all_inner_text(element)
|
|
49
|
-
if Webrat.configuration.parse_with_nokogiri?
|
|
50
|
-
element.inner_text
|
|
51
|
-
else
|
|
52
|
-
Hpricot(element.to_s).children.first.inner_text
|
|
53
|
-
end
|
|
54
|
-
end
|
|
54
|
+
end
|
|
55
|
+
end
|
|
55
56
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
else
|
|
60
|
-
if defined?(Hpricot::Doc) && element.is_a?(Hpricot::Doc)
|
|
61
|
-
element.inner_text
|
|
62
|
-
else
|
|
63
|
-
element.text
|
|
64
|
-
end
|
|
65
|
-
end
|
|
66
|
-
end
|
|
57
|
+
module Nokogiri #:nodoc:
|
|
58
|
+
module CSS #:nodoc:
|
|
59
|
+
class XPathVisitor #:nodoc:
|
|
67
60
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
element.path
|
|
71
|
-
else
|
|
72
|
-
element.xpath
|
|
61
|
+
def visit_pseudo_class_text(node) #:nodoc:
|
|
62
|
+
"@type='text'"
|
|
73
63
|
end
|
|
74
|
-
end
|
|
75
|
-
|
|
76
|
-
def self.attribute(element, attribute_name)
|
|
77
|
-
return element[attribute_name] if element.is_a?(Hash)
|
|
78
64
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
else
|
|
82
|
-
element.attributes[attribute_name]
|
|
65
|
+
def visit_pseudo_class_password(node) #:nodoc:
|
|
66
|
+
"@type='password'"
|
|
83
67
|
end
|
|
84
|
-
end
|
|
85
|
-
|
|
86
|
-
def self.xpath_at(*args)
|
|
87
|
-
xpath_search(*args).first
|
|
88
|
-
end
|
|
89
|
-
|
|
90
|
-
def self.css_at(*args)
|
|
91
|
-
css_search(*args).first
|
|
92
|
-
end
|
|
93
|
-
|
|
94
|
-
def self.xpath_search(element, *searches)
|
|
95
|
-
searches.flatten.map do |search|
|
|
96
|
-
if Webrat.configuration.parse_with_nokogiri?
|
|
97
|
-
element.xpath(search)
|
|
98
|
-
else
|
|
99
|
-
REXML::XPath.match(element, search)
|
|
100
|
-
end
|
|
101
|
-
end.flatten.compact
|
|
102
|
-
end
|
|
103
68
|
|
|
104
|
-
def self.css_search(element, *searches) #:nodoc:
|
|
105
|
-
xpath_search(element, css_to_xpath(*searches))
|
|
106
69
|
end
|
|
107
|
-
|
|
108
|
-
def self.css_to_xpath(*selectors)
|
|
109
|
-
selectors.map do |rule|
|
|
110
|
-
Nokogiri::CSS.xpath_for(rule, :prefix => ".//")
|
|
111
|
-
end.flatten.uniq
|
|
112
|
-
end
|
|
113
|
-
|
|
114
70
|
end
|
|
115
71
|
end
|
|
72
|
+
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# Supports using the matchers in controller, helper, and view specs if you're
|
|
2
|
+
# using rspec-rails. Just add a require statement to spec/spec_helper.rb or env.rb:
|
|
3
|
+
#
|
|
4
|
+
# require 'webrat/rspec-rails'
|
|
5
|
+
#
|
|
6
|
+
require "webrat/core/matchers"
|
|
7
|
+
|
|
8
|
+
Spec::Runner.configure do |config|
|
|
9
|
+
config.include(Webrat::Matchers, :type => [:controller, :helper, :view])
|
|
10
|
+
end
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
require "webrat/selenium"
|
|
2
|
+
|
|
3
|
+
if defined?(ActionController::IntegrationTest)
|
|
4
|
+
module ActionController #:nodoc:
|
|
5
|
+
IntegrationTest.class_eval do
|
|
6
|
+
include Webrat::Methods
|
|
7
|
+
include Webrat::Selenium::Methods
|
|
8
|
+
include Webrat::Selenium::Matchers
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
end
|
data/lib/webrat/rspec-rails.rb
CHANGED
|
@@ -1,13 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
#
|
|
4
|
-
# require 'webrat/rspec-rails'
|
|
5
|
-
#
|
|
6
|
-
require "webrat/core/matchers"
|
|
7
|
-
|
|
8
|
-
Spec::Runner.configure do |config|
|
|
9
|
-
# rspec should support :type => [:controller, :helper, :view] - but until it does ...
|
|
10
|
-
config.include(Webrat::Matchers, :type => :controller)
|
|
11
|
-
config.include(Webrat::Matchers, :type => :helper)
|
|
12
|
-
config.include(Webrat::Matchers, :type => :view)
|
|
13
|
-
end
|
|
1
|
+
warn("Requiring 'webrat/rspec-rails' is deprecated. Please require 'webrat/integrations/rspec-rails' instead")
|
|
2
|
+
require "webrat/integrations/rspec-rails"
|
data/lib/webrat/selenium.rb
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
require "webrat"
|
|
2
|
-
gem "selenium-client", ">=1.2.14"
|
|
3
2
|
require "selenium/client"
|
|
4
3
|
require "webrat/selenium/silence_stream"
|
|
5
4
|
require "webrat/selenium/selenium_session"
|
|
@@ -69,13 +68,3 @@ module Webrat
|
|
|
69
68
|
end
|
|
70
69
|
end
|
|
71
70
|
end
|
|
72
|
-
|
|
73
|
-
if defined?(ActionController::IntegrationTest)
|
|
74
|
-
module ActionController #:nodoc:
|
|
75
|
-
IntegrationTest.class_eval do
|
|
76
|
-
include Webrat::Methods
|
|
77
|
-
include Webrat::Selenium::Methods
|
|
78
|
-
include Webrat::Selenium::Matchers
|
|
79
|
-
end
|
|
80
|
-
end
|
|
81
|
-
end
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
module Webrat
|
|
2
|
+
module Selenium
|
|
3
|
+
|
|
4
|
+
class ApplicationServerFactory
|
|
5
|
+
|
|
6
|
+
def self.app_server_instance
|
|
7
|
+
case Webrat.configuration.application_framework
|
|
8
|
+
when :sinatra
|
|
9
|
+
require "webrat/selenium/application_servers/sinatra"
|
|
10
|
+
return Webrat::Selenium::ApplicationServers::Sinatra.new
|
|
11
|
+
when :merb
|
|
12
|
+
require "webrat/selenium/application_servers/merb"
|
|
13
|
+
return Webrat::Selenium::ApplicationServers::Merb.new
|
|
14
|
+
when :rails
|
|
15
|
+
require "webrat/selenium/application_servers/rails"
|
|
16
|
+
return Webrat::Selenium::ApplicationServers::Rails.new
|
|
17
|
+
when :external
|
|
18
|
+
require "webrat/selenium/application_servers/external"
|
|
19
|
+
return Webrat::Selenium::ApplicationServers::External.new
|
|
20
|
+
else
|
|
21
|
+
raise WebratError.new(<<-STR)
|
|
22
|
+
Unknown Webrat application_framework: #{Webrat.configuration.application_framework.inspect}
|
|
23
|
+
|
|
24
|
+
Please ensure you have a Webrat configuration block that specifies an application_framework
|
|
25
|
+
in your test_helper.rb, spec_helper.rb, or env.rb (for Cucumber).
|
|
26
|
+
|
|
27
|
+
For example:
|
|
28
|
+
|
|
29
|
+
Webrat.configure do |config|
|
|
30
|
+
# ...
|
|
31
|
+
config.application_framework = :rails
|
|
32
|
+
end
|
|
33
|
+
STR
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
end
|
|
40
|
+
end
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
require "webrat/selenium/silence_stream"
|
|
2
|
+
|
|
3
|
+
module Webrat
|
|
4
|
+
module Selenium
|
|
5
|
+
module ApplicationServers
|
|
6
|
+
class Base
|
|
7
|
+
include Webrat::Selenium::SilenceStream
|
|
8
|
+
|
|
9
|
+
def boot
|
|
10
|
+
start
|
|
11
|
+
wait
|
|
12
|
+
stop_at_exit
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def stop_at_exit
|
|
16
|
+
at_exit do
|
|
17
|
+
stop
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def wait
|
|
22
|
+
$stderr.print "==> Waiting for #{Webrat.configuration.application_framework} application server on port #{Webrat.configuration.application_port}... "
|
|
23
|
+
wait_for_socket
|
|
24
|
+
$stderr.print "Ready!\n"
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def wait_for_socket
|
|
28
|
+
silence_stream(STDOUT) do
|
|
29
|
+
TCPSocket.wait_for_service_with_timeout \
|
|
30
|
+
:host => "0.0.0.0",
|
|
31
|
+
:port => Webrat.configuration.application_port.to_i,
|
|
32
|
+
:timeout => 30 # seconds
|
|
33
|
+
end
|
|
34
|
+
rescue SocketError
|
|
35
|
+
fail
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def prepare_pid_file(file_path, pid_file_name)
|
|
39
|
+
FileUtils.mkdir_p File.expand_path(file_path)
|
|
40
|
+
File.expand_path("#{file_path}/#{pid_file_name}")
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
require "webrat/selenium/application_servers/base"
|
|
2
|
+
|
|
3
|
+
module Webrat
|
|
4
|
+
module Selenium
|
|
5
|
+
module ApplicationServers
|
|
6
|
+
class External < Webrat::Selenium::ApplicationServers::Base
|
|
7
|
+
def start
|
|
8
|
+
warn "Webrat Ignoring Start Of Application Server Due to External Mode"
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def stop
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def fail
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def pid_file
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def wait
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
require "webrat/selenium/application_servers/base"
|
|
2
|
+
|
|
3
|
+
module Webrat
|
|
4
|
+
module Selenium
|
|
5
|
+
module ApplicationServers
|
|
6
|
+
class Merb < Webrat::Selenium::ApplicationServers::Base
|
|
7
|
+
|
|
8
|
+
def start
|
|
9
|
+
system start_command
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def stop
|
|
13
|
+
silence_stream(STDOUT) do
|
|
14
|
+
pid = File.read(pid_file)
|
|
15
|
+
system("kill -9 #{pid}")
|
|
16
|
+
FileUtils.rm_f pid_file
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def fail
|
|
21
|
+
$stderr.puts
|
|
22
|
+
$stderr.puts
|
|
23
|
+
$stderr.puts "==> Failed to boot the Merb application server... exiting!"
|
|
24
|
+
$stderr.puts
|
|
25
|
+
$stderr.puts "Verify you can start a Merb server on port #{Webrat.configuration.application_port} with the following command:"
|
|
26
|
+
$stderr.puts
|
|
27
|
+
$stderr.puts " #{start_command}"
|
|
28
|
+
exit
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def pid_file
|
|
32
|
+
"log/merb.#{Webrat.configuration.application_port}.pid"
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def start_command
|
|
36
|
+
"#{merb_command} -d -p #{Webrat.configuration.application_port} -e #{Webrat.configuration.application_environment}"
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def merb_command
|
|
40
|
+
if File.exist?('bin/merb')
|
|
41
|
+
merb_cmd = 'bin/merb'
|
|
42
|
+
else
|
|
43
|
+
merb_cmd = 'merb'
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
require "webrat/selenium/application_servers/base"
|
|
2
|
+
|
|
3
|
+
module Webrat
|
|
4
|
+
module Selenium
|
|
5
|
+
module ApplicationServers
|
|
6
|
+
class Rails < Webrat::Selenium::ApplicationServers::Base
|
|
7
|
+
|
|
8
|
+
def start
|
|
9
|
+
system start_command
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def stop
|
|
13
|
+
silence_stream(STDOUT) do
|
|
14
|
+
system stop_command
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def fail
|
|
19
|
+
$stderr.puts
|
|
20
|
+
$stderr.puts
|
|
21
|
+
$stderr.puts "==> Failed to boot the Rails application server... exiting!"
|
|
22
|
+
$stderr.puts
|
|
23
|
+
$stderr.puts "Verify you can start a Rails 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 pid_file
|
|
30
|
+
prepare_pid_file("#{RAILS_ROOT}/tmp/pids", "mongrel_selenium.pid")
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def start_command
|
|
34
|
+
"mongrel_rails start -d --chdir='#{RAILS_ROOT}' --port=#{Webrat.configuration.application_port} --environment=#{Webrat.configuration.application_environment} --pid #{pid_file} &"
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def stop_command
|
|
38
|
+
"mongrel_rails stop -c #{RAILS_ROOT} --pid #{pid_file}"
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|