pivotal-screw-unit-server 0.5.3
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +27 -0
- data/README.markdown +354 -0
- data/Rakefile +42 -0
- data/VERSION.yml +4 -0
- data/bin/screw_unit +6 -0
- data/bin/screw_unit_server +20 -0
- data/core/CHANGES +10 -0
- data/core/EXAMPLE.html +68 -0
- data/core/LICENSE +22 -0
- data/core/README.markdown +307 -0
- data/core/example/models/cat.js +5 -0
- data/core/example/models/man.js +17 -0
- data/core/example/spec/matchers/have.js +8 -0
- data/core/example/spec/models/cat_spec.js +31 -0
- data/core/example/spec/models/man_spec.js +34 -0
- data/core/example/spec/spec_helper.js +5 -0
- data/core/example/spec/suite.html +25 -0
- data/core/lib/jquery-1.3.2.js +4376 -0
- data/core/lib/jquery.fn.js +30 -0
- data/core/lib/jquery.print.js +109 -0
- data/core/lib/screw.behaviors.js +93 -0
- data/core/lib/screw.builder.js +95 -0
- data/core/lib/screw.css +90 -0
- data/core/lib/screw.events.js +45 -0
- data/core/lib/screw.matchers.js +244 -0
- data/core/spec/behaviors_spec.js +188 -0
- data/core/spec/matchers_spec.js +372 -0
- data/core/spec/print_spec.js +158 -0
- data/core/spec/spec_helper.js +0 -0
- data/core/spec/suite.html +19 -0
- data/core/spec/with_screw_context_spec.js +9 -0
- data/init.rb +0 -0
- data/lib/screw_unit.rb +23 -0
- data/lib/screw_unit/representations.rb +2 -0
- data/lib/screw_unit/representations/spec.html.rb +117 -0
- data/spec/functional/functional_spec.rb +25 -0
- data/spec/functional/functional_spec_helper.rb +43 -0
- data/spec/functional/functional_spec_server_starter.rb +68 -0
- data/spec/functional_suite.rb +10 -0
- data/spec/spec_suite.rb +3 -0
- data/spec/unit/js_test_core/specs/spec_file_spec.rb +68 -0
- data/spec/unit/unit_spec_helper.rb +51 -0
- data/spec/unit_suite.rb +10 -0
- data/vendor/js-test-core/CHANGES +28 -0
- data/vendor/js-test-core/README +12 -0
- data/vendor/js-test-core/Rakefile +73 -0
- data/vendor/js-test-core/lib/js_test_core.rb +46 -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 +129 -0
- 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 +16 -0
- 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 +62 -0
- 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 +11 -0
- data/vendor/js-test-core/lib/js_test_core/selenium_server_configuration.rb +48 -0
- data/vendor/js-test-core/spec/example_core/JsTestCore.css +0 -0
- data/vendor/js-test-core/spec/example_core/JsTestCore.js +0 -0
- data/vendor/js-test-core/spec/example_core/subdir/SubDirFile.js +0 -0
- data/vendor/js-test-core/spec/example_public/favicon.ico +0 -0
- data/vendor/js-test-core/spec/example_public/javascripts/foo.js +3 -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_public/robots.txt +0 -0
- data/vendor/js-test-core/spec/example_public/stylesheets/example.css +3 -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/failing_spec.js +5 -0
- data/vendor/js-test-core/spec/example_specs/foo/failing_spec.js +6 -0
- data/vendor/js-test-core/spec/example_specs/foo/passing_spec.js +6 -0
- 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/spec_suite.rb +2 -0
- data/vendor/js-test-core/spec/specs/failing_spec.js +0 -0
- data/vendor/js-test-core/spec/unit/js_test_core/client_spec.rb +192 -0
- 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 +81 -0
- 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 +28 -0
- 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 +28 -0
- data/vendor/js-test-core/spec/unit_suite.rb +10 -0
- 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 +198 -0
@@ -0,0 +1,158 @@
|
|
1
|
+
Screw.Unit(function() {
|
2
|
+
describe("Print", function() {
|
3
|
+
describe('when given undefined', function() {
|
4
|
+
it("returns 'undefined'", function() {
|
5
|
+
expect($.print(undefined)).to(equal, 'undefined');
|
6
|
+
});
|
7
|
+
});
|
8
|
+
|
9
|
+
describe('when given null', function() {
|
10
|
+
it("returns 'null'", function() {
|
11
|
+
expect($.print(null)).to(equal, 'null');
|
12
|
+
});
|
13
|
+
});
|
14
|
+
|
15
|
+
describe('when given a number', function() {
|
16
|
+
it("returns the string representation of the number", function() {
|
17
|
+
expect($.print(1)).to(equal, '1');
|
18
|
+
expect($.print(1.01)).to(equal, '1.01');
|
19
|
+
expect($.print(-1)).to(equal, '-1');
|
20
|
+
});
|
21
|
+
});
|
22
|
+
|
23
|
+
describe('when given a boolean', function() {
|
24
|
+
it("returns the string representation of the boolean", function() {
|
25
|
+
expect($.print(true)).to(equal, 'true');
|
26
|
+
expect($.print(false)).to(equal, 'false');
|
27
|
+
});
|
28
|
+
});
|
29
|
+
|
30
|
+
describe('when given a string', function() {
|
31
|
+
it("returns the string, quoted", function() {
|
32
|
+
expect($.print('asdf')).to(equal, '"asdf"');
|
33
|
+
});
|
34
|
+
|
35
|
+
describe('when the string is longer than the [max_string] option', function() {
|
36
|
+
it("returns the string, truncated", function() {
|
37
|
+
expect($.print('asdf', { max_string: 3 })).to(equal, '"asd..."');
|
38
|
+
});
|
39
|
+
});
|
40
|
+
|
41
|
+
describe('when the strings has quotes or escaped characters', function() {
|
42
|
+
it("returns the string, with quotes and escaped characters escaped", function() {
|
43
|
+
expect($.print('as"df')).to(equal, '"as\\"df"');
|
44
|
+
expect($.print('as\tdf')).to(equal, '"as\\tdf"');
|
45
|
+
});
|
46
|
+
});
|
47
|
+
});
|
48
|
+
|
49
|
+
describe('when given a function', function() {
|
50
|
+
it("returns the function's signature", function() {
|
51
|
+
expect($.print(function() {})).to(match, /function\s*\(\)/);
|
52
|
+
expect($.print(function foo() {})).to(match, /function\s*foo\(\)/);
|
53
|
+
expect($.print(function foo(bar) {})).to(match, /function\s*foo\(bar\)/);
|
54
|
+
});
|
55
|
+
});
|
56
|
+
|
57
|
+
describe('when given a RegExp', function() {
|
58
|
+
it('should print the regexp', function() {
|
59
|
+
expect($.print(/abc/i)).to(equal, '/abc/i');
|
60
|
+
});
|
61
|
+
});
|
62
|
+
|
63
|
+
describe('when given NaN', function() {
|
64
|
+
it('should print the string "NaN"', function() {
|
65
|
+
expect($.print(NaN)).to(equal, 'NaN');
|
66
|
+
});
|
67
|
+
});
|
68
|
+
|
69
|
+
describe('when given 0', function() {
|
70
|
+
it('should print the string "0"', function() {
|
71
|
+
expect($.print(0)).to(equal, '0');
|
72
|
+
});
|
73
|
+
});
|
74
|
+
|
75
|
+
describe('when given an element', function() {
|
76
|
+
it("returns the string representation of the element", function() {
|
77
|
+
expect($.print($('<div></div>').get(0))).to(equal, '<div>');
|
78
|
+
expect($.print($('<div foo="bar"></div>').get(0))).to(equal, '<div>');
|
79
|
+
expect($.print($('<div class="foo" id="bar"></div>').get(0))).to(equal, '<div class="foo" id="bar">');
|
80
|
+
});
|
81
|
+
|
82
|
+
describe('when the element is an img', function() {
|
83
|
+
it('prints out the img src attribute', function() {
|
84
|
+
expect($.print($('<img src="test.png"/>'))).to(match, /<img src=".+?test.png">/);
|
85
|
+
})
|
86
|
+
});
|
87
|
+
});
|
88
|
+
|
89
|
+
describe('when given an array', function() {
|
90
|
+
it("returns the printed elements, comma separated, encircled by square brackets", function() {
|
91
|
+
expect($.print([])).to(equal, '[]');
|
92
|
+
expect($.print([1])).to(equal, '[ 1 ]');
|
93
|
+
expect($.print([1, 2, 3])).to(equal, '[ 1, 2, 3 ]');
|
94
|
+
});
|
95
|
+
|
96
|
+
describe('when the array is longer than the [max_array] option', function() {
|
97
|
+
it("returns the printed array, truncated", function() {
|
98
|
+
expect($.print([1, 2, 3, 4], { max_array: 2 })).to(equal, '[ 1, 2, 2 more... ]');
|
99
|
+
});
|
100
|
+
});
|
101
|
+
|
102
|
+
describe('when the array has arrays as its elements', function() {
|
103
|
+
it("returns the recursively printed array", function() {
|
104
|
+
expect($.print([[]])).to(equal, '[ [] ]');
|
105
|
+
expect($.print([ [1, 2, 3], 4 ])).to(equal, '[ [ 1, 2, 3 ], 4 ]');
|
106
|
+
});
|
107
|
+
});
|
108
|
+
|
109
|
+
describe('when the array has objects as its elements', function() {
|
110
|
+
it("returns recursively printed array", function() {
|
111
|
+
expect($.print([{}])).to(equal, '[ {} ]');
|
112
|
+
expect($.print([ { foo: 'bar' }, 'baz' ])).to(equal, '[ { foo: "bar" }, "baz" ]');
|
113
|
+
});
|
114
|
+
});
|
115
|
+
});
|
116
|
+
|
117
|
+
describe('when given arguments', function() {
|
118
|
+
it("returns the printed array of elements ", function() {
|
119
|
+
var args = null;
|
120
|
+
(function(){ args = arguments })(1,2,3);
|
121
|
+
expect($.print(args)).to(equal, '[ 1, 2, 3 ]');
|
122
|
+
});
|
123
|
+
});
|
124
|
+
|
125
|
+
describe('when given a jQuery', function() {
|
126
|
+
it("returns the printed array of elements engirthed in '$()'", function() {
|
127
|
+
expect($.print($('<div></div>'))).to(equal, '$([ <div> ])');
|
128
|
+
});
|
129
|
+
});
|
130
|
+
|
131
|
+
describe('when given a NodeList', function() {
|
132
|
+
it("returns the printed array of elements in the list", function() {
|
133
|
+
expect($.print(document.getElementsByTagName('body'))).to(equal, '[ <body> ]');
|
134
|
+
});
|
135
|
+
});
|
136
|
+
|
137
|
+
describe('when given an object', function() {
|
138
|
+
it("returns the keys and values of the object, enraptured with curly braces", function() {
|
139
|
+
expect($.print({})).to(equal, '{}');
|
140
|
+
expect($.print({ foo: 1, bar: 2 })).to(equal, '{ foo: 1, bar: 2 }');
|
141
|
+
});
|
142
|
+
|
143
|
+
describe('when the values of the object are non-primitive', function() {
|
144
|
+
it("recursively prints the keys and values", function() {
|
145
|
+
expect($.print({ foo: [1, 2] })).to(equal, '{ foo: [ 1, 2 ] }');
|
146
|
+
});
|
147
|
+
|
148
|
+
describe('when the object has circular references', function() {
|
149
|
+
it("returns elipses for circularities", function() {
|
150
|
+
var circular = {};
|
151
|
+
circular[0] = circular;
|
152
|
+
expect($.print(circular)).to(equal, '{ 0: ... }');
|
153
|
+
});
|
154
|
+
});
|
155
|
+
});
|
156
|
+
});
|
157
|
+
});
|
158
|
+
});
|
File without changes
|
@@ -0,0 +1,19 @@
|
|
1
|
+
<html>
|
2
|
+
<head>
|
3
|
+
<script src="../lib/jquery-1.3.2.js"></script>
|
4
|
+
<script src="../lib/jquery.fn.js"></script>
|
5
|
+
<script src="../lib/jquery.print.js"></script>
|
6
|
+
<script src="../lib/screw.builder.js"></script>
|
7
|
+
<script src="../lib/screw.matchers.js"></script>
|
8
|
+
<script src="../lib/screw.events.js"></script>
|
9
|
+
<script src="../lib/screw.behaviors.js"></script>
|
10
|
+
<script src="spec_helper.js"></script>
|
11
|
+
<script src="behaviors_spec.js"></script>
|
12
|
+
<script src="matchers_spec.js"></script>
|
13
|
+
<script src="print_spec.js"></script>
|
14
|
+
<script src="with_screw_context_spec.js"></script>
|
15
|
+
|
16
|
+
<link rel="stylesheet" href="../lib/screw.css">
|
17
|
+
</head>
|
18
|
+
<body></body>
|
19
|
+
</html>
|
@@ -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/init.rb
ADDED
File without changes
|
data/lib/screw_unit.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
require "rubygems"
|
2
|
+
|
3
|
+
dir = File.dirname(__FILE__)
|
4
|
+
$:.unshift(File.expand_path("#{dir}/../vendor/js-test-core/lib"))
|
5
|
+
require "js_test_core"
|
6
|
+
|
7
|
+
require "#{dir}/screw_unit/representations"
|
8
|
+
|
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
|
13
|
+
|
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
|
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
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require File.expand_path("#{File.dirname(__FILE__)}/functional_spec_helper")
|
2
|
+
|
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
|
+
|
15
|
+
it "runs a full passing Suite" do
|
16
|
+
ScrewUnit::Client.run(:spec_url => "#{root_url}/specs/foo/passing_spec")
|
17
|
+
stdout.string.strip.should == "SUCCESS"
|
18
|
+
end
|
19
|
+
|
20
|
+
it "runs a full failing Suite" do
|
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")
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require "rubygems"
|
2
|
+
require "spec"
|
3
|
+
require "spec/autorun"
|
4
|
+
require "selenium_rc"
|
5
|
+
require "thin"
|
6
|
+
dir = File.dirname(__FILE__)
|
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")
|
12
|
+
|
13
|
+
Spec::Runner.configure do |config|
|
14
|
+
config.mock_with :rr
|
15
|
+
end
|
16
|
+
|
17
|
+
Sinatra::Application.use ShowTestExceptions
|
18
|
+
Sinatra::Application.set :raise_errors, true
|
19
|
+
|
20
|
+
Sinatra::Application.use(ScrewUnit::App)
|
21
|
+
|
22
|
+
|
23
|
+
class Spec::ExampleGroup
|
24
|
+
include WaitFor
|
25
|
+
attr_reader :spec_root_path, :public_path
|
26
|
+
|
27
|
+
before(:all) do
|
28
|
+
@spec_root_path = FunctionalSpecServerStarter.spec_root_path
|
29
|
+
@public_path = FunctionalSpecServerStarter.public_path
|
30
|
+
unless SeleniumRC::Server.service_is_running?
|
31
|
+
Thread.start do
|
32
|
+
SeleniumRC::Server.boot
|
33
|
+
end
|
34
|
+
end
|
35
|
+
FunctionalSpecServerStarter.call
|
36
|
+
TCPSocket.wait_for_service :host => "0.0.0.0", :port => "4444"
|
37
|
+
end
|
38
|
+
|
39
|
+
def root_url
|
40
|
+
"http://#{ScrewUnit::DEFAULT_HOST}:#{ScrewUnit::DEFAULT_PORT}"
|
41
|
+
end
|
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
|