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/core/lib/screw.assets.js
DELETED
@@ -1,36 +0,0 @@
|
|
1
|
-
(function() {
|
2
|
-
Screw.Assets = {};
|
3
|
-
Screw.Assets.use_cache_buster = false; // TODO: NS/CTI - make this configurable from the UI.
|
4
|
-
var required_paths = [];
|
5
|
-
var included_stylesheets = {};
|
6
|
-
var cache_buster = parseInt(new Date().getTime()/(1*1000));
|
7
|
-
|
8
|
-
Screw.Assets.require = function(javascript_path, onload) {
|
9
|
-
if(!required_paths[javascript_path]) {
|
10
|
-
var full_path = javascript_path + ".js";
|
11
|
-
if (Screw.Assets.use_cache_buster) {
|
12
|
-
full_path += '?' + cache_buster;
|
13
|
-
}
|
14
|
-
document.write("<script src='" + full_path + "' type='text/javascript'></script>");
|
15
|
-
if(onload) {
|
16
|
-
var scripts = document.getElementsByTagName('script');
|
17
|
-
scripts[scripts.length-1].onload = onload;
|
18
|
-
}
|
19
|
-
required_paths[javascript_path] = true;
|
20
|
-
}
|
21
|
-
};
|
22
|
-
|
23
|
-
Screw.Assets.stylesheet = function(stylesheet_path) {
|
24
|
-
if(!included_stylesheets[stylesheet_path]) {
|
25
|
-
var full_path = stylesheet_path + ".css";
|
26
|
-
if(Screw.Assets.use_cache_buster) {
|
27
|
-
full_path += '?' + cache_buster;
|
28
|
-
}
|
29
|
-
document.write("<link rel='stylesheet' type='text/css' href='" + full_path + "' />");
|
30
|
-
included_stylesheets[stylesheet_path] = true;
|
31
|
-
}
|
32
|
-
};
|
33
|
-
|
34
|
-
window.require = Screw.Assets.require;
|
35
|
-
window.stylesheet = Screw.Assets.stylesheet;
|
36
|
-
})();
|
data/core/lib/screw.server.js
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
(function($) {
|
2
|
-
var ajax = $.ajax;
|
3
|
-
$(Screw).bind('after', function() {
|
4
|
-
var error_text = $(".error").map(function(i, element) {
|
5
|
-
return element.innerHTML;
|
6
|
-
}).get().join("\n");
|
7
|
-
|
8
|
-
var suite_id;
|
9
|
-
if(top.runOptions) {
|
10
|
-
suite_id = top.runOptions.getSessionId();
|
11
|
-
} else {
|
12
|
-
suite_id = 'user';
|
13
|
-
}
|
14
|
-
|
15
|
-
ajax({
|
16
|
-
type: "POST",
|
17
|
-
url: '/suites/' + suite_id + '/finish',
|
18
|
-
data: {"text": error_text}
|
19
|
-
});
|
20
|
-
});
|
21
|
-
})(jQuery);
|
data/lib/screw_unit/resources.rb
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
module ScrewUnit
|
2
|
-
module Resources
|
3
|
-
module Spec
|
4
|
-
def get(request, response)
|
5
|
-
html = <<-HTML
|
6
|
-
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
|
7
|
-
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ko">
|
8
|
-
<head>
|
9
|
-
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
|
10
|
-
<title>ScrewUnit results</title>
|
11
|
-
<script src="/core/jquery-1.2.3.js"></script>
|
12
|
-
<script src="/core/jquery.fn.js"></script>
|
13
|
-
<script src="/core/jquery.print.js"></script>
|
14
|
-
<script src="/core/screw.builder.js"></script>
|
15
|
-
<script src="/core/screw.matchers.js"></script>
|
16
|
-
<script src="/core/screw.events.js"></script>
|
17
|
-
<script src="/core/screw.behaviors.js"></script>
|
18
|
-
<script src="/core/screw.assets.js"></script>
|
19
|
-
<script src="/core/screw.server.js"></script>
|
20
|
-
<link rel="stylesheet" href="/core/screw.css">
|
21
|
-
HTML
|
22
|
-
spec_files.each do |file|
|
23
|
-
html << %{<script type="text/javascript" src="#{file.relative_path}"></script>\n}
|
24
|
-
end
|
25
|
-
|
26
|
-
html << <<-HTML
|
27
|
-
</head>
|
28
|
-
<body>
|
29
|
-
<div id="screw_unit_content"></div>
|
30
|
-
</body>
|
31
|
-
</html>
|
32
|
-
HTML
|
33
|
-
response.body = html.gsub(/^ /, "")
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
@@ -1,43 +0,0 @@
|
|
1
|
-
require File.expand_path("#{File.dirname(__FILE__)}/../../unit_spec_helper")
|
2
|
-
|
3
|
-
module JsTestCore
|
4
|
-
module Resources
|
5
|
-
module Specs
|
6
|
-
describe SpecDir do
|
7
|
-
attr_reader :dir
|
8
|
-
|
9
|
-
before do
|
10
|
-
stub(EventMachine).send_data
|
11
|
-
stub(EventMachine).close_connection
|
12
|
-
@dir = SpecDir.new(spec_root_path, '/specs')
|
13
|
-
end
|
14
|
-
|
15
|
-
describe "#get" do
|
16
|
-
attr_reader :html, :doc
|
17
|
-
before do
|
18
|
-
request = request('get', '/specs')
|
19
|
-
response = Rack::Response.new
|
20
|
-
dir.get(request, response)
|
21
|
-
@html = response.body
|
22
|
-
@doc = Hpricot(html)
|
23
|
-
end
|
24
|
-
|
25
|
-
it "returns script tags for each test javascript file" do
|
26
|
-
doc.at("script[@src='/specs/failing_spec.js']").should exist
|
27
|
-
doc.at("script[@src='/specs/foo/failing_spec.js']").should exist
|
28
|
-
doc.at("script[@src='/specs/foo/passing_spec.js']").should exist
|
29
|
-
end
|
30
|
-
|
31
|
-
it "returns the screw unit template" do
|
32
|
-
doc.at("link[@href='/core/screw.css']").should exist
|
33
|
-
doc.at("script[@src='/core/screw.builder.js']").should exist
|
34
|
-
doc.at("script[@src='/core/screw.events.js']").should exist
|
35
|
-
doc.at("script[@src='/core/screw.behaviors.js']").should exist
|
36
|
-
doc.at("script[@src='/core/screw.assets.js']").should exist
|
37
|
-
doc.at("body/#screw_unit_content").should_not be_nil
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
module JsTestCore
|
2
|
-
class RailsServer < Server
|
3
|
-
class << self
|
4
|
-
def run(rails_root, server_options = {})
|
5
|
-
server_options[:Host] ||= DEFAULT_HOST
|
6
|
-
server_options[:Port] ||= DEFAULT_PORT
|
7
|
-
Server.instance = new(rails_root, server_options[:Host], server_options[:Port])
|
8
|
-
Server.instance.run server_options
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
def initialize(rails_root, host=DEFAULT_HOST, port=DEFAULT_PORT)
|
13
|
-
super(
|
14
|
-
"#{rails_root}/spec/javascripts",
|
15
|
-
"#{rails_root}/public/javascripts",
|
16
|
-
"#{rails_root}/public",
|
17
|
-
host,
|
18
|
-
port
|
19
|
-
)
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
@@ -1,52 +0,0 @@
|
|
1
|
-
module JsTestCore
|
2
|
-
module Resources
|
3
|
-
class Dir < File
|
4
|
-
def locate(name)
|
5
|
-
if file = file(name)
|
6
|
-
file
|
7
|
-
elsif subdir = subdir(name)
|
8
|
-
subdir
|
9
|
-
else
|
10
|
-
raise "No file or directory found at #{relative_path}/#{name}."
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
def get(request, response)
|
15
|
-
|
16
|
-
end
|
17
|
-
|
18
|
-
def glob(pattern)
|
19
|
-
expanded_pattern = absolute_path + pattern
|
20
|
-
::Dir.glob(expanded_pattern).map do |absolute_globbed_path|
|
21
|
-
relative_globbed_path = absolute_globbed_path.gsub(absolute_path, relative_path)
|
22
|
-
File.new(absolute_globbed_path, relative_globbed_path)
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
protected
|
27
|
-
def determine_child_paths(name)
|
28
|
-
absolute_child_path = "#{absolute_path}/#{name}"
|
29
|
-
relative_child_path = "#{relative_path}/#{name}"
|
30
|
-
[absolute_child_path, relative_child_path]
|
31
|
-
end
|
32
|
-
|
33
|
-
def file(name)
|
34
|
-
absolute_file_path, relative_file_path = determine_child_paths(name)
|
35
|
-
if ::File.exists?(absolute_file_path) && !::File.directory?(absolute_file_path)
|
36
|
-
Resources::File.new(absolute_file_path, relative_file_path)
|
37
|
-
else
|
38
|
-
nil
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
def subdir(name)
|
43
|
-
absolute_dir_path, relative_dir_path = determine_child_paths(name)
|
44
|
-
if ::File.directory?(absolute_dir_path)
|
45
|
-
Resources::Dir.new(absolute_dir_path, relative_dir_path)
|
46
|
-
else
|
47
|
-
nil
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
module JsTestCore
|
2
|
-
module Resources
|
3
|
-
class FileNotFound
|
4
|
-
attr_reader :name
|
5
|
-
def initialize(name)
|
6
|
-
@name = name
|
7
|
-
end
|
8
|
-
|
9
|
-
def get(request, response)
|
10
|
-
response.status = 404
|
11
|
-
response.body = "Path #{name} not found. You may want to try the /#{WebRoot.dispatch_strategy} directory."
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
@@ -1,75 +0,0 @@
|
|
1
|
-
module JsTestCore
|
2
|
-
module Resources
|
3
|
-
class Runners
|
4
|
-
class FirefoxRunner
|
5
|
-
class << self
|
6
|
-
def resume(suite_id, text)
|
7
|
-
if instances[suite_id]
|
8
|
-
runner = instances.delete(suite_id)
|
9
|
-
runner.finalize(text)
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
def register_instance(runner)
|
14
|
-
instances[runner.suite_id] = runner
|
15
|
-
end
|
16
|
-
|
17
|
-
protected
|
18
|
-
def instances
|
19
|
-
@instances ||= {}
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
include FileUtils
|
24
|
-
attr_reader :profile_dir, :connection, :driver, :response
|
25
|
-
|
26
|
-
def initialize
|
27
|
-
profile_base = "#{::Dir.tmpdir}/js_test_core/firefox"
|
28
|
-
mkdir_p profile_base
|
29
|
-
@profile_dir = "#{profile_base}/#{Time.now.to_i}"
|
30
|
-
@connection = Server.connection
|
31
|
-
end
|
32
|
-
|
33
|
-
def post(request, response)
|
34
|
-
@response = response
|
35
|
-
|
36
|
-
spec_url = (request && request['spec_url']) ? request['spec_url'] : spec_suite_url
|
37
|
-
parsed_spec_url = URI.parse(spec_url)
|
38
|
-
selenium_port = (request['selenium_port'] || 4444).to_i
|
39
|
-
@driver = Selenium::SeleniumDriver.new(
|
40
|
-
request['selenium_host'] || 'localhost',
|
41
|
-
selenium_port,
|
42
|
-
'*firefox',
|
43
|
-
"#{parsed_spec_url.scheme}://#{parsed_spec_url.host}:#{parsed_spec_url.port}"
|
44
|
-
)
|
45
|
-
begin
|
46
|
-
driver.start
|
47
|
-
rescue Errno::ECONNREFUSED => e
|
48
|
-
raise Errno::ECONNREFUSED, "Cannot connect to Selenium Server on port #{selenium_port}. To start the selenium server, run `selenium`."
|
49
|
-
end
|
50
|
-
Thread.start do
|
51
|
-
driver.open(spec_url)
|
52
|
-
end
|
53
|
-
response.status = 200
|
54
|
-
FirefoxRunner.register_instance self
|
55
|
-
end
|
56
|
-
|
57
|
-
def finalize(text)
|
58
|
-
driver.stop
|
59
|
-
response.body = text
|
60
|
-
connection.send_body(response)
|
61
|
-
end
|
62
|
-
|
63
|
-
def suite_id
|
64
|
-
driver.session_id
|
65
|
-
end
|
66
|
-
|
67
|
-
protected
|
68
|
-
|
69
|
-
def spec_suite_url
|
70
|
-
"#{Server.root_url}/specs"
|
71
|
-
end
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|
@@ -1,50 +0,0 @@
|
|
1
|
-
module JsTestCore
|
2
|
-
module Resources
|
3
|
-
module Specs
|
4
|
-
class SpecDirSuperclass < ::JsTestCore::Resources::Dir
|
5
|
-
def get(request, response)
|
6
|
-
raise NotImplementedError, "#{self.class}#get needs to be implemented"
|
7
|
-
end
|
8
|
-
end
|
9
|
-
|
10
|
-
class SpecDir < SpecDirSuperclass
|
11
|
-
def spec_files
|
12
|
-
glob("/**/*_spec.js")
|
13
|
-
end
|
14
|
-
|
15
|
-
def locate(name)
|
16
|
-
if file = file(name)
|
17
|
-
file
|
18
|
-
elsif subdir = subdir(name)
|
19
|
-
subdir
|
20
|
-
elsif spec_file = spec_file(name)
|
21
|
-
spec_file
|
22
|
-
else
|
23
|
-
base_path = "#{relative_path}/#{name}"
|
24
|
-
raise "No file or directory found at #{base_path} or spec found at #{base_path}.js."
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
protected
|
29
|
-
|
30
|
-
def subdir(name)
|
31
|
-
absolute_dir_path, relative_dir_path = determine_child_paths(name)
|
32
|
-
if ::File.directory?(absolute_dir_path)
|
33
|
-
SpecDir.new(absolute_dir_path, relative_dir_path)
|
34
|
-
else
|
35
|
-
nil
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
def spec_file(name)
|
40
|
-
absolute_file_path, relative_file_path = determine_child_paths("#{name}.js")
|
41
|
-
if ::File.exists?(absolute_file_path) && !::File.directory?(absolute_file_path)
|
42
|
-
SpecFile.new(absolute_file_path, relative_file_path)
|
43
|
-
else
|
44
|
-
nil
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
module JsTestCore
|
2
|
-
module Resources
|
3
|
-
module Specs
|
4
|
-
class SpecFileSuperclass < ::JsTestCore::Resources::File
|
5
|
-
def get(request, response)
|
6
|
-
raise NotImplementedError, "#{self.class}#get needs to be implemented"
|
7
|
-
end
|
8
|
-
end
|
9
|
-
|
10
|
-
class SpecFile < SpecFileSuperclass
|
11
|
-
def spec_files
|
12
|
-
[self]
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
@@ -1,24 +0,0 @@
|
|
1
|
-
module JsTestCore
|
2
|
-
module Resources
|
3
|
-
class Suite
|
4
|
-
class << self
|
5
|
-
def locate(id)
|
6
|
-
new id
|
7
|
-
end
|
8
|
-
end
|
9
|
-
|
10
|
-
attr_reader :id
|
11
|
-
def initialize(id)
|
12
|
-
@id = id
|
13
|
-
end
|
14
|
-
|
15
|
-
def locate(name)
|
16
|
-
if name == 'finish'
|
17
|
-
SuiteFinish.new self
|
18
|
-
else
|
19
|
-
raise ArgumentError, "Invalid path: #{name}"
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
module JsTestCore
|
2
|
-
module Resources
|
3
|
-
class SuiteFinish
|
4
|
-
attr_reader :suite
|
5
|
-
def initialize(suite)
|
6
|
-
@suite = suite
|
7
|
-
end
|
8
|
-
|
9
|
-
def post(request, response)
|
10
|
-
if suite.id == 'user'
|
11
|
-
STDOUT.puts request['text']
|
12
|
-
else
|
13
|
-
Runners::FirefoxRunner.resume(suite.id, request['text'])
|
14
|
-
end
|
15
|
-
response.headers['Content-Length'] = "0"
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|