screw_server 0.1.4
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/Gemfile.run +3 -0
- data/Gemfile.run.lock +41 -0
- data/assets/screw-jslint.js +69 -0
- data/assets/screw-server.js +120 -0
- data/assets/screw.css +70 -0
- data/assets/vendor/fulljslint.js +5699 -0
- data/assets/vendor/screw-unit/CHANGES +7 -0
- data/assets/vendor/screw-unit/EXAMPLE.html +68 -0
- data/assets/vendor/screw-unit/LICENSE +22 -0
- data/assets/vendor/screw-unit/README.markdown +307 -0
- data/assets/vendor/screw-unit/example/models/cat.js +5 -0
- data/assets/vendor/screw-unit/example/models/man.js +17 -0
- data/assets/vendor/screw-unit/example/spec/matchers/have.js +8 -0
- data/assets/vendor/screw-unit/example/spec/models/cat_spec.js +31 -0
- data/assets/vendor/screw-unit/example/spec/models/man_spec.js +34 -0
- data/assets/vendor/screw-unit/example/spec/spec_helper.js +5 -0
- data/assets/vendor/screw-unit/example/spec/suite.html +25 -0
- data/assets/vendor/screw-unit/lib/jquery-1.2.6.js +3549 -0
- data/assets/vendor/screw-unit/lib/jquery.fn.js +29 -0
- data/assets/vendor/screw-unit/lib/jquery.print.js +109 -0
- data/assets/vendor/screw-unit/lib/screw.behaviors.js +101 -0
- data/assets/vendor/screw-unit/lib/screw.builder.js +90 -0
- data/assets/vendor/screw-unit/lib/screw.css +90 -0
- data/assets/vendor/screw-unit/lib/screw.events.js +45 -0
- data/assets/vendor/screw-unit/lib/screw.matchers.js +203 -0
- data/assets/vendor/screw-unit/spec/behaviors_spec.js +188 -0
- data/assets/vendor/screw-unit/spec/matchers_spec.js +391 -0
- data/assets/vendor/screw-unit/spec/print_spec.js +158 -0
- data/assets/vendor/screw-unit/spec/spec_helper.js +0 -0
- data/assets/vendor/screw-unit/spec/suite.html +18 -0
- data/assets/vendor/smoke/LICENSE +22 -0
- data/assets/vendor/smoke/README.markdown +68 -0
- data/assets/vendor/smoke/lib/smoke.core.js +49 -0
- data/assets/vendor/smoke/lib/smoke.mock.js +219 -0
- data/assets/vendor/smoke/lib/smoke.stub.js +29 -0
- data/assets/vendor/smoke/plugins/screw.mocking.js +26 -0
- data/assets/vendor/smoke/spec/core_spec.js +115 -0
- data/assets/vendor/smoke/spec/mock_spec.js +431 -0
- data/assets/vendor/smoke/spec/screw_integration_spec.js +17 -0
- data/assets/vendor/smoke/spec/spec_helper.js +0 -0
- data/assets/vendor/smoke/spec/stub_spec.js +17 -0
- data/assets/vendor/smoke/spec/su/jquery-1.2.3.js +3408 -0
- data/assets/vendor/smoke/spec/su/jquery.fn.js +29 -0
- data/assets/vendor/smoke/spec/su/jquery.print.js +108 -0
- data/assets/vendor/smoke/spec/su/screw.behaviors.js +91 -0
- data/assets/vendor/smoke/spec/su/screw.builder.js +80 -0
- data/assets/vendor/smoke/spec/su/screw.css +74 -0
- data/assets/vendor/smoke/spec/su/screw.events.js +38 -0
- data/assets/vendor/smoke/spec/su/screw.matchers.js +65 -0
- data/assets/vendor/smoke/spec/suite.html +29 -0
- data/bin/screw_server +43 -0
- data/lib/screw_server/app.rb +197 -0
- data/lib/screw_server/base.rb +21 -0
- data/lib/screw_server/fixture_file.rb +17 -0
- data/lib/screw_server/jslint_suite.rb +51 -0
- data/lib/screw_server/spec_file.rb +76 -0
- data/lib/screw_server.rb +2 -0
- data/screw_server.gemspec +28 -0
- data/views/index.haml +13 -0
- data/views/missing_spec_helper.haml +12 -0
- data/views/no_specs.haml +11 -0
- data/views/run_spec.haml +30 -0
- data/views/sample_spec.js +7 -0
- data/views/sample_spec_helper.js +2 -0
- metadata +257 -0
data/Gemfile.run
ADDED
data/Gemfile.run.lock
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
screw_server (0.1.3)
|
5
|
+
bundler (= 1.0.7)
|
6
|
+
daemons (= 1.0.10)
|
7
|
+
eventmachine (= 0.12.6)
|
8
|
+
haml (= 3.0.13)
|
9
|
+
json (= 1.4.3)
|
10
|
+
rack (= 1.1.0)
|
11
|
+
sinatra (= 1.0)
|
12
|
+
thin (= 1.2.7)
|
13
|
+
|
14
|
+
GEM
|
15
|
+
remote: http://rubygems.org/
|
16
|
+
specs:
|
17
|
+
daemons (1.0.10)
|
18
|
+
eventmachine (0.12.6)
|
19
|
+
haml (3.0.13)
|
20
|
+
json (1.4.3)
|
21
|
+
rack (1.1.0)
|
22
|
+
sinatra (1.0)
|
23
|
+
rack (>= 1.0)
|
24
|
+
thin (1.2.7)
|
25
|
+
daemons (>= 1.0.9)
|
26
|
+
eventmachine (>= 0.12.6)
|
27
|
+
rack (>= 1.0.0)
|
28
|
+
|
29
|
+
PLATFORMS
|
30
|
+
ruby
|
31
|
+
|
32
|
+
DEPENDENCIES
|
33
|
+
bundler (= 1.0.7)
|
34
|
+
daemons (= 1.0.10)
|
35
|
+
eventmachine (= 0.12.6)
|
36
|
+
haml (= 3.0.13)
|
37
|
+
json (= 1.4.3)
|
38
|
+
rack (= 1.1.0)
|
39
|
+
screw_server!
|
40
|
+
sinatra (= 1.0)
|
41
|
+
thin (= 1.2.7)
|
@@ -0,0 +1,69 @@
|
|
1
|
+
(function() {
|
2
|
+
|
3
|
+
Screw.jslint_scripts = {};
|
4
|
+
|
5
|
+
Screw.matching_suite = function(filename) {
|
6
|
+
var suite;
|
7
|
+
$.each(Screw.jslint_suites, function() {
|
8
|
+
var found;
|
9
|
+
$.each(this.file_list, function() {
|
10
|
+
if (this == filename) { found = true; }
|
11
|
+
});
|
12
|
+
if (found) { suite = this; }
|
13
|
+
});
|
14
|
+
return suite;
|
15
|
+
};
|
16
|
+
|
17
|
+
$("script").map(function() {
|
18
|
+
var source_url = $(this).attr("src");
|
19
|
+
if (source_url && source_url !== "") {
|
20
|
+
var normalized_source_url = source_url.split("?")[0];
|
21
|
+
|
22
|
+
if (!Screw.matching_suite(normalized_source_url)) { return; }
|
23
|
+
|
24
|
+
Screw.jslint_scripts[normalized_source_url] = null;
|
25
|
+
|
26
|
+
Screw.ajax({
|
27
|
+
url: source_url,
|
28
|
+
dataType: "text",
|
29
|
+
contentType: "text/plain",
|
30
|
+
success: function(code) {
|
31
|
+
Screw.jslint_scripts[normalized_source_url] = code;
|
32
|
+
}
|
33
|
+
});
|
34
|
+
}
|
35
|
+
});
|
36
|
+
|
37
|
+
if (Screw.jslint_suites.length > 0) {
|
38
|
+
Screw.Unit(function(){
|
39
|
+
describe("JSLINT check", function() {
|
40
|
+
it("should succeed", function() {
|
41
|
+
var message = "";
|
42
|
+
var ajax = Screw.ajax;
|
43
|
+
$.each(Screw.jslint_scripts, function(name, source_code) {
|
44
|
+
if (source_code === null) { throw "failed to load "+name; }
|
45
|
+
|
46
|
+
var suite = Screw.matching_suite(name);
|
47
|
+
|
48
|
+
if (!JSLINT(source_code, suite.options)) {
|
49
|
+
for (var i = 0; i < JSLINT.errors.length; i += 1) {
|
50
|
+
var e = JSLINT.errors[i];
|
51
|
+
if (e) {
|
52
|
+
var line = parseInt(e.line, 10) + 1;
|
53
|
+
var character = parseInt(e.character, 10) + 1;
|
54
|
+
message += 'Lint at ' + name + ":" + line + ' character ' +
|
55
|
+
character + ': ' + e.reason + "\n";
|
56
|
+
message += (e.evidence || '').
|
57
|
+
replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1") + "\n";
|
58
|
+
message += "\n";
|
59
|
+
}
|
60
|
+
}
|
61
|
+
}
|
62
|
+
});
|
63
|
+
if (message.length > 0) { throw message; }
|
64
|
+
});
|
65
|
+
});
|
66
|
+
});
|
67
|
+
}
|
68
|
+
|
69
|
+
}());
|
@@ -0,0 +1,120 @@
|
|
1
|
+
(function() {
|
2
|
+
|
3
|
+
if (!window.jQuery) {
|
4
|
+
alert(
|
5
|
+
"jQuery not found!\n"+
|
6
|
+
"jQuery must be provided by your application.\n"+
|
7
|
+
"Make sure the url for jquery required by your spec helper is correct.\n"+
|
8
|
+
"\n"+
|
9
|
+
"Example:\n"+
|
10
|
+
"If jQuery is installed under\n"
|
11
|
+
+"<your app>/public/javascripts/jquery.js\n"+
|
12
|
+
"then make sure the following line is in your spec_helper.js\n"+
|
13
|
+
"require('javascripts/jquery.js');"
|
14
|
+
);
|
15
|
+
return;
|
16
|
+
}
|
17
|
+
|
18
|
+
// save the ajax method in case a test messes with it
|
19
|
+
Screw.ajax = jQuery.ajax;
|
20
|
+
|
21
|
+
// Tests should be run without animations
|
22
|
+
// since a test must return synchronously
|
23
|
+
jQuery.fx.off = true;
|
24
|
+
|
25
|
+
$.extend(Screw.Specifications, {
|
26
|
+
use_fixture: function(fixture_name) {
|
27
|
+
Screw.Specifications.before(function() {
|
28
|
+
$("#fixture_container").html(window.fixture_container[fixture_name]);
|
29
|
+
});
|
30
|
+
}
|
31
|
+
});
|
32
|
+
|
33
|
+
window.require = function() {
|
34
|
+
// require is a NOOP in javascript.
|
35
|
+
// the require statement is only "used" by the screw_server.rb when generating the wrapper html.
|
36
|
+
// the screw_server looks for require statements per regexp.
|
37
|
+
};
|
38
|
+
|
39
|
+
var exampleName = function(element){
|
40
|
+
var exampleName = $.trim($(element).children("h2").text());
|
41
|
+
|
42
|
+
var names = contextNamesForExample(element);
|
43
|
+
names.push(exampleName);
|
44
|
+
|
45
|
+
return names.join(" ");
|
46
|
+
};
|
47
|
+
|
48
|
+
var contextNamesForExample = function(element){
|
49
|
+
var describes = $(element).parents('.describe').children('h1');
|
50
|
+
|
51
|
+
var contextNames = $.map(describes, function(context){
|
52
|
+
return $.trim($(context).text());
|
53
|
+
});
|
54
|
+
|
55
|
+
return contextNames.reverse();
|
56
|
+
};
|
57
|
+
|
58
|
+
$(Screw).bind('loaded', function() {
|
59
|
+
$('.it')
|
60
|
+
.bind('failed', function(e, reason) {
|
61
|
+
if (!window.console || !window.console.debug) { return; }
|
62
|
+
console.debug("Failure:");
|
63
|
+
console.debug(exampleName(this));
|
64
|
+
console.debug(reason.toString());
|
65
|
+
|
66
|
+
var file = reason.fileName || reason.sourceURL;
|
67
|
+
var line = reason.lineNumber || reason.line;
|
68
|
+
if (file || line) {
|
69
|
+
console.debug('line ' + line + ', ' + file);
|
70
|
+
}
|
71
|
+
var trace = reason.stack;
|
72
|
+
if (trace) {
|
73
|
+
console.debug(trace);
|
74
|
+
}
|
75
|
+
})
|
76
|
+
.bind('failed', function(e, reason) {
|
77
|
+
var test_dom = $(this);
|
78
|
+
if (reason.message) {
|
79
|
+
test_dom.append($('<p class="error"></p>').text(reason.message));
|
80
|
+
}
|
81
|
+
var trace = reason.stack;
|
82
|
+
if (trace) {
|
83
|
+
var trace_lines = trace.split("\n")
|
84
|
+
$.each(trace_lines, function(number, line) {
|
85
|
+
test_dom.append($('<p class="error"></p>').text(line));
|
86
|
+
});
|
87
|
+
}
|
88
|
+
});
|
89
|
+
|
90
|
+
$(Screw)
|
91
|
+
.bind('after', function() {
|
92
|
+
$("#fixture_container").empty();
|
93
|
+
|
94
|
+
var failures = $("li .it.failed");
|
95
|
+
if (failures.length > 0) {
|
96
|
+
window.scrollTo(0, failures.first().position().top);
|
97
|
+
}
|
98
|
+
})
|
99
|
+
|
100
|
+
});
|
101
|
+
|
102
|
+
Screw.Matchers.be = {
|
103
|
+
match: function(expected, actual) {
|
104
|
+
if (expected instanceof Array) {
|
105
|
+
for (var i = 0; i < actual.length; i = i + 1) {
|
106
|
+
if (!Screw.Matchers.be.match(expected[i], actual[i])) {
|
107
|
+
return false;
|
108
|
+
}
|
109
|
+
}
|
110
|
+
return actual.length === expected.length;
|
111
|
+
} else {
|
112
|
+
return actual === expected;
|
113
|
+
}
|
114
|
+
},
|
115
|
+
failure_message: function(expected, actual, not) {
|
116
|
+
return 'expected ' + $.print(actual) + (not ? ' not' : '') + ' to be ' + $.print(expected);
|
117
|
+
}
|
118
|
+
};
|
119
|
+
|
120
|
+
}());
|
data/assets/screw.css
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
* {
|
2
|
+
margin: 0;
|
3
|
+
padding: 0;
|
4
|
+
font-weight: normal;
|
5
|
+
list-style: none;
|
6
|
+
font-size: 1em;
|
7
|
+
}
|
8
|
+
|
9
|
+
body {
|
10
|
+
background: #fff;
|
11
|
+
color: #333;
|
12
|
+
font-family: "Helvetica Neue", Helvetica, Arial, "Sans-Serif";
|
13
|
+
font-size: 78.5%;
|
14
|
+
}
|
15
|
+
|
16
|
+
h3.status {
|
17
|
+
width: 100%;
|
18
|
+
margin: 0 0 1em 0;
|
19
|
+
padding: .75em;
|
20
|
+
font-size: 1.1em;
|
21
|
+
color: #fff;
|
22
|
+
background-color: #3875d7;
|
23
|
+
font-weight: normal;
|
24
|
+
-webkit-box-shadow: 0px 1px 5px #666;
|
25
|
+
-moz-box-shadow: 0px 2px 3px #999;
|
26
|
+
}
|
27
|
+
|
28
|
+
ul {
|
29
|
+
margin: .5em 0;
|
30
|
+
padding: 0 1em;
|
31
|
+
}
|
32
|
+
|
33
|
+
h1 {
|
34
|
+
margin: 0 1em;
|
35
|
+
padding: .25em 0;
|
36
|
+
border-bottom: 1px dotted #ccc;
|
37
|
+
font-weight: bold;
|
38
|
+
}
|
39
|
+
|
40
|
+
h2 {
|
41
|
+
padding: .2em .5em;
|
42
|
+
color: #ccc;
|
43
|
+
}
|
44
|
+
|
45
|
+
.enqueued h2 {
|
46
|
+
color: #999;
|
47
|
+
}
|
48
|
+
|
49
|
+
.passed h2 {
|
50
|
+
color: #333;
|
51
|
+
background: #abffa5;
|
52
|
+
border-top: 2px solid #ccffcc;
|
53
|
+
border-bottom: 2px solid #66ff66;
|
54
|
+
}
|
55
|
+
|
56
|
+
.failed h2 {
|
57
|
+
color: #333;
|
58
|
+
background: #ffaaaa;
|
59
|
+
border-top: 2px solid #ffcccc;
|
60
|
+
border-bottom: 2px solid #ff9977;
|
61
|
+
}
|
62
|
+
|
63
|
+
.error {
|
64
|
+
background-color: #f9f9f9;
|
65
|
+
margin-bottom: .5em;
|
66
|
+
padding: 1em;
|
67
|
+
border-left: 1px solid #ddd;
|
68
|
+
border-right: 1px solid #ddd;
|
69
|
+
border-bottom: 1px solid #ddd;
|
70
|
+
}
|