pivotal-screw-unit 0.4.3 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +6 -0
- data/Rakefile +4 -1
- data/VERSION.yml +2 -2
- data/bin/screw_unit_server +14 -4
- data/lib/screw_unit/representations/spec.html.rb +1 -1
- data/lib/screw_unit/resources/core_file.rb +7 -0
- data/lib/screw_unit.rb +12 -8
- data/spec/functional/functional_spec_helper.rb +11 -4
- data/spec/functional/functional_spec_server_starter.rb +13 -8
- data/spec/unit/js_test_core/specs/spec_file_spec.rb +51 -18
- data/spec/unit/unit_spec_helper.rb +22 -90
- data/vendor/js-test-core/CHANGES +3 -0
- data/vendor/js-test-core/lib/js_test_core/app.rb +12 -0
- data/vendor/js-test-core/lib/js_test_core/client.rb +5 -5
- data/vendor/js-test-core/lib/js_test_core/configuration.rb +35 -0
- data/vendor/js-test-core/lib/js_test_core/{selenium → extensions/selenium}/client/driver.rb +0 -0
- data/vendor/js-test-core/lib/js_test_core/extensions.rb +1 -1
- data/vendor/js-test-core/lib/js_test_core/models/selenium_session.rb +80 -0
- data/vendor/js-test-core/lib/js_test_core/models.rb +8 -0
- data/vendor/js-test-core/lib/js_test_core/representations/dir.html.rb +24 -0
- data/vendor/js-test-core/{vendor/thin-rest/lib/thin_rest/representations/resource_not_found.html.rb → lib/js_test_core/representations/not_found.html.rb} +3 -7
- data/vendor/js-test-core/{vendor/thin-rest/lib/thin_rest → lib/js_test_core}/representations/page.html.rb +1 -1
- data/vendor/js-test-core/lib/js_test_core/representations/spec.html.rb +1 -1
- data/vendor/js-test-core/lib/js_test_core/representations.rb +4 -2
- 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 +38 -18
- 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 -60
- data/vendor/js-test-core/lib/js_test_core/resources.rb +7 -8
- data/vendor/js-test-core/lib/js_test_core.rb +18 -13
- data/vendor/js-test-core/{vendor/thin-rest/README → spec/example_core/subdir/SubDirFile.js} +0 -0
- data/vendor/js-test-core/spec/example_specs/custom_dir_and_suite/passing_spec.js +1 -1
- 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 +6 -6
- 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 +54 -63
- 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 +15 -19
- data/vendor/js-test-core/spec/unit/unit_spec_helper.rb +14 -148
- data/vendor/js-test-core/vendor/lucky-luciano/README.markdown +7 -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/be_http.rb +32 -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.rb +4 -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/{thin-rest → lucky-luciano}/spec/spec_suite.rb +1 -2
- metadata +74 -59
- data/spec/unit/js_test_core/specs/spec_dir_spec.rb +0 -39
- data/vendor/js-test-core/lib/js_test_core/rack/commonlogger.rb +0 -5
- data/vendor/js-test-core/lib/js_test_core/rack.rb +0 -2
- 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 -67
- data/vendor/js-test-core/lib/js_test_core/resources/runner.rb +0 -107
- data/vendor/js-test-core/lib/js_test_core/resources/session.rb +0 -44
- data/vendor/js-test-core/lib/js_test_core/resources/session_finish.rb +0 -17
- data/vendor/js-test-core/lib/js_test_core/resources/specs/spec.rb +0 -32
- 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 -21
- data/vendor/js-test-core/lib/js_test_core/selenium.rb +0 -2
- data/vendor/js-test-core/lib/js_test_core/server.rb +0 -50
- 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 -8
- data/vendor/js-test-core/lib/js_test_core/thin.rb +0 -3
- data/vendor/js-test-core/spec/example_specs/custom_dir_and_suite.html +0 -9
- 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 -53
- data/vendor/js-test-core/spec/unit/js_test_core/resources/file_not_found_spec.rb +0 -16
- data/vendor/js-test-core/spec/unit/js_test_core/resources/runners/runner_spec.rb +0 -303
- data/vendor/js-test-core/spec/unit/js_test_core/resources/session_finish_spec.rb +0 -79
- data/vendor/js-test-core/spec/unit/js_test_core/resources/session_spec.rb +0 -82
- data/vendor/js-test-core/spec/unit/js_test_core/resources/specs/spec_dir_spec.rb +0 -104
- data/vendor/js-test-core/spec/unit/js_test_core/resources/specs/spec_file_spec.rb +0 -41
- data/vendor/js-test-core/spec/unit/js_test_core/server_spec.rb +0 -117
- data/vendor/js-test-core/spec/unit/thin/js_test_core_connection_spec.rb +0 -6
- data/vendor/js-test-core/vendor/thin-rest/CHANGES +0 -2
- data/vendor/js-test-core/vendor/thin-rest/lib/thin_rest/connection.rb +0 -117
- data/vendor/js-test-core/vendor/thin-rest/lib/thin_rest/extensions/object.rb +0 -21
- data/vendor/js-test-core/vendor/thin-rest/lib/thin_rest/extensions.rb +0 -3
- data/vendor/js-test-core/vendor/thin-rest/lib/thin_rest/representations/internal_error.html.rb +0 -20
- data/vendor/js-test-core/vendor/thin-rest/lib/thin_rest/representations.rb +0 -4
- data/vendor/js-test-core/vendor/thin-rest/lib/thin_rest/resources/internal_error.rb +0 -11
- data/vendor/js-test-core/vendor/thin-rest/lib/thin_rest/resources/resource.rb +0 -105
- data/vendor/js-test-core/vendor/thin-rest/lib/thin_rest/resources/resource_not_found.rb +0 -19
- data/vendor/js-test-core/vendor/thin-rest/lib/thin_rest/resources.rb +0 -4
- data/vendor/js-test-core/vendor/thin-rest/lib/thin_rest/routing_error.rb +0 -5
- data/vendor/js-test-core/vendor/thin-rest/lib/thin_rest.rb +0 -10
- data/vendor/js-test-core/vendor/thin-rest/spec/thin_rest/connection_spec.rb +0 -205
- data/vendor/js-test-core/vendor/thin-rest/spec/thin_rest/resources/resource_not_found_spec.rb +0 -16
- data/vendor/js-test-core/vendor/thin-rest/spec/thin_rest/resources/resource_spec.rb +0 -135
- data/vendor/js-test-core/vendor/thin-rest/spec/thin_rest/resources/root_spec.rb +0 -16
- data/vendor/js-test-core/vendor/thin-rest/spec/thin_rest_spec_helper.rb +0 -134
@@ -2,8 +2,10 @@ dir = File.dirname(__FILE__)
|
|
2
2
|
|
3
3
|
module JsTestCore
|
4
4
|
module Representations
|
5
|
-
include ThinRest::Representations
|
6
5
|
end
|
7
6
|
end
|
8
7
|
|
9
|
-
require "#{dir}/representations/
|
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,19 @@
|
|
1
|
+
module JsTestCore
|
2
|
+
module Resources
|
3
|
+
class CoreFile < File
|
4
|
+
map "/core"
|
5
|
+
|
6
|
+
get "/?" do
|
7
|
+
do_get
|
8
|
+
end
|
9
|
+
|
10
|
+
get "*" do
|
11
|
+
do_get
|
12
|
+
end
|
13
|
+
|
14
|
+
def absolute_path
|
15
|
+
@absolute_path ||= ::File.expand_path("#{core_path}#{relative_path.gsub(%r{^/core}, "")}")
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -1,6 +1,8 @@
|
|
1
1
|
module JsTestCore
|
2
2
|
module Resources
|
3
3
|
class File < Resource
|
4
|
+
map "*"
|
5
|
+
|
4
6
|
MIME_TYPES = {
|
5
7
|
'.html' => 'text/html',
|
6
8
|
'.htm' => 'text/html',
|
@@ -12,30 +14,48 @@ module JsTestCore
|
|
12
14
|
'.gif' => 'image/gif',
|
13
15
|
}
|
14
16
|
|
15
|
-
|
17
|
+
get "*" do
|
18
|
+
do_get
|
19
|
+
end
|
20
|
+
|
21
|
+
def relative_path
|
22
|
+
@relative_path ||= request.path_info
|
23
|
+
end
|
24
|
+
|
25
|
+
def absolute_path
|
26
|
+
@absolute_path ||= ::File.expand_path("#{public_path}#{relative_path}")
|
27
|
+
end
|
28
|
+
|
29
|
+
protected
|
30
|
+
|
31
|
+
def do_get
|
32
|
+
if ::File.exists?(absolute_path)
|
33
|
+
if ::File.directory?(absolute_path)
|
34
|
+
render_dir
|
35
|
+
else
|
36
|
+
render_file
|
37
|
+
end
|
38
|
+
else
|
39
|
+
pass
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def render_dir
|
44
|
+
Representations::Dir.new(:relative_path => relative_path, :absolute_path => absolute_path).to_s
|
45
|
+
end
|
16
46
|
|
17
|
-
def
|
47
|
+
def render_file
|
18
48
|
extension = ::File.extname(absolute_path)
|
19
49
|
content_type = MIME_TYPES[extension] || 'text/html'
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
200,
|
50
|
+
[
|
51
|
+
200,
|
52
|
+
{
|
24
53
|
'Content-Type' => content_type,
|
25
54
|
'Last-Modified' => ::File.mtime(absolute_path).rfc822,
|
26
55
|
'Content-Length' => ::File.size(absolute_path)
|
27
|
-
|
28
|
-
::File.
|
29
|
-
|
30
|
-
connection.send_data(file.read(1024))
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
def ==(other)
|
37
|
-
return false unless other.class == self.class
|
38
|
-
absolute_path == other.absolute_path && relative_path == other.relative_path
|
56
|
+
},
|
57
|
+
::File.read(absolute_path)
|
58
|
+
]
|
39
59
|
end
|
40
60
|
end
|
41
61
|
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module JsTestCore
|
2
|
+
module Resources
|
3
|
+
class ImplementationsDeprecation < Resource
|
4
|
+
map "/implementations"
|
5
|
+
|
6
|
+
get "*" do
|
7
|
+
new_path = File.path("javascripts", *params["splat"])
|
8
|
+
[301, {'Location' => new_path}, "This page has been moved to #{new_path}"]
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module JsTestCore
|
2
|
+
module Resources
|
3
|
+
class NotFound < Resource
|
4
|
+
map "*"
|
5
|
+
|
6
|
+
get "/" do
|
7
|
+
call
|
8
|
+
end
|
9
|
+
|
10
|
+
put "/" do
|
11
|
+
call
|
12
|
+
end
|
13
|
+
|
14
|
+
post "/" do
|
15
|
+
call
|
16
|
+
end
|
17
|
+
|
18
|
+
delete "/" do
|
19
|
+
call
|
20
|
+
end
|
21
|
+
|
22
|
+
def call
|
23
|
+
body = Representations::NotFound.new(:message => "File #{request.path_info} not found").to_s
|
24
|
+
[
|
25
|
+
404,
|
26
|
+
{
|
27
|
+
"Content-Type" => "text/html",
|
28
|
+
"Content-Length" => body.size.to_s
|
29
|
+
},
|
30
|
+
body
|
31
|
+
]
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module JsTestCore
|
2
|
+
module Resources
|
3
|
+
class Resource < LuckyLuciano::Resource
|
4
|
+
protected
|
5
|
+
|
6
|
+
def spec_root_path; server.spec_root_path; end
|
7
|
+
def public_path; server.public_path; end
|
8
|
+
def core_path; server.core_path; end
|
9
|
+
def root_url; server.root_url; end
|
10
|
+
|
11
|
+
def server
|
12
|
+
JsTestCore::Configuration
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,104 @@
|
|
1
|
+
module JsTestCore
|
2
|
+
module Resources
|
3
|
+
class SeleniumSession < Resource
|
4
|
+
map "/selenium_sessions"
|
5
|
+
|
6
|
+
post "/" do
|
7
|
+
do_post params["selenium_browser_start_command"]
|
8
|
+
end
|
9
|
+
|
10
|
+
post "/firefox" do
|
11
|
+
do_post "*firefox"
|
12
|
+
end
|
13
|
+
|
14
|
+
post '/iexplore' do |env, name|
|
15
|
+
do_post "*iexplore"
|
16
|
+
end
|
17
|
+
|
18
|
+
get "/:session_id" do
|
19
|
+
do_get
|
20
|
+
end
|
21
|
+
|
22
|
+
post "/finish" do
|
23
|
+
do_finish
|
24
|
+
end
|
25
|
+
|
26
|
+
post "/:session_id/finish" do
|
27
|
+
do_finish
|
28
|
+
end
|
29
|
+
|
30
|
+
include FileUtils
|
31
|
+
RUNNING = 'running'
|
32
|
+
SUCCESSFUL_COMPLETION = 'success'
|
33
|
+
FAILURE_COMPLETION = 'failure'
|
34
|
+
|
35
|
+
protected
|
36
|
+
|
37
|
+
def do_get
|
38
|
+
selenium_session = Models::SeleniumSession.find(session_id)
|
39
|
+
if selenium_session
|
40
|
+
body = if selenium_session.running?
|
41
|
+
"status=#{RUNNING}"
|
42
|
+
else
|
43
|
+
if selenium_session.successful?
|
44
|
+
"status=#{SUCCESSFUL_COMPLETION}"
|
45
|
+
else
|
46
|
+
"status=#{FAILURE_COMPLETION}&reason=#{selenium_session.run_result}"
|
47
|
+
end
|
48
|
+
end
|
49
|
+
[
|
50
|
+
200,
|
51
|
+
{'Content-Length' => body.length},
|
52
|
+
body
|
53
|
+
]
|
54
|
+
else
|
55
|
+
body = Representations::NotFound.new(:message => "Could not find session #{session_id}").to_s
|
56
|
+
[
|
57
|
+
404,
|
58
|
+
{
|
59
|
+
"Content-Type" => "text/html",
|
60
|
+
"Content-Length" => body.size.to_s
|
61
|
+
},
|
62
|
+
body
|
63
|
+
]
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def do_finish
|
68
|
+
if selenium_session = Models::SeleniumSession.find(session_id)
|
69
|
+
selenium_session.finish(request['text'])
|
70
|
+
else
|
71
|
+
STDOUT.puts request['text']
|
72
|
+
end
|
73
|
+
[200, {}, request['text']]
|
74
|
+
end
|
75
|
+
|
76
|
+
def session_id
|
77
|
+
params["session_id"] || request.cookies["session_id"]
|
78
|
+
end
|
79
|
+
|
80
|
+
def do_post(selenium_browser_start_command)
|
81
|
+
selenium_session = Models::SeleniumSession.new({
|
82
|
+
:spec_url => request['spec_url'].to_s == "" ? full_spec_suite_url : request['spec_url'],
|
83
|
+
:selenium_browser_start_command => selenium_browser_start_command,
|
84
|
+
:selenium_host => request['selenium_host'].to_s == "" ? 'localhost' : request['selenium_host'].to_s,
|
85
|
+
:selenium_port => request['selenium_port'].to_s == "" ? 4444 : Integer(request['selenium_port'])
|
86
|
+
})
|
87
|
+
selenium_session.start
|
88
|
+
|
89
|
+
body = "session_id=#{selenium_session.session_id}"
|
90
|
+
[
|
91
|
+
200,
|
92
|
+
{
|
93
|
+
"Content-Length" => body.length
|
94
|
+
},
|
95
|
+
body
|
96
|
+
]
|
97
|
+
end
|
98
|
+
|
99
|
+
def full_spec_suite_url
|
100
|
+
"#{Configuration.root_url}/specs"
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
module JsTestCore
|
2
|
+
module Resources
|
3
|
+
class SpecFile < ::JsTestCore::Resources::File
|
4
|
+
class << self
|
5
|
+
def spec_representation_class
|
6
|
+
@spec_representation_class ||= JsTestCore::Representations::Spec
|
7
|
+
end
|
8
|
+
|
9
|
+
attr_writer :spec_representation_class
|
10
|
+
end
|
11
|
+
|
12
|
+
map "/specs"
|
13
|
+
|
14
|
+
get "/?" do
|
15
|
+
do_get
|
16
|
+
end
|
17
|
+
|
18
|
+
get "*" do
|
19
|
+
do_get
|
20
|
+
end
|
21
|
+
|
22
|
+
protected
|
23
|
+
|
24
|
+
def do_get
|
25
|
+
if ::File.exists?(absolute_path)
|
26
|
+
if ::File.directory?(absolute_path)
|
27
|
+
spec_files = ::Dir["#{absolute_path}/**/*_spec.js"].map do |file|
|
28
|
+
["#{relative_path}#{file.gsub(absolute_path, "")}"]
|
29
|
+
end
|
30
|
+
get_generated_spec(absolute_path, spec_files)
|
31
|
+
else
|
32
|
+
super
|
33
|
+
end
|
34
|
+
elsif ::File.exists?("#{absolute_path}.js")
|
35
|
+
get_generated_spec("#{absolute_path}.js", ["#{relative_path}.js"])
|
36
|
+
else
|
37
|
+
pass
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def get_generated_spec(real_path, spec_files)
|
42
|
+
html = render_spec(spec_files)
|
43
|
+
[
|
44
|
+
200,
|
45
|
+
{
|
46
|
+
'Content-Type' => "text/html",
|
47
|
+
'Last-Modified' => ::File.mtime(real_path).rfc822,
|
48
|
+
'Content-Length' => html.length
|
49
|
+
},
|
50
|
+
html
|
51
|
+
]
|
52
|
+
end
|
53
|
+
|
54
|
+
def render_spec(spec_files)
|
55
|
+
self.class.spec_representation_class.new(:spec_files => spec_files).to_s
|
56
|
+
end
|
57
|
+
|
58
|
+
def absolute_path
|
59
|
+
@absolute_path ||= ::File.expand_path("#{spec_root_path}#{relative_path.gsub(%r{^/specs}, "")}")
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -1,65 +1,10 @@
|
|
1
1
|
module JsTestCore
|
2
2
|
module Resources
|
3
|
-
class WebRoot <
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
Resources::Dir.new(env.merge(
|
9
|
-
:absolute_path => JsTestCore::Server.core_path,
|
10
|
-
:relative_path => "/core"
|
11
|
-
))
|
12
|
-
end
|
13
|
-
route "implementations" do |env, name|
|
14
|
-
Resources::Dir.new(env.merge(
|
15
|
-
:absolute_path => JsTestCore::Server.implementation_root_path,
|
16
|
-
:relative_path => "/implementations"
|
17
|
-
))
|
18
|
-
end
|
19
|
-
route "sessions", "JsTestCore::Resources::Session::Collection"
|
20
|
-
route "session" do |env, name|
|
21
|
-
Session.new(env.merge(:id => rack_request.cookies["session_id"]))
|
22
|
-
end
|
23
|
-
route "runners", "JsTestCore::Resources::Runner::Collection"
|
24
|
-
route "specs" do |env, name|
|
25
|
-
if self.class.dispatch_strategy == :specs
|
26
|
-
Resources::Specs::SpecDir.new(env.merge(
|
27
|
-
:absolute_path => JsTestCore::Server.spec_root_path,
|
28
|
-
:relative_path => "/specs"
|
29
|
-
))
|
30
|
-
else
|
31
|
-
Resources::ResourceNotFound.new(env.merge(:name => name))
|
32
|
-
end
|
33
|
-
end
|
34
|
-
route ANY do |env, name|
|
35
|
-
potential_file_in_public_path = "#{public_path}/#{name}"
|
36
|
-
if ::File.directory?(potential_file_in_public_path)
|
37
|
-
Resources::Dir.new(env.merge(
|
38
|
-
:absolute_path => potential_file_in_public_path,
|
39
|
-
:relative_path => "/#{name}"
|
40
|
-
))
|
41
|
-
elsif ::File.exists?(potential_file_in_public_path)
|
42
|
-
Resources::File.new(env.merge(
|
43
|
-
:absolute_path => potential_file_in_public_path,
|
44
|
-
:relative_path => "/#{name}"
|
45
|
-
))
|
46
|
-
else
|
47
|
-
Resources::ResourceNotFound.new(env.merge(:name => name))
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
class << self
|
52
|
-
attr_accessor :dispatch_strategy
|
53
|
-
def dispatch_specs
|
54
|
-
self.dispatch_strategy = :specs
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
property :public_path
|
59
|
-
|
60
|
-
def get
|
61
|
-
connection.send_head(200, :Location => "/#{self.class.dispatch_strategy}")
|
62
|
-
connection.send_body("<html><head></head><body>Welcome to the Js Test Server. Click the following link to run you <a href=/specs>spec suite</a>.</body></html>")
|
3
|
+
class WebRoot < Resource
|
4
|
+
map "/"
|
5
|
+
|
6
|
+
get("") do
|
7
|
+
[200, {}, "<html><head></head><body>Welcome to the Js Test Server. Click the following link to run you <a href=/specs>spec suite</a>.</body></html>"]
|
63
8
|
end
|
64
9
|
end
|
65
10
|
end
|
@@ -2,16 +2,15 @@ dir = File.dirname(__FILE__)
|
|
2
2
|
|
3
3
|
module JsTestCore
|
4
4
|
module Resources
|
5
|
-
include ThinRest::Resources
|
6
5
|
end
|
7
6
|
end
|
8
7
|
|
9
|
-
require "#{dir}/resources/
|
8
|
+
require "#{dir}/resources/resource"
|
9
|
+
require "#{dir}/resources/selenium_session"
|
10
10
|
require "#{dir}/resources/file"
|
11
|
-
require "#{dir}/resources/
|
12
|
-
require "#{dir}/resources/
|
13
|
-
require "#{dir}/resources/specs/spec_file"
|
14
|
-
require "#{dir}/resources/specs/spec_dir"
|
11
|
+
require "#{dir}/resources/spec_file"
|
12
|
+
require "#{dir}/resources/core_file"
|
15
13
|
require "#{dir}/resources/web_root"
|
16
|
-
require "#{dir}/resources/
|
17
|
-
|
14
|
+
require "#{dir}/resources/not_found"
|
15
|
+
|
16
|
+
require "#{dir}/resources/implementations_deprecation"
|
@@ -1,14 +1,11 @@
|
|
1
1
|
require "rubygems"
|
2
|
-
gem "thin", ">=
|
2
|
+
gem "thin", ">=1.2.1"
|
3
|
+
gem "erector", ">=0.6.6"
|
3
4
|
gem "selenium-client"
|
4
5
|
|
5
6
|
dir = File.dirname(__FILE__)
|
6
|
-
$LOAD_PATH.unshift File.expand_path("#{dir}/../vendor/
|
7
|
-
require "
|
8
|
-
|
9
|
-
# This causes errors to be printed to STDOUT.
|
10
|
-
Thin::Logging.silent = false
|
11
|
-
Thin::Logging.debug = true
|
7
|
+
$LOAD_PATH.unshift File.expand_path("#{dir}/../vendor/lucky-luciano/lib")
|
8
|
+
require "lucky_luciano"
|
12
9
|
|
13
10
|
require "fileutils"
|
14
11
|
require "tmpdir"
|
@@ -19,23 +16,31 @@ require "selenium/client"
|
|
19
16
|
require "optparse"
|
20
17
|
require "erector"
|
21
18
|
|
19
|
+
require "#{dir}/js_test_core/configuration"
|
20
|
+
|
22
21
|
require "#{dir}/js_test_core/extensions"
|
23
|
-
require "#{dir}/js_test_core/
|
24
|
-
require "#{dir}/js_test_core/rack"
|
22
|
+
require "#{dir}/js_test_core/models"
|
25
23
|
require "#{dir}/js_test_core/resources"
|
26
24
|
require "#{dir}/js_test_core/representations"
|
27
|
-
require "#{dir}/js_test_core/selenium"
|
28
25
|
|
29
26
|
require "#{dir}/js_test_core/client"
|
30
27
|
require "#{dir}/js_test_core/selenium_server_configuration"
|
31
|
-
|
32
|
-
require "#{dir}/js_test_core/
|
28
|
+
|
29
|
+
require "#{dir}/js_test_core/app"
|
33
30
|
|
34
31
|
module JsTestCore
|
35
32
|
DEFAULT_HOST = "0.0.0.0"
|
36
33
|
DEFAULT_PORT = 8080
|
37
34
|
|
38
35
|
class << self
|
39
|
-
|
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
|
40
45
|
end
|
41
46
|
end
|
File without changes
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module BeHttp
|
2
|
+
include Spec::Matchers
|
3
|
+
def be_http(status, headers, body)
|
4
|
+
SimpleMatcher.new(nil) do |given, matcher|
|
5
|
+
description = (<<-DESC).gsub(/^ +/, "")
|
6
|
+
be an http of
|
7
|
+
expected status: #{status.inspect}
|
8
|
+
actual status : #{given.status.inspect}
|
9
|
+
|
10
|
+
expected headers containing: #{headers.inspect}
|
11
|
+
actual headers : #{given.headers.inspect}
|
12
|
+
|
13
|
+
expected body containing: #{body.inspect}
|
14
|
+
actual body : #{given.body.inspect}
|
15
|
+
DESC
|
16
|
+
matcher.failure_message = description
|
17
|
+
matcher.negative_failure_message = "not #{description}"
|
18
|
+
|
19
|
+
passed = true
|
20
|
+
unless given.status == status
|
21
|
+
passed = false
|
22
|
+
end
|
23
|
+
unless headers.all?{|k, v| given.headers[k] == headers[k]}
|
24
|
+
passed = false
|
25
|
+
end
|
26
|
+
unless body.is_a?(Regexp) ? given.body =~ body : given.body.include?(body)
|
27
|
+
passed = false
|
28
|
+
end
|
29
|
+
passed
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
class Spec::ExampleGroup
|
2
|
+
class << self
|
3
|
+
def macro(name, &block)
|
4
|
+
eigen do
|
5
|
+
define_method(name, &block)
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
def eigen(&block)
|
10
|
+
eigen_class = (class << self; self; end)
|
11
|
+
eigen_class.class_eval(&block)
|
12
|
+
eigen_class
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
include Rack::Test::Methods
|
17
|
+
include BeHttp
|
18
|
+
attr_reader :core_path, :spec_root_path, :public_path, :server, :connection
|
19
|
+
before(:all) do
|
20
|
+
dir = File.dirname(__FILE__)
|
21
|
+
@core_path = File.expand_path("#{LIBRARY_ROOT_DIR}/spec/example_core")
|
22
|
+
@spec_root_path = File.expand_path("#{LIBRARY_ROOT_DIR}/spec/example_specs")
|
23
|
+
@public_path = File.expand_path("#{LIBRARY_ROOT_DIR}/spec/example_public")
|
24
|
+
stub(Thread).start.yields
|
25
|
+
end
|
26
|
+
|
27
|
+
before(:each) do
|
28
|
+
JsTestCore::Configuration.instance.spec_root_path = spec_root_path
|
29
|
+
JsTestCore::Configuration.instance.public_path = public_path
|
30
|
+
JsTestCore::Configuration.instance.core_path = core_path
|
31
|
+
end
|
32
|
+
|
33
|
+
def app
|
34
|
+
Sinatra::Application
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
class FakeSeleniumDriver
|
2
|
+
SESSION_ID = "DEADBEEF"
|
3
|
+
attr_reader :session_id
|
4
|
+
|
5
|
+
def initialize
|
6
|
+
@session_id = nil
|
7
|
+
end
|
8
|
+
|
9
|
+
def start
|
10
|
+
@session_id = SESSION_ID
|
11
|
+
end
|
12
|
+
|
13
|
+
def stop
|
14
|
+
@session_id = nil
|
15
|
+
end
|
16
|
+
|
17
|
+
def open(url)
|
18
|
+
end
|
19
|
+
|
20
|
+
def create_cookie(key_value, options="")
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
def session_started?
|
25
|
+
!!@session_id
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
class ShowTestExceptions
|
2
|
+
attr_reader :app
|
3
|
+
|
4
|
+
def initialize(app)
|
5
|
+
@app = app
|
6
|
+
end
|
7
|
+
|
8
|
+
def call(env)
|
9
|
+
app.call(env)
|
10
|
+
rescue StandardError, LoadError, SyntaxError => e
|
11
|
+
body = [
|
12
|
+
e.message,
|
13
|
+
e.backtrace.join("\n\t")
|
14
|
+
].join("\n")
|
15
|
+
[
|
16
|
+
500,
|
17
|
+
{"Content-Type" => "text",
|
18
|
+
"Content-Length" => body.size.to_s},
|
19
|
+
body
|
20
|
+
]
|
21
|
+
end
|
22
|
+
end
|