screw-unit-server 0.3.0 → 0.5.3
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/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
@@ -0,0 +1,9 @@
|
|
1
|
+
Screw.Unit(function(screw) { with(screw) {
|
2
|
+
describe("Screw.Unit", function() {
|
3
|
+
describe("when the passed-in function has an arity of 1", function() {
|
4
|
+
it("passes the Screw.Unit context into the function", function() {
|
5
|
+
expect(true).to(equal, true);
|
6
|
+
});
|
7
|
+
});
|
8
|
+
});
|
9
|
+
}});
|
data/lib/screw_unit.rb
CHANGED
@@ -3,24 +3,21 @@ require "rubygems"
|
|
3
3
|
dir = File.dirname(__FILE__)
|
4
4
|
$:.unshift(File.expand_path("#{dir}/../vendor/js-test-core/lib"))
|
5
5
|
require "js_test_core"
|
6
|
-
JsTestCore::Resources::WebRoot.dispatch_specs
|
7
6
|
|
8
|
-
require "#{dir}/screw_unit/
|
7
|
+
require "#{dir}/screw_unit/representations"
|
9
8
|
|
10
|
-
module ScrewUnit
|
11
|
-
DEFAULT_HOST = JsTestCore::DEFAULT_HOST
|
12
|
-
DEFAULT_PORT = JsTestCore::DEFAULT_PORT
|
13
|
-
|
14
|
-
Server = JsTestCore::Server
|
15
|
-
RailsServer = JsTestCore::RailsServer
|
16
|
-
Client = JsTestCore::Client
|
17
|
-
end
|
18
9
|
JsTestCore.core_path = File.expand_path("#{dir}/../core/lib")
|
10
|
+
JsTestCore::Resources::SpecFile.spec_representation_class = ScrewUnit::Representations::Spec
|
11
|
+
module ScrewUnit
|
12
|
+
include JsTestCore
|
19
13
|
|
20
|
-
class
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
14
|
+
class << self
|
15
|
+
def method_missing(method_name, *args, &block)
|
16
|
+
if JsTestCore::Configuration.instance.respond_to?(method_name)
|
17
|
+
JsTestCore::Configuration.instance.send(method_name, *args, &block)
|
18
|
+
else
|
19
|
+
super
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
26
23
|
end
|
@@ -0,0 +1,117 @@
|
|
1
|
+
module ScrewUnit
|
2
|
+
module Representations
|
3
|
+
class Spec < JsTestCore::Representations::Spec
|
4
|
+
def title_text
|
5
|
+
"Screw Unit suite"
|
6
|
+
end
|
7
|
+
|
8
|
+
def head_content
|
9
|
+
core_js_files
|
10
|
+
script(raw(<<-JS), :type => "text/javascript")
|
11
|
+
(function($) {
|
12
|
+
Screw.Assets = {};
|
13
|
+
Screw.Assets.use_cache_buster = false; // TODO: NS/CTI - make this configurable from the UI.
|
14
|
+
var required_paths = [];
|
15
|
+
var included_stylesheets = {};
|
16
|
+
var cache_buster = parseInt(new Date().getTime()/(1*1000));
|
17
|
+
|
18
|
+
function tag(name, attributes) {
|
19
|
+
var html = "<" + name;
|
20
|
+
for(var attribute in attributes) {
|
21
|
+
html += (" " + attribute + "='" + attributes[attribute]) + "'";
|
22
|
+
};
|
23
|
+
html += "></";
|
24
|
+
html += name;
|
25
|
+
html += ">";
|
26
|
+
return html;
|
27
|
+
}
|
28
|
+
|
29
|
+
Screw.Assets.require = function(javascript_path, onload) {
|
30
|
+
if(!required_paths[javascript_path]) {
|
31
|
+
var full_path = javascript_path + ".js";
|
32
|
+
if (Screw.Assets.use_cache_buster) {
|
33
|
+
full_path += '?' + cache_buster;
|
34
|
+
}
|
35
|
+
document.write(tag("script", {src: full_path, type: 'text/javascript'}));
|
36
|
+
if(onload) {
|
37
|
+
var scripts = document.getElementsByTagName('script');
|
38
|
+
scripts[scripts.length-1].onload = onload;
|
39
|
+
}
|
40
|
+
required_paths[javascript_path] = true;
|
41
|
+
}
|
42
|
+
};
|
43
|
+
|
44
|
+
Screw.Assets.stylesheet = function(stylesheet_path) {
|
45
|
+
if(!included_stylesheets[stylesheet_path]) {
|
46
|
+
var full_path = stylesheet_path + ".css";
|
47
|
+
if(Screw.Assets.use_cache_buster) {
|
48
|
+
full_path += '?' + cache_buster;
|
49
|
+
}
|
50
|
+
document.write(tag("link", {rel: 'stylesheet', type: 'text/css', href: full_path}));
|
51
|
+
included_stylesheets[stylesheet_path] = true;
|
52
|
+
}
|
53
|
+
};
|
54
|
+
|
55
|
+
window.require = Screw.Assets.require;
|
56
|
+
window.stylesheet = Screw.Assets.stylesheet;
|
57
|
+
})(jQuery);
|
58
|
+
|
59
|
+
(function($) {
|
60
|
+
var ajax = $.ajax;
|
61
|
+
$(Screw).bind('after', function() {
|
62
|
+
var error_text = $(".error").map(function(i, error_element) {
|
63
|
+
var element = $(error_element);
|
64
|
+
|
65
|
+
var parent_descriptions = element.parents("li.describe");
|
66
|
+
var parent_description_text = [];
|
67
|
+
|
68
|
+
for(var i=parent_descriptions.length-1; i >= 0; i--) {
|
69
|
+
parent_description_text.push($(parent_descriptions[i]).find("h1").text());
|
70
|
+
}
|
71
|
+
|
72
|
+
var it_text = element.parents("li.it").find("h2").text();
|
73
|
+
|
74
|
+
return parent_description_text.join(" ") + " " + it_text + ": " + element.text();
|
75
|
+
}).get().join("\\n");
|
76
|
+
|
77
|
+
ajax({
|
78
|
+
type: "POST",
|
79
|
+
url: '#{ScrewUnit::Resources::SeleniumSession.path("/finish")}',
|
80
|
+
data: {"text": error_text}
|
81
|
+
});
|
82
|
+
});
|
83
|
+
})(jQuery);
|
84
|
+
JS
|
85
|
+
project_js_files
|
86
|
+
link :rel => "stylesheet", :href => "/core/screw.css"
|
87
|
+
project_css_files
|
88
|
+
|
89
|
+
spec_script_elements
|
90
|
+
end
|
91
|
+
|
92
|
+
def core_js_files
|
93
|
+
script :src => jquery_js_file
|
94
|
+
script :src => "/core/jquery.fn.js"
|
95
|
+
script :src => "/core/jquery.print.js"
|
96
|
+
script :src => "/core/screw.builder.js"
|
97
|
+
script :src => "/core/screw.matchers.js"
|
98
|
+
script :src => "/core/screw.events.js"
|
99
|
+
script :src => "/core/screw.behaviors.js"
|
100
|
+
end
|
101
|
+
|
102
|
+
def project_js_files
|
103
|
+
end
|
104
|
+
|
105
|
+
def project_css_files
|
106
|
+
end
|
107
|
+
|
108
|
+
def jquery_js_file
|
109
|
+
"/core/jquery-1.3.2.js"
|
110
|
+
end
|
111
|
+
|
112
|
+
def body_content
|
113
|
+
div :id => "screw_unit_content"
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
@@ -1,14 +1,25 @@
|
|
1
1
|
require File.expand_path("#{File.dirname(__FILE__)}/functional_spec_helper")
|
2
2
|
|
3
3
|
describe "ScrewUnit" do
|
4
|
+
attr_reader :stdout, :request
|
5
|
+
before do
|
6
|
+
@stdout = StringIO.new
|
7
|
+
ScrewUnit::Client.const_set(:STDOUT, stdout)
|
8
|
+
@request = "http request"
|
9
|
+
end
|
10
|
+
|
11
|
+
after do
|
12
|
+
ScrewUnit::Client.__send__(:remove_const, :STDOUT)
|
13
|
+
end
|
14
|
+
|
4
15
|
it "runs a full passing Suite" do
|
5
|
-
mock(ScrewUnit::Client).puts("SUCCESS")
|
6
16
|
ScrewUnit::Client.run(:spec_url => "#{root_url}/specs/foo/passing_spec")
|
17
|
+
stdout.string.strip.should == "SUCCESS"
|
7
18
|
end
|
8
19
|
|
9
20
|
it "runs a full failing Suite" do
|
10
|
-
mock(ScrewUnit::Client).puts("FAILURE")
|
11
|
-
mock(ScrewUnit::Client).puts('expected true to equal false')
|
12
21
|
ScrewUnit::Client.run(:spec_url => "#{root_url}/specs/foo/failing_spec")
|
22
|
+
stdout.string.strip.should include("FAILURE")
|
23
|
+
stdout.string.strip.should include("A failing spec in foo fails: expected true to equal false")
|
13
24
|
end
|
14
25
|
end
|
@@ -1,55 +1,43 @@
|
|
1
1
|
require "rubygems"
|
2
2
|
require "spec"
|
3
|
-
|
3
|
+
require "spec/autorun"
|
4
|
+
require "selenium_rc"
|
5
|
+
require "thin"
|
4
6
|
dir = File.dirname(__FILE__)
|
5
|
-
|
6
|
-
require "
|
7
|
-
require "
|
8
|
-
require "
|
7
|
+
LIBRARY_ROOT_DIR = File.expand_path("#{dir}/../..")
|
8
|
+
require "#{LIBRARY_ROOT_DIR}/vendor/js-test-core/spec/spec_helpers/be_http"
|
9
|
+
require "#{LIBRARY_ROOT_DIR}/vendor/js-test-core/spec/spec_helpers/show_test_exceptions"
|
10
|
+
require "#{dir}/functional_spec_server_starter"
|
11
|
+
ARGV.push("-b")
|
9
12
|
|
10
13
|
Spec::Runner.configure do |config|
|
11
14
|
config.mock_with :rr
|
12
15
|
end
|
13
16
|
|
14
|
-
|
15
|
-
|
17
|
+
Sinatra::Application.use ShowTestExceptions
|
18
|
+
Sinatra::Application.set :raise_errors, true
|
16
19
|
|
17
|
-
|
18
|
-
extend self
|
19
|
-
def wait_for(time=5)
|
20
|
-
Timeout.timeout(time) do
|
21
|
-
loop do
|
22
|
-
value = yield
|
23
|
-
return value if value
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
20
|
+
Sinatra::Application.use(ScrewUnit::App)
|
28
21
|
|
29
|
-
|
22
|
+
|
23
|
+
class Spec::ExampleGroup
|
30
24
|
include WaitFor
|
31
|
-
attr_reader :spec_root_path, :
|
25
|
+
attr_reader :spec_root_path, :public_path
|
26
|
+
|
32
27
|
before(:all) do
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
end
|
37
|
-
dir = File.dirname(__FILE__)
|
38
|
-
@spec_root_path = "#{dir}/../example_specs"
|
39
|
-
@public_path = "#{dir}/../example_public"
|
40
|
-
@implementation_root_path = "#{public_path}/javascripts"
|
41
|
-
unless $screw_unit_server_started
|
28
|
+
@spec_root_path = FunctionalSpecServerStarter.spec_root_path
|
29
|
+
@public_path = FunctionalSpecServerStarter.public_path
|
30
|
+
unless SeleniumRC::Server.service_is_running?
|
42
31
|
Thread.start do
|
43
|
-
|
32
|
+
SeleniumRC::Server.boot
|
44
33
|
end
|
45
|
-
$screw_unit_server_started = true
|
46
|
-
end
|
47
|
-
wait_for do
|
48
|
-
Lsof.running?(8080)
|
49
34
|
end
|
35
|
+
FunctionalSpecServerStarter.call
|
36
|
+
TCPSocket.wait_for_service :host => "0.0.0.0", :port => "4444"
|
50
37
|
end
|
51
38
|
|
52
39
|
def root_url
|
53
40
|
"http://#{ScrewUnit::DEFAULT_HOST}:#{ScrewUnit::DEFAULT_PORT}"
|
54
41
|
end
|
55
42
|
end
|
43
|
+
|
@@ -0,0 +1,68 @@
|
|
1
|
+
require "rubygems"
|
2
|
+
require "timeout"
|
3
|
+
require "lsof"
|
4
|
+
dir = File.dirname(__FILE__)
|
5
|
+
$LOAD_PATH.unshift "#{dir}/../../lib"
|
6
|
+
require "screw_unit"
|
7
|
+
require "nokogiri"
|
8
|
+
|
9
|
+
module WaitFor
|
10
|
+
extend self
|
11
|
+
def wait_for(time=5)
|
12
|
+
Timeout.timeout(time) do
|
13
|
+
loop do
|
14
|
+
value = yield
|
15
|
+
return value if value
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
class FunctionalSpecServerStarter
|
22
|
+
class << self
|
23
|
+
include WaitFor
|
24
|
+
def call(threaded=true)
|
25
|
+
return if $screw_unit_server_started
|
26
|
+
|
27
|
+
Lsof.kill(8080)
|
28
|
+
wait_for do
|
29
|
+
!Lsof.running?(8080)
|
30
|
+
end
|
31
|
+
|
32
|
+
dir = File.dirname(__FILE__)
|
33
|
+
Dir.chdir("#{dir}/../../") do
|
34
|
+
Thread.start do
|
35
|
+
start_thin_server
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
wait_for do
|
40
|
+
Lsof.running?(8080)
|
41
|
+
end
|
42
|
+
$screw_unit_server_started = true
|
43
|
+
end
|
44
|
+
|
45
|
+
def start_thin_server
|
46
|
+
system("bin/screw_unit_server #{spec_root_path} #{public_path}")
|
47
|
+
at_exit do
|
48
|
+
Lsof.kill(8080)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def spec_root_path
|
53
|
+
File.expand_path("#{dir}/../example_specs")
|
54
|
+
end
|
55
|
+
|
56
|
+
def public_path
|
57
|
+
File.expand_path("#{dir}/../example_public")
|
58
|
+
end
|
59
|
+
|
60
|
+
def dir
|
61
|
+
dir = File.dirname(__FILE__)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
if $0 == __FILE__
|
67
|
+
FunctionalSpecServerStarter.call(false)
|
68
|
+
end
|
@@ -4,35 +4,60 @@ module JsTestCore
|
|
4
4
|
module Resources
|
5
5
|
module Specs
|
6
6
|
describe SpecFile do
|
7
|
-
describe "
|
8
|
-
|
7
|
+
describe "File" do
|
8
|
+
describe "GET /specs/failing_spec" do
|
9
|
+
attr_reader :html, :doc
|
10
|
+
before do
|
11
|
+
response = get(SpecFile.path("/failing_spec"))
|
12
|
+
response.should be_http(
|
13
|
+
200,
|
14
|
+
{},
|
15
|
+
""
|
16
|
+
)
|
17
|
+
|
18
|
+
@doc = Nokogiri::HTML(response.body)
|
19
|
+
end
|
9
20
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
21
|
+
it "returns script tags for the test javascript file" do
|
22
|
+
doc.at("script[@src='/specs/failing_spec.js']").should_not be_nil
|
23
|
+
end
|
24
|
+
|
25
|
+
it "returns the screw unit template" do
|
26
|
+
doc.at("link[@href='/core/screw.css']").should_not be_nil
|
27
|
+
doc.at("script[@src='/core/screw.builder.js']").should_not be_nil
|
28
|
+
doc.at("script[@src='/core/screw.events.js']").should_not be_nil
|
29
|
+
doc.at("script[@src='/core/screw.behaviors.js']").should_not be_nil
|
30
|
+
doc.at("body/#screw_unit_content").should_not be_nil
|
31
|
+
end
|
14
32
|
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe "Directory" do
|
36
|
+
describe "GET /specs" do
|
37
|
+
attr_reader :dir, :html, :doc
|
15
38
|
|
16
|
-
describe "#get" do
|
17
|
-
attr_reader :html, :doc
|
18
39
|
before do
|
19
|
-
|
20
|
-
response
|
21
|
-
|
22
|
-
|
23
|
-
|
40
|
+
response = get(SpecFile.path("/"))
|
41
|
+
response.should be_http(
|
42
|
+
200,
|
43
|
+
{},
|
44
|
+
""
|
45
|
+
)
|
46
|
+
|
47
|
+
@doc = Nokogiri::HTML(response.body)
|
24
48
|
end
|
25
49
|
|
26
|
-
it "returns script tags for
|
27
|
-
doc.at("script[@src='/specs/failing_spec.js']").
|
50
|
+
it "returns script tags for each test javascript file" do
|
51
|
+
doc.at("script[@src='/specs/failing_spec.js']").should_not be_nil
|
52
|
+
doc.at("script[@src='/specs/foo/failing_spec.js']").should_not be_nil
|
53
|
+
doc.at("script[@src='/specs/foo/passing_spec.js']").should_not be_nil
|
28
54
|
end
|
29
55
|
|
30
56
|
it "returns the screw unit template" do
|
31
|
-
doc.at("link[@href='/core/screw.css']").
|
32
|
-
doc.at("script[@src='/core/screw.builder.js']").
|
33
|
-
doc.at("script[@src='/core/screw.events.js']").
|
34
|
-
doc.at("script[@src='/core/screw.behaviors.js']").
|
35
|
-
doc.at("script[@src='/core/screw.assets.js']").should exist
|
57
|
+
doc.at("link[@href='/core/screw.css']").should_not be_nil
|
58
|
+
doc.at("script[@src='/core/screw.builder.js']").should_not be_nil
|
59
|
+
doc.at("script[@src='/core/screw.events.js']").should_not be_nil
|
60
|
+
doc.at("script[@src='/core/screw.behaviors.js']").should_not be_nil
|
36
61
|
doc.at("body/#screw_unit_content").should_not be_nil
|
37
62
|
end
|
38
63
|
end
|
@@ -1,120 +1,51 @@
|
|
1
1
|
require "rubygems"
|
2
2
|
require "spec"
|
3
|
-
|
3
|
+
require "spec/autorun"
|
4
|
+
require "rack/test"
|
5
|
+
ARGV.push("-b")
|
4
6
|
|
5
|
-
|
7
|
+
dir = File.dirname(__FILE__)
|
8
|
+
LIBRARY_ROOT_DIR = File.expand_path("#{dir}/../..")
|
9
|
+
$LOAD_PATH.unshift File.expand_path("#{LIBRARY_ROOT_DIR}/lib")
|
6
10
|
require "screw_unit"
|
7
|
-
require "
|
11
|
+
require "nokogiri"
|
8
12
|
require "guid"
|
13
|
+
require "#{LIBRARY_ROOT_DIR}/vendor/js-test-core/spec/spec_helpers/be_http"
|
14
|
+
require "#{LIBRARY_ROOT_DIR}/vendor/js-test-core/spec/spec_helpers/show_test_exceptions"
|
9
15
|
|
10
16
|
Spec::Runner.configure do |config|
|
11
17
|
config.mock_with :rr
|
12
18
|
end
|
13
19
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
!@actual.nil?
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
20
|
+
Sinatra::Application.use ShowTestExceptions
|
21
|
+
Sinatra::Application.set :raise_errors, true
|
22
|
+
Sinatra::Application.set :show_exceptions, false
|
23
|
+
JsTestCore::App.set :raise_errors, true
|
24
|
+
JsTestCore::App.set :show_exceptions, false
|
24
25
|
|
25
|
-
|
26
|
-
class << self
|
27
|
-
def thin_logging
|
28
|
-
@thin_logging = true if @thin_logging.nil?
|
29
|
-
@thin_logging
|
30
|
-
end
|
31
|
-
|
32
|
-
attr_writer :thin_logging
|
33
|
-
end
|
34
|
-
end
|
26
|
+
Sinatra::Application.use(ScrewUnit::App)
|
35
27
|
|
36
|
-
|
37
|
-
|
28
|
+
class Spec::ExampleGroup
|
29
|
+
include Rack::Test::Methods
|
30
|
+
include BeHttp
|
31
|
+
|
32
|
+
attr_reader :spec_root_path, :public_path, :server, :connection
|
38
33
|
before(:all) do
|
39
34
|
dir = File.dirname(__FILE__)
|
40
35
|
@spec_root_path = File.expand_path("#{dir}/../example_specs")
|
41
|
-
@implementation_root_path = File.expand_path("#{dir}/../example_public/javascripts")
|
42
36
|
@public_path = File.expand_path("#{dir}/../example_public")
|
43
37
|
end
|
44
38
|
|
45
39
|
before(:each) do
|
46
|
-
JsTestCore::
|
47
|
-
|
48
|
-
raise "You need to mock calls to EventMachine.run or the process will hang"
|
49
|
-
end
|
50
|
-
stub(EventMachine).start_server do
|
51
|
-
raise "You need to mock calls to EventMachine.start_server or the process will hang"
|
52
|
-
end
|
53
|
-
stub(EventMachine).send_data do
|
54
|
-
raise "Calls to EventMachine.send_data must be mocked or stubbed"
|
55
|
-
end
|
56
|
-
@connection = Thin::JsTestCoreConnection.new(Guid.new)
|
57
|
-
stub(EventMachine).send_data {raise "EventMachine.send_data must be handled"}
|
58
|
-
stub(EventMachine).close_connection {raise "EventMachine.close_connection must be handled"}
|
59
|
-
@server = JsTestCore::Server.instance
|
60
|
-
Thin::Logging.silent = !self.class.thin_logging
|
61
|
-
Thin::Logging.debug = self.class.thin_logging
|
62
|
-
end
|
63
|
-
|
64
|
-
after(:each) do
|
65
|
-
Thin::Logging.silent = true
|
66
|
-
Thin::Logging.debug = false
|
67
|
-
end
|
68
|
-
|
69
|
-
def get(url, params={})
|
70
|
-
request(:get, url, params)
|
71
|
-
end
|
72
|
-
|
73
|
-
def post(url, params={})
|
74
|
-
request(:post, url, params)
|
40
|
+
JsTestCore::Configuration.instance.spec_root_path = spec_root_path
|
41
|
+
JsTestCore::Configuration.instance.public_path = public_path
|
75
42
|
end
|
76
43
|
|
77
|
-
def
|
78
|
-
|
44
|
+
def app
|
45
|
+
Sinatra::Application
|
79
46
|
end
|
80
47
|
|
81
|
-
def delete(url, params={})
|
82
|
-
request(:delete, url, params)
|
83
|
-
end
|
84
|
-
|
85
|
-
def env_for(method, url, params)
|
86
|
-
Rack::MockRequest.env_for(url, params.merge({:method => method.to_s.upcase, 'js_test_core.connection' => connection}))
|
87
|
-
end
|
88
|
-
|
89
|
-
def create_request(method, url, params={})
|
90
|
-
env = env_for(method, url, params)
|
91
|
-
server.call(env)[2]
|
92
|
-
end
|
93
|
-
alias_method :request, :create_request
|
94
|
-
|
95
48
|
def core_path
|
96
49
|
JsTestCore::Server.core_path
|
97
50
|
end
|
98
|
-
|
99
|
-
def spec_file(relative_path)
|
100
|
-
absolute_path = spec_root_path + relative_path
|
101
|
-
JsTestCore::Resources::File.new(absolute_path, "/specs#{relative_path}")
|
102
|
-
end
|
103
|
-
|
104
|
-
def spec_dir(relative_path="")
|
105
|
-
absolute_path = spec_root_path + relative_path
|
106
|
-
JsTestCore::Resources::SpecDir.new(absolute_path, "/specs#{relative_path}")
|
107
|
-
end
|
108
|
-
|
109
|
-
def contain_spec_file_with_correct_paths(path_relative_to_spec_root)
|
110
|
-
expected_absolute_path = spec_root_path + path_relative_to_spec_root
|
111
|
-
expected_relative_path = "/specs" + path_relative_to_spec_root
|
112
|
-
|
113
|
-
::Spec::Matchers::SimpleMatcher.new(expected_relative_path) do |globbed_files|
|
114
|
-
file = globbed_files.find do |file|
|
115
|
-
file.absolute_path == expected_absolute_path
|
116
|
-
end
|
117
|
-
file && file.relative_path == expected_relative_path
|
118
|
-
end
|
119
|
-
end
|
120
51
|
end
|