screw-unit-server 0.3.0 → 0.5.3
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +23 -1
- data/README.markdown +10 -3
- data/Rakefile +27 -55
- data/VERSION.yml +4 -0
- data/bin/screw_unit_server +14 -4
- data/core/CHANGES +10 -0
- data/core/EXAMPLE.html +4 -4
- data/core/README.markdown +7 -7
- data/core/example/models/man.js +2 -2
- data/core/example/spec/suite.html +1 -1
- data/core/lib/jquery-1.3.2.js +4376 -0
- data/core/lib/jquery.fn.js +2 -1
- data/core/lib/jquery.print.js +13 -12
- data/core/lib/screw.behaviors.js +11 -9
- data/core/lib/screw.builder.js +26 -11
- data/core/lib/screw.css +2 -2
- data/core/lib/screw.events.js +11 -4
- data/core/lib/screw.matchers.js +192 -13
- data/core/spec/behaviors_spec.js +11 -1
- data/core/spec/matchers_spec.js +288 -9
- data/core/spec/print_spec.js +47 -8
- data/core/spec/suite.html +2 -1
- data/core/spec/with_screw_context_spec.js +9 -0
- data/lib/screw_unit.rb +13 -16
- data/lib/screw_unit/representations.rb +2 -0
- data/lib/screw_unit/representations/spec.html.rb +117 -0
- data/spec/functional/functional_spec.rb +14 -3
- data/spec/functional/functional_spec_helper.rb +22 -34
- data/spec/functional/functional_spec_server_starter.rb +68 -0
- data/spec/unit/js_test_core/specs/spec_file_spec.rb +45 -20
- data/spec/unit/unit_spec_helper.rb +24 -93
- data/vendor/js-test-core/CHANGES +19 -0
- data/vendor/js-test-core/Rakefile +2 -1
- data/vendor/js-test-core/lib/js_test_core.rb +26 -10
- data/vendor/js-test-core/lib/js_test_core/app.rb +12 -0
- data/vendor/js-test-core/lib/js_test_core/client.rb +97 -18
- data/vendor/js-test-core/lib/js_test_core/configuration.rb +35 -0
- data/vendor/js-test-core/lib/js_test_core/extensions.rb +3 -0
- data/vendor/js-test-core/lib/js_test_core/extensions/selenium/client/driver.rb +7 -0
- data/vendor/js-test-core/lib/js_test_core/extensions/time.rb +6 -0
- data/vendor/js-test-core/lib/js_test_core/models.rb +8 -0
- data/vendor/js-test-core/lib/js_test_core/models/selenium_session.rb +80 -0
- data/vendor/js-test-core/lib/js_test_core/representations.rb +11 -0
- data/vendor/js-test-core/lib/js_test_core/representations/dir.html.rb +24 -0
- data/vendor/js-test-core/lib/js_test_core/representations/not_found.html.rb +15 -0
- data/vendor/js-test-core/lib/js_test_core/representations/page.html.rb +41 -0
- data/vendor/js-test-core/lib/js_test_core/representations/spec.html.rb +24 -0
- data/vendor/js-test-core/lib/js_test_core/resources.rb +13 -8
- data/vendor/js-test-core/lib/js_test_core/resources/core_file.rb +19 -0
- data/vendor/js-test-core/lib/js_test_core/resources/file.rb +44 -14
- data/vendor/js-test-core/lib/js_test_core/resources/implementations_deprecation.rb +12 -0
- data/vendor/js-test-core/lib/js_test_core/resources/not_found.rb +35 -0
- data/vendor/js-test-core/lib/js_test_core/resources/resource.rb +16 -0
- data/vendor/js-test-core/lib/js_test_core/resources/selenium_session.rb +104 -0
- data/vendor/js-test-core/lib/js_test_core/resources/spec_file.rb +63 -0
- data/vendor/js-test-core/lib/js_test_core/resources/web_root.rb +5 -56
- data/vendor/js-test-core/lib/js_test_core/selenium_server_configuration.rb +48 -0
- data/vendor/js-test-core/spec/example_core/subdir/SubDirFile.js +0 -0
- data/vendor/js-test-core/spec/example_public/javascripts/large_file.js +59 -0
- data/vendor/js-test-core/spec/example_public/javascripts/subdir/bar.js +1 -0
- data/vendor/js-test-core/spec/example_specs/custom_dir_and_suite/passing_spec.js +6 -0
- data/vendor/js-test-core/spec/example_specs/custom_suite.html +8 -0
- data/vendor/js-test-core/spec/example_specs/foo/failing_spec.js +1 -1
- data/vendor/js-test-core/spec/example_specs/foo/passing_spec.js +1 -1
- data/vendor/js-test-core/spec/spec_helpers/be_http.rb +32 -0
- data/vendor/js-test-core/spec/spec_helpers/example_group.rb +36 -0
- data/vendor/js-test-core/spec/spec_helpers/fake_selenium_driver.rb +27 -0
- data/vendor/js-test-core/spec/spec_helpers/show_test_exceptions.rb +22 -0
- data/vendor/js-test-core/spec/unit/js_test_core/client_spec.rb +140 -85
- data/vendor/js-test-core/spec/unit/js_test_core/configuration_spec.rb +44 -0
- data/vendor/js-test-core/spec/unit/js_test_core/models/selenium_session_spec.rb +85 -0
- data/vendor/js-test-core/spec/unit/js_test_core/resources/core_file_spec.rb +60 -0
- data/vendor/js-test-core/spec/unit/js_test_core/resources/file_spec.rb +61 -68
- data/vendor/js-test-core/spec/unit/js_test_core/resources/implementations_deprecation_spec.rb +18 -0
- data/vendor/js-test-core/spec/unit/js_test_core/resources/not_found_spec.rb +51 -0
- data/vendor/js-test-core/spec/unit/js_test_core/resources/selenium_session_spec.rb +362 -0
- data/vendor/js-test-core/spec/unit/js_test_core/resources/spec_file_spec.rb +120 -0
- data/vendor/js-test-core/spec/unit/js_test_core/resources/web_root_spec.rb +14 -89
- data/vendor/js-test-core/spec/unit/js_test_core/selenium_server_configuration_spec.rb +49 -0
- data/vendor/js-test-core/spec/unit/unit_spec_helper.rb +16 -113
- data/vendor/js-test-core/vendor/lucky-luciano/README.markdown +7 -0
- data/vendor/js-test-core/vendor/lucky-luciano/lib/lucky_luciano.rb +4 -0
- data/vendor/js-test-core/vendor/lucky-luciano/lib/lucky_luciano/resource.rb +135 -0
- data/vendor/js-test-core/vendor/lucky-luciano/lib/lucky_luciano/rspec.rb +4 -0
- data/vendor/js-test-core/vendor/lucky-luciano/lib/lucky_luciano/rspec/be_http.rb +32 -0
- data/vendor/js-test-core/vendor/lucky-luciano/spec/lucky_luciano/resource_spec.rb +231 -0
- data/vendor/js-test-core/vendor/lucky-luciano/spec/spec_helper.rb +48 -0
- data/vendor/js-test-core/vendor/lucky-luciano/spec/spec_suite.rb +4 -0
- metadata +143 -129
- data/core/TODO +0 -2
- data/core/lib/jquery-1.2.3.js +0 -3408
- data/core/lib/screw.assets.js +0 -36
- data/core/lib/screw.server.js +0 -21
- data/lib/screw_unit/resources.rb +0 -2
- data/lib/screw_unit/resources/spec.rb +0 -37
- data/spec/unit/js_test_core/specs/spec_dir_spec.rb +0 -43
- data/vendor/js-test-core/lib/js_test_core/rack.rb +0 -2
- data/vendor/js-test-core/lib/js_test_core/rack/commonlogger.rb +0 -5
- data/vendor/js-test-core/lib/js_test_core/rails_server.rb +0 -22
- data/vendor/js-test-core/lib/js_test_core/resources/dir.rb +0 -52
- data/vendor/js-test-core/lib/js_test_core/resources/file_not_found.rb +0 -15
- data/vendor/js-test-core/lib/js_test_core/resources/runners.rb +0 -15
- data/vendor/js-test-core/lib/js_test_core/resources/runners/firefox_runner.rb +0 -75
- data/vendor/js-test-core/lib/js_test_core/resources/specs/spec_dir.rb +0 -50
- data/vendor/js-test-core/lib/js_test_core/resources/specs/spec_file.rb +0 -17
- data/vendor/js-test-core/lib/js_test_core/resources/suite.rb +0 -24
- data/vendor/js-test-core/lib/js_test_core/resources/suite_finish.rb +0 -19
- data/vendor/js-test-core/lib/js_test_core/selenium.rb +0 -2
- data/vendor/js-test-core/lib/js_test_core/selenium/selenium_driver.rb +0 -5
- data/vendor/js-test-core/lib/js_test_core/server.rb +0 -111
- data/vendor/js-test-core/lib/js_test_core/thin.rb +0 -3
- data/vendor/js-test-core/lib/js_test_core/thin/backends/js_test_core_server.rb +0 -9
- data/vendor/js-test-core/lib/js_test_core/thin/js_test_core_connection.rb +0 -42
- data/vendor/js-test-core/spec/unit/js_test_core/rails_server_spec.rb +0 -45
- data/vendor/js-test-core/spec/unit/js_test_core/resources/dir_spec.rb +0 -42
- data/vendor/js-test-core/spec/unit/js_test_core/resources/file_not_found_spec.rb +0 -26
- data/vendor/js-test-core/spec/unit/js_test_core/resources/runner_spec.rb +0 -24
- data/vendor/js-test-core/spec/unit/js_test_core/resources/runners/firefox_runner_spec.rb +0 -197
- data/vendor/js-test-core/spec/unit/js_test_core/resources/specs/spec_dir_spec.rb +0 -79
- data/vendor/js-test-core/spec/unit/js_test_core/resources/specs/spec_file_spec.rb +0 -42
- data/vendor/js-test-core/spec/unit/js_test_core/resources/suite_finish_spec.rb +0 -94
- data/vendor/js-test-core/spec/unit/js_test_core/resources/suite_spec.rb +0 -44
- data/vendor/js-test-core/spec/unit/js_test_core/server_spec.rb +0 -131
- data/vendor/js-test-core/spec/unit/thin/js_test_core_connection_spec.rb +0 -92
data/vendor/js-test-core/CHANGES
CHANGED
@@ -1,3 +1,22 @@
|
|
1
|
+
- No longer using the /implementanions directory. Replace all cases of /implementations with /javascripts.
|
2
|
+
- Added support for custom suite files
|
3
|
+
- Added dependency on Erector
|
4
|
+
- Better error messages
|
5
|
+
- Changed dependency from Selenium to selenium-client
|
6
|
+
- Renamed Resources::Runner to Resources::SeleniumSession
|
7
|
+
- Changed /runners to /selenium_sessions
|
8
|
+
|
9
|
+
0.2.0
|
10
|
+
- Renamed Suite to Session to follow Selenium conventions
|
11
|
+
- Renamed SuiteFinish to SessionFinish to follow Selenium conventions
|
12
|
+
- Added /session, which uses the session_id cookie to derive the current session.
|
13
|
+
- Added /session/finished to be used to simplify client/server interactions.
|
14
|
+
- Remove File caching because it doesn't cause a noticable performance benefit over a local network and because it sometimes doesn't write over stale files.
|
15
|
+
- Client accepts selenium_browser_start_command parameter, which allows the user to parameterize the selenium_browser_start_command
|
16
|
+
- Added support for running specs in Internet Explorer via POST /runners/iexplore
|
17
|
+
- Resource file download performance improvements via caching and chunked sending
|
18
|
+
- Fixed false positive bug when Client connection times out
|
19
|
+
|
1
20
|
0.1.1
|
2
21
|
- SuiteFinish#post immediately closes the connection
|
3
22
|
|
@@ -26,7 +26,7 @@ def run_suite
|
|
26
26
|
end
|
27
27
|
|
28
28
|
PKG_NAME = "js_test_core"
|
29
|
-
PKG_VERSION = "0.
|
29
|
+
PKG_VERSION = "0.2.0"
|
30
30
|
PKG_FILES = FileList[
|
31
31
|
'[A-Z]*',
|
32
32
|
'*.rb',
|
@@ -58,6 +58,7 @@ spec = Gem::Specification.new do |s|
|
|
58
58
|
s.rubyforge_project = "pivotalrb"
|
59
59
|
s.add_dependency('Selenium')
|
60
60
|
s.add_dependency('thin', '=0.8.1')
|
61
|
+
s.add_dependency('erector')
|
61
62
|
end
|
62
63
|
|
63
64
|
Rake::GemPackageTask.new(spec) do |pkg|
|
@@ -1,30 +1,46 @@
|
|
1
1
|
require "rubygems"
|
2
|
-
gem "thin", ">=
|
2
|
+
gem "thin", ">=1.2.1"
|
3
|
+
gem "erector", ">=0.6.6"
|
4
|
+
gem "selenium-client"
|
5
|
+
|
6
|
+
dir = File.dirname(__FILE__)
|
7
|
+
$LOAD_PATH.unshift File.expand_path("#{dir}/../vendor/lucky-luciano/lib")
|
8
|
+
require "lucky_luciano"
|
3
9
|
|
4
|
-
require "thin"
|
5
10
|
require "fileutils"
|
6
11
|
require "tmpdir"
|
7
12
|
require "timeout"
|
8
13
|
require "cgi"
|
9
14
|
require "net/http"
|
10
|
-
require "selenium"
|
15
|
+
require "selenium/client"
|
11
16
|
require "optparse"
|
17
|
+
require "erector"
|
12
18
|
|
13
|
-
dir
|
14
|
-
|
15
|
-
require "#{dir}/js_test_core/
|
19
|
+
require "#{dir}/js_test_core/configuration"
|
20
|
+
|
21
|
+
require "#{dir}/js_test_core/extensions"
|
22
|
+
require "#{dir}/js_test_core/models"
|
16
23
|
require "#{dir}/js_test_core/resources"
|
17
|
-
require "#{dir}/js_test_core/
|
24
|
+
require "#{dir}/js_test_core/representations"
|
18
25
|
|
19
26
|
require "#{dir}/js_test_core/client"
|
20
|
-
require "#{dir}/js_test_core/
|
21
|
-
|
27
|
+
require "#{dir}/js_test_core/selenium_server_configuration"
|
28
|
+
|
29
|
+
require "#{dir}/js_test_core/app"
|
22
30
|
|
23
31
|
module JsTestCore
|
24
32
|
DEFAULT_HOST = "0.0.0.0"
|
25
33
|
DEFAULT_PORT = 8080
|
26
34
|
|
27
35
|
class << self
|
28
|
-
|
36
|
+
Configuration.instance = Configuration.new
|
37
|
+
|
38
|
+
def method_missing(method_name, *args, &block)
|
39
|
+
if Configuration.instance.respond_to?(method_name)
|
40
|
+
Configuration.instance.send(method_name, *args, &block)
|
41
|
+
else
|
42
|
+
super
|
43
|
+
end
|
44
|
+
end
|
29
45
|
end
|
30
46
|
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module JsTestCore
|
2
|
+
class App < Sinatra::Base
|
3
|
+
set :logging, true
|
4
|
+
register(JsTestCore::Resources::WebRoot.route_handler)
|
5
|
+
register(JsTestCore::Resources::SeleniumSession.route_handler)
|
6
|
+
register(JsTestCore::Resources::CoreFile.route_handler)
|
7
|
+
register(JsTestCore::Resources::SpecFile.route_handler)
|
8
|
+
register(JsTestCore::Resources::File.route_handler)
|
9
|
+
register(JsTestCore::Resources::ImplementationsDeprecation.route_handler)
|
10
|
+
register(JsTestCore::Resources::NotFound.route_handler)
|
11
|
+
end
|
12
|
+
end
|
@@ -1,24 +1,17 @@
|
|
1
1
|
module JsTestCore
|
2
2
|
class Client
|
3
|
-
class
|
4
|
-
|
5
|
-
data = []
|
6
|
-
data << "selenium_host=#{CGI.escape(params[:selenium_host] || 'localhost')}"
|
7
|
-
data << "selenium_port=#{CGI.escape((params[:selenium_port] || 4444).to_s)}"
|
8
|
-
data << "spec_url=#{CGI.escape(params[:spec_url])}" if params[:spec_url]
|
9
|
-
response = Net::HTTP.start(DEFAULT_HOST, DEFAULT_PORT) do |http|
|
10
|
-
http.post('/runners/firefox', data.join("&"))
|
11
|
-
end
|
3
|
+
class ClientException < Exception
|
4
|
+
end
|
12
5
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
6
|
+
class InvalidStatusResponse < ClientException
|
7
|
+
end
|
8
|
+
|
9
|
+
class SessionNotFound < ClientException
|
10
|
+
end
|
11
|
+
|
12
|
+
class << self
|
13
|
+
def run(parameters={})
|
14
|
+
new(parameters).run
|
22
15
|
end
|
23
16
|
|
24
17
|
def run_argv(argv)
|
@@ -28,6 +21,10 @@ module JsTestCore
|
|
28
21
|
o.banner << "\nUsage: #{$0} [options] [-- untouched arguments]"
|
29
22
|
|
30
23
|
o.on
|
24
|
+
o.on('-s', '--selenium_browser_start_command=selenium_browser_start_command', "The Selenium server command to start the browser. See http://selenium-rc.openqa.org/") do |selenium_browser_start_command|
|
25
|
+
params[:selenium_browser_start_command] = selenium_browser_start_command
|
26
|
+
end
|
27
|
+
|
31
28
|
o.on('-h', '--selenium_host=SELENIUM_HOST', "The host name of the Selenium Server relative to where this file is executed") do |host|
|
32
29
|
params[:selenium_host] = host
|
33
30
|
end
|
@@ -40,11 +37,93 @@ module JsTestCore
|
|
40
37
|
params[:spec_url] = spec_url
|
41
38
|
end
|
42
39
|
|
40
|
+
o.on('-t', '--timeout=TIMEOUT', "The timeout limit of the test run") do |timeout|
|
41
|
+
params[:timeout] = Integer(timeout)
|
42
|
+
end
|
43
|
+
|
43
44
|
o.on_tail
|
44
45
|
end
|
45
46
|
parser.order!(argv)
|
46
47
|
run params
|
47
48
|
end
|
48
49
|
end
|
50
|
+
|
51
|
+
attr_reader :parameters, :query_string, :http, :session_start_response, :last_poll_status, :last_poll_reason, :last_poll
|
52
|
+
def initialize(parameters)
|
53
|
+
@parameters = parameters
|
54
|
+
@query_string = SeleniumServerConfiguration.query_string_from(parameters)
|
55
|
+
end
|
56
|
+
|
57
|
+
def run
|
58
|
+
if parameters[:timeout]
|
59
|
+
Timeout.timeout(parameters[:timeout]) {do_run}
|
60
|
+
else
|
61
|
+
do_run
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def parts_from_query(query)
|
66
|
+
query.split('&').inject({}) do |acc, key_value_pair|
|
67
|
+
key, value = key_value_pair.split('=')
|
68
|
+
acc[key] = value
|
69
|
+
acc
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
protected
|
74
|
+
def do_run
|
75
|
+
Net::HTTP.start(DEFAULT_HOST, DEFAULT_PORT) do |@http|
|
76
|
+
start_runner
|
77
|
+
wait_for_session_to_finish
|
78
|
+
end
|
79
|
+
report_result
|
80
|
+
end
|
81
|
+
|
82
|
+
def start_runner
|
83
|
+
@session_start_response = http.post(Resources::SeleniumSession.path, query_string)
|
84
|
+
end
|
85
|
+
|
86
|
+
def wait_for_session_to_finish
|
87
|
+
while session_not_completed?
|
88
|
+
poll
|
89
|
+
sleep 0.25
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
def report_result
|
94
|
+
case last_poll_status
|
95
|
+
when Resources::SeleniumSession::SUCCESSFUL_COMPLETION
|
96
|
+
STDOUT.puts "SUCCESS"
|
97
|
+
true
|
98
|
+
when Resources::SeleniumSession::FAILURE_COMPLETION
|
99
|
+
STDOUT.puts "FAILURE"
|
100
|
+
STDOUT.puts last_poll_reason
|
101
|
+
false
|
102
|
+
else
|
103
|
+
raise InvalidStatusResponse, "Invalid Status: #{last_poll_status}"
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
def session_not_completed?
|
108
|
+
last_poll_status.nil? || last_poll_status == Resources::SeleniumSession::RUNNING
|
109
|
+
end
|
110
|
+
|
111
|
+
def poll
|
112
|
+
@last_poll = http.get(Resources::SeleniumSession.path("/:session_id", :session_id => session_id))
|
113
|
+
ensure_session_exists!
|
114
|
+
parts = parts_from_query(last_poll.body)
|
115
|
+
@last_poll_status = parts['status']
|
116
|
+
@last_poll_reason = parts['reason']
|
117
|
+
end
|
118
|
+
|
119
|
+
def ensure_session_exists!
|
120
|
+
if (400..499).include?(Integer(last_poll.code))
|
121
|
+
raise SessionNotFound, "Could not find session with id #{session_id}"
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
def session_id
|
126
|
+
@session_id ||= parts_from_query(session_start_response.body)['session_id']
|
127
|
+
end
|
49
128
|
end
|
50
129
|
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module JsTestCore
|
2
|
+
class Configuration
|
3
|
+
class << self
|
4
|
+
attr_accessor :instance
|
5
|
+
|
6
|
+
def method_missing(method_name, *args, &block)
|
7
|
+
if Configuration.instance.respond_to?(method_name)
|
8
|
+
Configuration.instance.send(method_name, *args, &block)
|
9
|
+
else
|
10
|
+
super
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
attr_accessor :host, :port, :spec_root_path, :public_path, :core_path
|
16
|
+
|
17
|
+
def initialize(params={})
|
18
|
+
params = {
|
19
|
+
:spec_root_path => File.expand_path("./specs/javascripts"),
|
20
|
+
:public_path => File.expand_path("./public"),
|
21
|
+
:host => DEFAULT_HOST,
|
22
|
+
:port => DEFAULT_PORT,
|
23
|
+
}.merge(params)
|
24
|
+
@spec_root_path = ::File.expand_path(params[:spec_root_path])
|
25
|
+
@public_path = ::File.expand_path(params[:public_path])
|
26
|
+
@host = params[:host]
|
27
|
+
@port = params[:port]
|
28
|
+
@core_path = params[:core_path]
|
29
|
+
end
|
30
|
+
|
31
|
+
def root_url
|
32
|
+
"http://#{host}:#{port}"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,80 @@
|
|
1
|
+
module JsTestCore
|
2
|
+
module Models
|
3
|
+
class SeleniumSession
|
4
|
+
class << self
|
5
|
+
def find(id)
|
6
|
+
instances[id.to_s]
|
7
|
+
end
|
8
|
+
|
9
|
+
def register(selenium_session)
|
10
|
+
instances[selenium_session.session_id] = selenium_session
|
11
|
+
end
|
12
|
+
|
13
|
+
protected
|
14
|
+
def instances
|
15
|
+
@instances ||= {}
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
attr_reader :spec_url, :selenium_browser_start_command, :selenium_host, :selenium_port, :http_address, :driver, :run_result
|
20
|
+
|
21
|
+
def initialize(params={})
|
22
|
+
@spec_url = params[:spec_url]
|
23
|
+
@selenium_browser_start_command = params[:selenium_browser_start_command]
|
24
|
+
@selenium_host = params[:selenium_host]
|
25
|
+
@selenium_port = params[:selenium_port]
|
26
|
+
|
27
|
+
memoized_parsed_spec_url = parsed_spec_url
|
28
|
+
@http_address = "#{memoized_parsed_spec_url.scheme}://#{memoized_parsed_spec_url.host}:#{memoized_parsed_spec_url.port}"
|
29
|
+
|
30
|
+
@driver = Selenium::Client::Driver.new(
|
31
|
+
selenium_host,
|
32
|
+
selenium_port,
|
33
|
+
selenium_browser_start_command,
|
34
|
+
http_address
|
35
|
+
)
|
36
|
+
end
|
37
|
+
|
38
|
+
def start
|
39
|
+
begin
|
40
|
+
driver.start
|
41
|
+
rescue Errno::ECONNREFUSED => e
|
42
|
+
raise Errno::ECONNREFUSED, "Cannot connect to Selenium Server at #{http_address}. To start the selenium server, run `selenium`."
|
43
|
+
end
|
44
|
+
self.class.register(self)
|
45
|
+
Thread.start do
|
46
|
+
driver.open("/")
|
47
|
+
driver.create_cookie("session_id=#{session_id}")
|
48
|
+
driver.open(parsed_spec_url.path)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def session_id
|
53
|
+
driver.session_id
|
54
|
+
end
|
55
|
+
|
56
|
+
def finish(run_result)
|
57
|
+
driver.stop
|
58
|
+
@run_result = run_result.to_s
|
59
|
+
end
|
60
|
+
|
61
|
+
def running?
|
62
|
+
driver.session_started?
|
63
|
+
end
|
64
|
+
|
65
|
+
def successful?
|
66
|
+
!running? && run_result.empty?
|
67
|
+
end
|
68
|
+
|
69
|
+
def failed?
|
70
|
+
!running? && !successful?
|
71
|
+
end
|
72
|
+
|
73
|
+
protected
|
74
|
+
|
75
|
+
def parsed_spec_url
|
76
|
+
URI.parse(spec_url)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
dir = File.dirname(__FILE__)
|
2
|
+
|
3
|
+
module JsTestCore
|
4
|
+
module Representations
|
5
|
+
end
|
6
|
+
end
|
7
|
+
|
8
|
+
require "#{dir}/representations/page.html"
|
9
|
+
require "#{dir}/representations/not_found.html"
|
10
|
+
require "#{dir}/representations/spec.html"
|
11
|
+
require "#{dir}/representations/dir.html"
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module JsTestCore
|
2
|
+
module Representations
|
3
|
+
class Dir < Page
|
4
|
+
needs :relative_path, :absolute_path
|
5
|
+
protected
|
6
|
+
def body_content
|
7
|
+
ul do
|
8
|
+
::Dir.glob("#{absolute_path}/*").inject("") do |html, file|
|
9
|
+
li do
|
10
|
+
a(
|
11
|
+
::File.basename(file),
|
12
|
+
:href => "#{relative_path}/#{::File.basename(file)}".gsub("//", "/")
|
13
|
+
)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def title_text
|
20
|
+
"Contents of #{relative_path}"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|