snapdragon 0.1.5 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ChangeLog.markdown +16 -1
- data/README.markdown +7 -0
- data/example/spec/bar_spec.js +6 -0
- data/example/spec/hoopty_spec.js +8 -1
- data/lib/snapdragon/cli_application.rb +12 -61
- data/lib/snapdragon/path.rb +45 -0
- data/lib/snapdragon/resources/SnapdragonConsoleReporter.js +162 -0
- data/lib/snapdragon/spec_directory.rb +5 -5
- data/lib/snapdragon/spec_file.rb +8 -13
- data/lib/snapdragon/suite.rb +26 -32
- data/lib/snapdragon/version.rb +1 -1
- data/lib/snapdragon/views/run.erb +9 -12
- data/spec/lib/snapdragon/cli_application_spec.rb +7 -167
- data/spec/lib/snapdragon/path_spec.rb +100 -0
- data/spec/lib/snapdragon/spec_file_spec.rb +0 -10
- data/spec/lib/snapdragon/suite_spec.rb +23 -93
- metadata +7 -3
- data/lib/snapdragon/resources/ConsoleReporter.js +0 -163
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f1632da8263c3d4445832f76e9cc084c863946f2
|
4
|
+
data.tar.gz: 6abc0912510a43f966bdcd5a2092398f76255923
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0245feb11ac0d4a2bc8b6e9ba1f04b45f24be9635c18bd12c7b27df683f5a9d0ff9d5824d8858cd93a49de00ecb989ab7e94c0b39ca9d9a98e5f601ecd5da8e8
|
7
|
+
data.tar.gz: a295d969bf7ff0f5e0f4bcd86c6bd9dd46deec98d3fecd09c6867031e6de83f4c4ba7a32727136f5184b01d32c7c89a512d63adabf0ec42449baac4a3c1f33d7
|
data/ChangeLog.markdown
CHANGED
@@ -6,9 +6,24 @@ versions as well as provide a rough history.
|
|
6
6
|
|
7
7
|
#### Next Release
|
8
8
|
|
9
|
+
#### v0.1.6
|
10
|
+
|
11
|
+
* snapdragon_server when given `some/spec.js:344` now opens the browser to the
|
12
|
+
correctly filtered URL
|
13
|
+
([\#3](http://github.com/reachlocal/snapdragon/issues/3))
|
14
|
+
* snapdragon_server now finds new files/specs on browser refresh
|
15
|
+
([\#1](http://github.com/reachlocal/snapdragon/issues/1))
|
16
|
+
* Stack traces are now exclude jasmine.js lines
|
17
|
+
([\#10](http://github.com/reachlocal/snapdragon/issues/10))
|
18
|
+
* Added stack traces to the output of failed expectations
|
19
|
+
([\#14](http://github.com/reachlocal/snapdragon/issues/14))
|
20
|
+
* Moved from inline code loading to external script tag sources
|
21
|
+
([\#13](http://github.com/reachlocal/snapdragon/issues/13))
|
22
|
+
|
9
23
|
#### v0.1.5
|
10
24
|
|
11
|
-
* Jasmine runner now hosts files in CWD under `/:path`
|
25
|
+
* Jasmine runner now hosts files in CWD under `/:path`
|
26
|
+
([\#12](http://github.com/reachlocal/snapdragon/issues/12))
|
12
27
|
|
13
28
|
#### v0.1.4
|
14
29
|
|
data/README.markdown
CHANGED
@@ -32,6 +32,13 @@ running the following command:
|
|
32
32
|
|
33
33
|
## Quick Start Guide
|
34
34
|
|
35
|
+
If you are a visual learner Brian Miller and I have put together a Free
|
36
|
+
[Snapdragon](http://github.com/reachlocal/snapdragon) Screencast at [The Code
|
37
|
+
Breakdown](http://codebreakdown.com) ([direct
|
38
|
+
download](http://codebreakdown.com/screencasts/7/download)).
|
39
|
+
|
40
|
+
[![It in Action](http://media.codebreakdown.com/thumbnails/tcb-0007-thumbnail-400x225.png)](http://codebreakdown.com)
|
41
|
+
|
35
42
|
For those of you that like to jump right in and start playing with new tools
|
36
43
|
follow the steps below to get started.
|
37
44
|
|
data/example/spec/hoopty_spec.js
CHANGED
@@ -18,7 +18,14 @@ describe("Hoopty", function() {
|
|
18
18
|
describe(".hello", function() {
|
19
19
|
it("says hello there", function() {
|
20
20
|
var f = new Hoopty();
|
21
|
-
expect(f.hello()).toBe("Hello There");
|
21
|
+
expect(f.hello()).toBe("Hello There aeuaeuo");
|
22
|
+
});
|
23
|
+
});
|
24
|
+
|
25
|
+
describe(".goodbye", function() {
|
26
|
+
it("says goodbye", function() {
|
27
|
+
var f = new Hoopty();
|
28
|
+
expect(f.goodbye()).toBe("goodbye");
|
22
29
|
});
|
23
30
|
});
|
24
31
|
});
|
@@ -4,8 +4,6 @@ require 'launchy'
|
|
4
4
|
|
5
5
|
require_relative './web_application'
|
6
6
|
require_relative './suite'
|
7
|
-
require_relative './spec_file'
|
8
|
-
require_relative './spec_directory'
|
9
7
|
|
10
8
|
# Set the default_wait_time to something reasonable for the entire length of
|
11
9
|
# the test suite to run. This should probably eventually be something
|
@@ -17,77 +15,30 @@ module Snapdragon
|
|
17
15
|
class CliApplication
|
18
16
|
def initialize(arguements)
|
19
17
|
@args = arguements
|
20
|
-
@suite = Snapdragon::Suite.new
|
18
|
+
@suite = Snapdragon::Suite.new(arguements)
|
21
19
|
end
|
22
20
|
|
23
21
|
def run
|
24
|
-
|
25
|
-
|
22
|
+
session = Capybara::Session.new(:poltergeist, Snapdragon::WebApplication.new(nil, @suite))
|
23
|
+
if @suite.filtered?
|
24
|
+
session.visit("/run?spec=#{@suite.spec_query_param}")
|
25
|
+
else
|
26
|
+
session.visit("/run")
|
27
|
+
end
|
28
|
+
session.find("#testscomplete")
|
26
29
|
return 0
|
27
30
|
end
|
28
31
|
|
29
32
|
def serve
|
30
|
-
parse_arguements(@args)
|
31
33
|
server = Capybara::Server.new(Snapdragon::WebApplication.new(nil, @suite), 9292)
|
32
34
|
server.boot
|
33
|
-
Launchy.open('http://localhost:9292/run')
|
34
|
-
trap('SIGINT') { puts "Shutting down..."; exit 0 }
|
35
|
-
sleep
|
36
|
-
end
|
37
|
-
|
38
|
-
private
|
39
|
-
|
40
|
-
def parse_arguements(arguements)
|
41
|
-
arguements.each do |arguement|
|
42
|
-
parse_arguement(arguement)
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
def parse_arguement(arguement)
|
47
|
-
if is_a_file_path_and_line_number?(arguement)
|
48
|
-
path, line_num_str = arguement.split(':')
|
49
|
-
@suite.add_spec_file(SpecFile.new(path, line_num_str.to_i))
|
50
|
-
elsif is_a_file_path?(arguement)
|
51
|
-
@suite.add_spec_file(SpecFile.new(arguement))
|
52
|
-
elsif is_a_directory?(arguement)
|
53
|
-
spec_dir = Snapdragon::SpecDirectory.new(arguement)
|
54
|
-
@suite.add_spec_files(spec_dir.spec_files)
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
def is_a_file_path_and_line_number?(arguement)
|
59
|
-
if arguement =~ /^[\w\/\-\d\.]+[s|S]pec\.js:\d+$/
|
60
|
-
return true
|
61
|
-
else
|
62
|
-
return false
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
def is_a_file_path?(arguement)
|
67
|
-
if arguement =~ /^[\w\/\-\d\.]+[s|S]pec\.js$/
|
68
|
-
return true
|
69
|
-
else
|
70
|
-
return false
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
def is_a_directory?(arguement)
|
75
|
-
if arguement =~ /^[\w\/\-\d\.]+$/
|
76
|
-
return true
|
77
|
-
else
|
78
|
-
return false
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
def run_suite
|
83
|
-
session = Capybara::Session.new(:poltergeist, Snapdragon::WebApplication.new(nil, @suite))
|
84
35
|
if @suite.filtered?
|
85
|
-
|
86
|
-
session.find("#testscomplete")
|
36
|
+
Launchy.open("http://localhost:9292/run?spec=#{@suite.spec_query_param}")
|
87
37
|
else
|
88
|
-
|
89
|
-
session.find("#testscomplete")
|
38
|
+
Launchy.open('http://localhost:9292/run')
|
90
39
|
end
|
40
|
+
trap('SIGINT') { puts "Shutting down..."; exit 0 }
|
41
|
+
sleep
|
91
42
|
end
|
92
43
|
end
|
93
44
|
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require_relative './spec_directory'
|
2
|
+
require_relative './spec_file'
|
3
|
+
|
4
|
+
module Snapdragon
|
5
|
+
class Path
|
6
|
+
attr_reader :path, :line_number
|
7
|
+
|
8
|
+
def initialize(raw_path)
|
9
|
+
@raw_path = raw_path
|
10
|
+
if has_line_number?
|
11
|
+
@path, @line_number = raw_path.split(':')
|
12
|
+
@line_number = @line_number.to_i
|
13
|
+
else
|
14
|
+
@path = raw_path
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def spec_files
|
19
|
+
if exists?
|
20
|
+
if is_a_directory?
|
21
|
+
spec_dir = Snapdragon::SpecDirectory.new(self)
|
22
|
+
return spec_dir.spec_files
|
23
|
+
else
|
24
|
+
return [SpecFile.new(self)]
|
25
|
+
end
|
26
|
+
end
|
27
|
+
return []
|
28
|
+
end
|
29
|
+
|
30
|
+
def has_line_number?
|
31
|
+
return true if @raw_path =~ /^.*:\d+$/
|
32
|
+
return false
|
33
|
+
end
|
34
|
+
|
35
|
+
private
|
36
|
+
|
37
|
+
def is_a_directory?
|
38
|
+
return File.directory?(@path)
|
39
|
+
end
|
40
|
+
|
41
|
+
def exists?
|
42
|
+
return File.exists?(@path)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,162 @@
|
|
1
|
+
jasmine.SnapdragonConsoleReporter = function(options) {
|
2
|
+
var print = function(msg) { console.log(msg); },
|
3
|
+
showColors = options.showColors || true,
|
4
|
+
onComplete = options.onComplete || function() {},
|
5
|
+
specCount,
|
6
|
+
failureCount,
|
7
|
+
passedCount,
|
8
|
+
failedSpecs = [],
|
9
|
+
pendingSpecs = [],
|
10
|
+
pendingCount,
|
11
|
+
startTimestamp,
|
12
|
+
endTimestamp
|
13
|
+
ansi = {
|
14
|
+
green: '\033[32m',
|
15
|
+
red: '\033[31m',
|
16
|
+
yellow: '\033[33m',
|
17
|
+
none: '\033[0m'
|
18
|
+
};
|
19
|
+
|
20
|
+
function printNewline() {
|
21
|
+
print("");
|
22
|
+
}
|
23
|
+
|
24
|
+
function colored(color, str) {
|
25
|
+
return showColors ? (ansi[color] + str + ansi.none) : str;
|
26
|
+
}
|
27
|
+
|
28
|
+
function plural(str, count) {
|
29
|
+
return count == 1 ? str : str + "s";
|
30
|
+
}
|
31
|
+
|
32
|
+
function repeat(thing, times) {
|
33
|
+
var arr = [];
|
34
|
+
for (var i = 0; i < times; i++) {
|
35
|
+
arr.push(thing);
|
36
|
+
}
|
37
|
+
return arr;
|
38
|
+
}
|
39
|
+
|
40
|
+
function indent(str, spaces) {
|
41
|
+
var lines = (str || '').split("\n");
|
42
|
+
var newArr = [];
|
43
|
+
for (var i = 0; i < lines.length; i++) {
|
44
|
+
newArr.push(repeat(" ", spaces).join("") + lines[i]);
|
45
|
+
}
|
46
|
+
return newArr.join("\n");
|
47
|
+
}
|
48
|
+
|
49
|
+
function specFailureDetails(spec, failure_number) {
|
50
|
+
print(indent(failure_number + ") " + spec.getFullName(), 2));
|
51
|
+
|
52
|
+
var resultItems = spec.results().getItems();
|
53
|
+
for (var i = 0; i < resultItems.length; i++) {
|
54
|
+
var result = resultItems[i];
|
55
|
+
if (result.trace.stack) {
|
56
|
+
print(indent(colored("red", trimStackTrace(result.trace.stack)), 6));
|
57
|
+
} else {
|
58
|
+
print(indent(colored("red", result.message), 6));
|
59
|
+
}
|
60
|
+
}
|
61
|
+
printNewline();
|
62
|
+
}
|
63
|
+
|
64
|
+
function specPendingDetails(spec) {
|
65
|
+
print(indent(colored("yellow", spec.getFullName()), 2));
|
66
|
+
printNewline();
|
67
|
+
}
|
68
|
+
|
69
|
+
function signalCapybaraTestsFinishedRunning() {
|
70
|
+
var div = document.createElement('div');
|
71
|
+
div.id = 'testscomplete';
|
72
|
+
document.body.appendChild(div);
|
73
|
+
}
|
74
|
+
|
75
|
+
function trimStackTrace(stackTraceString) {
|
76
|
+
return stackTraceString.replace(/\s*at\s*http:\/\/127.0.0.1:\d+\/jasmine-core\/jasmine\.js:\d+\s*/g, "");
|
77
|
+
}
|
78
|
+
|
79
|
+
// Jasmine Hooks
|
80
|
+
|
81
|
+
this.log = function() {
|
82
|
+
};
|
83
|
+
|
84
|
+
this.reportRunnerStarting = function() {
|
85
|
+
startTimestamp = new Date().getTime();
|
86
|
+
specCount = 0;
|
87
|
+
failureCount = 0;
|
88
|
+
passedCount = 0;
|
89
|
+
pendingCount = 0;
|
90
|
+
print("Running examples...");
|
91
|
+
printNewline();
|
92
|
+
};
|
93
|
+
|
94
|
+
this.reportSuiteResults = function(suite) {
|
95
|
+
};
|
96
|
+
|
97
|
+
this.reportSpecStarting = function() {
|
98
|
+
};
|
99
|
+
|
100
|
+
this.reportSpecResults = function(spec) {
|
101
|
+
var results = spec.results();
|
102
|
+
|
103
|
+
if (!results.skipped) { // not pending
|
104
|
+
specCount++;
|
105
|
+
}
|
106
|
+
|
107
|
+
if (results.skipped) { // when you filter out tests with spec query param
|
108
|
+
pendingCount++;
|
109
|
+
pendingSpecs.push(spec);
|
110
|
+
} else if (results.passed()) { // passed
|
111
|
+
passedCount++;
|
112
|
+
} else { // failed
|
113
|
+
failureCount++;
|
114
|
+
failedSpecs.push(spec);
|
115
|
+
}
|
116
|
+
};
|
117
|
+
|
118
|
+
this.reportRunnerResults = function(options) {
|
119
|
+
endTimestamp = new Date().getTime();
|
120
|
+
|
121
|
+
// I have commented out the pending section below because v1.3.1 of
|
122
|
+
// jasmine doesn't have a concept of pending. It has a concept of
|
123
|
+
// skipped when you filter tests using the spec query param.
|
124
|
+
|
125
|
+
// if (pendingCount > 0) {
|
126
|
+
// print("Pending:");
|
127
|
+
// }
|
128
|
+
|
129
|
+
// for (var i = 0; i < pendingSpecs.length; i++) {
|
130
|
+
// specPendingDetails(pendingSpecs[i]);
|
131
|
+
// }
|
132
|
+
|
133
|
+
if (failureCount > 0) {
|
134
|
+
print("Failures:");
|
135
|
+
printNewline();
|
136
|
+
}
|
137
|
+
|
138
|
+
for (var i = 0; i < failedSpecs.length; i++) {
|
139
|
+
specFailureDetails(failedSpecs[i], i + 1);
|
140
|
+
}
|
141
|
+
|
142
|
+
var specCounts = specCount + " " + plural("example", specCount) + ", " + failureCount + " " + plural("failure", failureCount);
|
143
|
+
|
144
|
+
if (pendingCount) {
|
145
|
+
specCounts += ", " + pendingCount + " skipped";
|
146
|
+
}
|
147
|
+
|
148
|
+
var seconds = (endTimestamp - startTimestamp) / 1000.0;
|
149
|
+
print("Finished in " + seconds + " " + plural("second", seconds));
|
150
|
+
|
151
|
+
if (failureCount > 0) { // have any failures
|
152
|
+
print(colored("red", specCounts));
|
153
|
+
// } else if (pendingCount > 0) {
|
154
|
+
// print(colored("yellow", specCounts));
|
155
|
+
} else {
|
156
|
+
print(colored("green", specCounts));
|
157
|
+
}
|
158
|
+
|
159
|
+
onComplete();
|
160
|
+
signalCapybaraTestsFinishedRunning();
|
161
|
+
};
|
162
|
+
};
|
@@ -7,13 +7,13 @@ module Snapdragon
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def spec_files
|
10
|
-
|
11
|
-
Dir.glob("#{@path}/**/*").each do |
|
12
|
-
if
|
13
|
-
|
10
|
+
spec_file_objs = []
|
11
|
+
Dir.glob("#{@path.path}/**/*").each do |raw_path|
|
12
|
+
if raw_path =~ /^[\w\/\-\d]+[s|S]pec\.js$/
|
13
|
+
spec_file_objs << Snapdragon::SpecFile.new(Snapdragon::Path.new(raw_path))
|
14
14
|
end
|
15
15
|
end
|
16
|
-
return
|
16
|
+
return spec_file_objs
|
17
17
|
end
|
18
18
|
end
|
19
19
|
end
|
data/lib/snapdragon/spec_file.rb
CHANGED
@@ -1,19 +1,15 @@
|
|
1
1
|
module Snapdragon
|
2
2
|
class SpecFile
|
3
|
-
def initialize(path
|
3
|
+
def initialize(path)
|
4
4
|
@path = path
|
5
|
-
@line_number = line_number
|
6
5
|
end
|
7
6
|
|
8
|
-
def
|
9
|
-
|
10
|
-
content = f.read
|
11
|
-
f.close
|
12
|
-
return content
|
7
|
+
def relative_url_path
|
8
|
+
File.join('/', @path.path)
|
13
9
|
end
|
14
10
|
|
15
11
|
def require_paths
|
16
|
-
f = File.open(File.expand_path(@path), 'r')
|
12
|
+
f = File.open(File.expand_path(@path.path), 'r')
|
17
13
|
lines = f.readlines
|
18
14
|
f.close
|
19
15
|
|
@@ -21,7 +17,7 @@ module Snapdragon
|
|
21
17
|
|
22
18
|
lines.each do |line|
|
23
19
|
if line =~ /\/\/+\s+require_relative\(['"](.+)['"]\)\s+$/
|
24
|
-
require_paths << File.
|
20
|
+
require_paths << File.join('/', File.join(File.dirname(@path.path), $1))
|
25
21
|
end
|
26
22
|
end
|
27
23
|
|
@@ -29,8 +25,7 @@ module Snapdragon
|
|
29
25
|
end
|
30
26
|
|
31
27
|
def filtered?
|
32
|
-
return
|
33
|
-
return false
|
28
|
+
return @path.has_line_number?
|
34
29
|
end
|
35
30
|
|
36
31
|
def spec_query_param
|
@@ -38,10 +33,10 @@ module Snapdragon
|
|
38
33
|
|
39
34
|
# Work our way from the line number up to build the spec query param
|
40
35
|
# description
|
41
|
-
initial_line_number = @line_number
|
36
|
+
initial_line_number = @path.line_number
|
42
37
|
initial_line_index = initial_line_number - 1
|
43
38
|
|
44
|
-
f = open(File.expand_path(@path), 'r')
|
39
|
+
f = open(File.expand_path(@path.path), 'r')
|
45
40
|
lines = f.readlines
|
46
41
|
f.close
|
47
42
|
|
data/lib/snapdragon/suite.rb
CHANGED
@@ -1,50 +1,44 @@
|
|
1
|
+
require_relative './path'
|
2
|
+
|
1
3
|
module Snapdragon
|
2
4
|
class Suite
|
3
|
-
def initialize
|
4
|
-
@
|
5
|
-
@require_paths = Set.new
|
6
|
-
@filtered = false
|
7
|
-
@spec_query_param = ''
|
5
|
+
def initialize(paths)
|
6
|
+
@paths = paths
|
8
7
|
end
|
9
8
|
|
10
|
-
def
|
11
|
-
|
12
|
-
|
13
|
-
|
9
|
+
def spec_files
|
10
|
+
spec_file_objs = []
|
11
|
+
|
12
|
+
@paths.each do |raw_path|
|
13
|
+
path = Snapdragon::Path.new(raw_path)
|
14
|
+
spec_file_objs.concat(path.spec_files)
|
14
15
|
end
|
15
|
-
|
16
|
-
|
16
|
+
|
17
|
+
return spec_file_objs
|
17
18
|
end
|
18
19
|
|
19
|
-
def
|
20
|
-
|
21
|
-
|
20
|
+
def require_paths
|
21
|
+
require_paths = Set.new
|
22
|
+
|
23
|
+
spec_files.each do |foo|
|
24
|
+
require_paths.merge(foo.require_paths)
|
22
25
|
end
|
23
|
-
end
|
24
26
|
|
25
|
-
|
26
|
-
@specs
|
27
|
+
return require_paths
|
27
28
|
end
|
28
29
|
|
29
|
-
def
|
30
|
-
|
31
|
-
|
32
|
-
require_content << "\n\n// #{require_path} begins here\n"
|
33
|
-
f = File.open(require_path, 'r')
|
34
|
-
require_content << f.read
|
35
|
-
require_content << "\n// #{require_path} ends here\n\n"
|
36
|
-
f.close
|
30
|
+
def filtered?
|
31
|
+
spec_files.each do |spec_file|
|
32
|
+
return true if spec_file.filtered?
|
37
33
|
end
|
38
|
-
|
39
|
-
return require_content
|
34
|
+
return false
|
40
35
|
end
|
41
36
|
|
42
37
|
def spec_query_param
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
@filtered
|
38
|
+
spec_files.each do |spec_file|
|
39
|
+
return spec_file.spec_query_param if spec_file.filtered?
|
40
|
+
end
|
41
|
+
return ''
|
48
42
|
end
|
49
43
|
end
|
50
44
|
end
|
data/lib/snapdragon/version.rb
CHANGED
@@ -2,19 +2,17 @@
|
|
2
2
|
<script type="text/javascript" src="/jasmine-core/jasmine.js"></script>
|
3
3
|
<script type="text/javascript" src="/jasmine-core/jasmine-html.js"></script>
|
4
4
|
|
5
|
-
<script type="text/javascript" src="/resources/
|
5
|
+
<script type="text/javascript" src="/resources/SnapdragonConsoleReporter.js"></script>
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
<%=
|
10
|
-
|
7
|
+
<!-- The implementation code the spec files being tested need -->
|
8
|
+
<% @suite.require_paths.each do |path| %>
|
9
|
+
<script type="text/javascript" src="<%= path %>"></script>
|
10
|
+
<% end %>
|
11
11
|
|
12
|
-
|
13
|
-
// The spec file contents
|
12
|
+
<!-- The spec files -->
|
14
13
|
<% @suite.spec_files.each do |spec| %>
|
15
|
-
<%= spec.
|
14
|
+
<script type="text/javascript" src="<%= spec.relative_url_path %>"></script>
|
16
15
|
<% end %>
|
17
|
-
</script>
|
18
16
|
|
19
17
|
<script type="text/javascript">
|
20
18
|
(function() {
|
@@ -25,9 +23,8 @@
|
|
25
23
|
|
26
24
|
jasmineEnv.addReporter(htmlReporter);
|
27
25
|
|
28
|
-
var
|
29
|
-
|
30
|
-
jasmineEnv.addReporter(consoleReporter);
|
26
|
+
var snapdragonConsoleReporter = new jasmine.SnapdragonConsoleReporter({});
|
27
|
+
jasmineEnv.addReporter(snapdragonConsoleReporter);
|
31
28
|
|
32
29
|
jasmineEnv.specFilter = function(spec) {
|
33
30
|
return htmlReporter.specFilter(spec);
|
@@ -22,174 +22,14 @@ describe Snapdragon::CliApplication do
|
|
22
22
|
end
|
23
23
|
|
24
24
|
describe "#run" do
|
25
|
-
it "parses the given command line arguements" do
|
26
|
-
arguements = stub
|
27
|
-
app = Snapdragon::CliApplication.new(arguements)
|
28
|
-
app.should_receive(:parse_arguements).with(arguements)
|
29
|
-
app.stub(:run_suite)
|
30
|
-
app.run
|
31
|
-
end
|
32
|
-
|
33
|
-
it "runs the Jasmine suite" do
|
34
|
-
app = Snapdragon::CliApplication.new(['/some/path/to_some_spec.js'])
|
35
|
-
app.stub(:parse_arguements)
|
36
|
-
app.should_receive(:run_suite)
|
37
|
-
app.run
|
38
|
-
end
|
39
|
-
|
40
|
-
it "returns 0 representing success" do
|
41
|
-
app = Snapdragon::CliApplication.new(['/some/path/to_some_spec.js'])
|
42
|
-
app.stub(:parse_arguements)
|
43
|
-
app.stub(:run_suite)
|
44
|
-
app.run.should eq(0)
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
describe "#parse_arguements" do
|
49
|
-
let(:arguements) { ['some/path/to/some_spec.js:23', 'some/path/to/some_other_spec.js'] }
|
50
|
-
subject { Snapdragon::CliApplication.new(arguements) }
|
51
|
-
|
52
|
-
it "iterates over each of the arguments parsing each one" do
|
53
|
-
subject.should_receive(:parse_arguement).with('some/path/to/some_spec.js:23')
|
54
|
-
subject.should_receive(:parse_arguement).with('some/path/to/some_other_spec.js')
|
55
|
-
subject.send(:parse_arguements, arguements)
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
describe "#parse_arguement" do
|
60
|
-
subject { Snapdragon::CliApplication.new(stub) }
|
61
|
-
|
62
|
-
context "when the arg represents a file + line number" do
|
63
|
-
before do
|
64
|
-
subject.stub(:is_a_file_path_and_line_number?).and_return(true)
|
65
|
-
end
|
66
|
-
|
67
|
-
it "creates a SpecFile with the specified path and line number" do
|
68
|
-
Snapdragon::SpecFile.should_receive(:new).with('some/path/to/some_spec.js', 45).and_return(stub.as_null_object)
|
69
|
-
subject.send(:parse_arguement, 'some/path/to/some_spec.js:45')
|
70
|
-
end
|
71
|
-
|
72
|
-
it "appends the created SpecFile to the applications Suite" do
|
73
|
-
spec_file = stub('spec_file')
|
74
|
-
suite = mock('suite')
|
75
|
-
subject.instance_variable_set(:@suite, suite)
|
76
|
-
Snapdragon::SpecFile.stub(:new).and_return(spec_file)
|
77
|
-
suite.should_receive(:add_spec_file).with(spec_file)
|
78
|
-
subject.send(:parse_arguement, 'some/path/to/some_spec.js:45')
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
context "when the arg represents a file without a line number" do
|
83
|
-
before do
|
84
|
-
subject.stub(:is_a_file_path_and_line_number?).and_return(false)
|
85
|
-
subject.stub(:is_a_file_path?).and_return(true)
|
86
|
-
end
|
87
|
-
|
88
|
-
it "creates a SpecFile object with the specified path" do
|
89
|
-
Snapdragon::SpecFile.should_receive(:new).with('some/path/to/some_spec.js').and_return(stub.as_null_object)
|
90
|
-
subject.send(:parse_arguement, 'some/path/to/some_spec.js')
|
91
|
-
end
|
92
|
-
|
93
|
-
it "appends the created SpecFile to the application Suite" do
|
94
|
-
spec_file = stub('spec_file')
|
95
|
-
suite = mock('suite')
|
96
|
-
subject.instance_variable_set(:@suite, suite)
|
97
|
-
Snapdragon::SpecFile.stub(:new).and_return(spec_file)
|
98
|
-
suite.should_receive(:add_spec_file).with(spec_file)
|
99
|
-
subject.send(:parse_arguement, 'some/path/to/some_spec.js')
|
100
|
-
end
|
101
|
-
end
|
102
|
-
|
103
|
-
context "when the arg respesents a directory" do
|
104
|
-
before do
|
105
|
-
subject.stub(:is_a_file_path_and_line_number?).and_return(false)
|
106
|
-
subject.stub(:is_a_file_path?).and_return(false)
|
107
|
-
subject.stub(:is_a_directory?).and_return(true)
|
108
|
-
end
|
109
|
-
|
110
|
-
it "creates a SpecDirectory with the given directory path" do
|
111
|
-
Snapdragon::SpecDirectory.should_receive(:new).with('some/path/to/some_directory').and_return(stub(:spec_files => []))
|
112
|
-
subject.send(:parse_arguement, 'some/path/to/some_directory')
|
113
|
-
end
|
114
|
-
|
115
|
-
it "gets all of the SpecFiles recursively identified in the SpecDirectory path" do
|
116
|
-
spec_dir = mock
|
117
|
-
Snapdragon::SpecDirectory.stub(:new).and_return(spec_dir)
|
118
|
-
spec_dir.should_receive(:spec_files).and_return([])
|
119
|
-
subject.send(:parse_arguement, 'some/path/to/some_directory')
|
120
|
-
end
|
121
|
-
|
122
|
-
it "appends the SpecFiles to the application Suite" do
|
123
|
-
spec_dir = stub('spec_dir')
|
124
|
-
spec_files = stub('spec_files')
|
125
|
-
suite = mock('suite')
|
126
|
-
subject.instance_variable_set(:@suite, suite)
|
127
|
-
Snapdragon::SpecDirectory.stub(:new).and_return(spec_dir)
|
128
|
-
spec_dir.stub(:spec_files).and_return(spec_files)
|
129
|
-
suite.should_receive(:add_spec_files).with(spec_files)
|
130
|
-
subject.send(:parse_arguement, 'some/path/to/some_directory')
|
131
|
-
end
|
132
|
-
end
|
133
|
-
end
|
134
|
-
|
135
|
-
describe "#is_a_file_path_and_line_number?" do
|
136
|
-
let(:arguements) { stub('arguments') }
|
137
|
-
subject { Snapdragon::CliApplication.new(arguements) }
|
138
|
-
|
139
|
-
context "when it matches the pattern of a file path and line number" do
|
140
|
-
it "returns true" do
|
141
|
-
subject.send(:is_a_file_path_and_line_number?, 'some/path/to/some_spec.js:534').should be_true
|
142
|
-
end
|
143
|
-
end
|
144
|
-
|
145
|
-
context "when it does NOT match the pattern of a file path and line number" do
|
146
|
-
it "returns false" do
|
147
|
-
subject.send(:is_a_file_path_and_line_number?, 'some/path/to/some_spec.js').should be_false
|
148
|
-
end
|
149
|
-
end
|
150
|
-
end
|
151
|
-
|
152
|
-
describe "#is_a_file_path?" do
|
153
|
-
let(:arguements) { stub('arguments') }
|
154
|
-
subject { Snapdragon::CliApplication.new(arguements) }
|
155
|
-
|
156
|
-
context "when it matches the pattern of a file path" do
|
157
|
-
it "returns true" do
|
158
|
-
subject.send(:is_a_file_path?, 'some/path/to/some_spec.js').should be_true
|
159
|
-
end
|
160
|
-
end
|
161
|
-
|
162
|
-
context "when it does NOT match the pattern of a file path" do
|
163
|
-
it "returns false" do
|
164
|
-
subject.send(:is_a_file_path?, 'some/path/to/some.js').should be_false
|
165
|
-
end
|
166
|
-
end
|
167
|
-
end
|
168
|
-
|
169
|
-
describe "#is_a_directory?" do
|
170
|
-
let(:arguements) { stub('arguments') }
|
171
|
-
subject { Snapdragon::CliApplication.new(arguements) }
|
172
|
-
|
173
|
-
context "when it matches the pattern of a directory path" do
|
174
|
-
it "returns true" do
|
175
|
-
subject.send(:is_a_directory?, 'some/path/to/some_directory').should be_true
|
176
|
-
end
|
177
|
-
end
|
178
|
-
|
179
|
-
context "when it does NOT match the pattern of a directory path" do
|
180
|
-
it "returns false" do
|
181
|
-
subject.send(:is_a_directory?, 'some/path/to/some_spec.js').should be_false
|
182
|
-
end
|
183
|
-
end
|
184
|
-
end
|
185
|
-
|
186
|
-
describe "#run_suite" do
|
187
25
|
let(:arguements) { stub('arguments') }
|
188
26
|
subject { Snapdragon::CliApplication.new(arguements) }
|
189
27
|
|
190
28
|
it "creates a capybara session" do
|
29
|
+
suite = stub(filtered?: false)
|
30
|
+
Snapdragon::Suite.stub(:new).and_return(suite)
|
191
31
|
Capybara::Session.should_receive(:new).and_return(stub.as_null_object)
|
192
|
-
subject.
|
32
|
+
subject.run
|
193
33
|
end
|
194
34
|
|
195
35
|
context "when suite is filtered" do
|
@@ -198,10 +38,10 @@ describe Snapdragon::CliApplication do
|
|
198
38
|
end
|
199
39
|
|
200
40
|
it "visits /run with the spec query param in the capybara session" do
|
201
|
-
session = mock
|
41
|
+
session = mock(find: nil)
|
202
42
|
Capybara::Session.stub(:new).and_return(session)
|
203
43
|
session.should_receive(:visit).with("/run?spec=some_query_param_spec_filter")
|
204
|
-
subject.
|
44
|
+
subject.run
|
205
45
|
end
|
206
46
|
end
|
207
47
|
|
@@ -211,10 +51,10 @@ describe Snapdragon::CliApplication do
|
|
211
51
|
end
|
212
52
|
|
213
53
|
it "visits /run in that capybara session" do
|
214
|
-
session = mock
|
54
|
+
session = mock(find: nil)
|
215
55
|
Capybara::Session.stub(:new).and_return(session)
|
216
56
|
session.should_receive(:visit).with('/run')
|
217
|
-
subject.
|
57
|
+
subject.run
|
218
58
|
end
|
219
59
|
end
|
220
60
|
end
|
@@ -0,0 +1,100 @@
|
|
1
|
+
require_relative '../../../lib/snapdragon/path'
|
2
|
+
|
3
|
+
describe Snapdragon::Path do
|
4
|
+
describe "#initialize" do
|
5
|
+
it "stores the raw path in an instance variable" do
|
6
|
+
path = Snapdragon::Path.new('some/path:423')
|
7
|
+
path.instance_variable_get(:@raw_path).should eq('some/path:423')
|
8
|
+
end
|
9
|
+
|
10
|
+
context "when given a path and line number" do
|
11
|
+
it "stores the path in an instance variable" do
|
12
|
+
path = Snapdragon::Path.new('some/path:423')
|
13
|
+
path.instance_variable_get(:@path).should eq('some/path')
|
14
|
+
end
|
15
|
+
|
16
|
+
it "stores the line number in an instance variable" do
|
17
|
+
path = Snapdragon::Path.new('some/path:423')
|
18
|
+
path.instance_variable_get(:@line_number).should eq(423)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
context "when given a path" do
|
23
|
+
it "stores teh path in an instance variable" do
|
24
|
+
path = Snapdragon::Path.new('some/path')
|
25
|
+
path.instance_variable_get(:@path).should eq('some/path')
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe "#spec_files" do
|
31
|
+
let(:path) { Snapdragon::Path.new('some/path') }
|
32
|
+
|
33
|
+
context "when does NOT exist" do
|
34
|
+
before do
|
35
|
+
path.stub(:exists?).and_return(false)
|
36
|
+
end
|
37
|
+
|
38
|
+
it "returns an empty array" do
|
39
|
+
path.spec_files.should eq([])
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
context "when does exist" do
|
44
|
+
before do
|
45
|
+
path.stub(:exists?).and_return(true)
|
46
|
+
end
|
47
|
+
|
48
|
+
context "when is a directory" do
|
49
|
+
before do
|
50
|
+
path.stub(:is_a_directory?).and_return(true)
|
51
|
+
end
|
52
|
+
|
53
|
+
it "constructs a spec directory" do
|
54
|
+
Snapdragon::SpecDirectory.should_receive(:new).and_return(stub.as_null_object)
|
55
|
+
path.spec_files
|
56
|
+
end
|
57
|
+
|
58
|
+
it "returns the spec files recursively found in the spec directory" do
|
59
|
+
spec_files = stub
|
60
|
+
spec_dir = stub(spec_files: spec_files)
|
61
|
+
Snapdragon::SpecDirectory.should_receive(:new).and_return(spec_dir)
|
62
|
+
path.spec_files.should eq(spec_files)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
context "when is NOT a directory" do
|
67
|
+
before do
|
68
|
+
path.stub(:is_a_directory?).and_return(false)
|
69
|
+
end
|
70
|
+
|
71
|
+
it "constructs a spec file" do
|
72
|
+
Snapdragon::SpecFile.should_receive(:new)
|
73
|
+
path.spec_files
|
74
|
+
end
|
75
|
+
|
76
|
+
it "returns an array containing a newly constructed spec file" do
|
77
|
+
spec_file = stub
|
78
|
+
Snapdragon::SpecFile.stub(:new).and_return(spec_file)
|
79
|
+
path.spec_files.should eq([spec_file])
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
describe "#has_line_number?" do
|
86
|
+
context "when the given raw path has a line number" do
|
87
|
+
it "returns true" do
|
88
|
+
path = Snapdragon::Path.new('some/path:234')
|
89
|
+
path.has_line_number?.should be_true
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
context "when the given raw path does NOT have a line number" do
|
94
|
+
it "returns false" do
|
95
|
+
path = Snapdragon::Path.new('some/path')
|
96
|
+
path.has_line_number?.should be_false
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
@@ -6,16 +6,6 @@ describe Snapdragon::SpecFile do
|
|
6
6
|
spec_file = Snapdragon::SpecFile.new('some/path/to_some_spec.js')
|
7
7
|
spec_file.instance_variable_get(:@path).should eq('some/path/to_some_spec.js')
|
8
8
|
end
|
9
|
-
|
10
|
-
it "assigns the given line number" do
|
11
|
-
spec_file = Snapdragon::SpecFile.new('some/path/to_some_spec.js', 54)
|
12
|
-
spec_file.instance_variable_get(:@line_number).should eq(54)
|
13
|
-
end
|
14
|
-
|
15
|
-
it "line number defaults to nil when not assigned" do
|
16
|
-
spec_file = Snapdragon::SpecFile.new('some/path/to_some_spec.js')
|
17
|
-
spec_file.instance_variable_get(:@line_number).should eq(nil)
|
18
|
-
end
|
19
9
|
end
|
20
10
|
|
21
11
|
describe "#read" do
|
@@ -2,110 +2,40 @@ require_relative '../../../lib/snapdragon/suite'
|
|
2
2
|
|
3
3
|
describe Snapdragon::Suite do
|
4
4
|
describe "#initialize" do
|
5
|
-
it "
|
6
|
-
|
7
|
-
|
5
|
+
it "constucts an instance of a Suite given an array of paths" do
|
6
|
+
paths = [stub, stub, stub]
|
7
|
+
Snapdragon::Suite.new(paths)
|
8
8
|
end
|
9
9
|
|
10
|
-
it "
|
11
|
-
|
12
|
-
suite.
|
13
|
-
|
14
|
-
|
15
|
-
it "assigns @filtered to an initial state of false" do
|
16
|
-
suite = Snapdragon::Suite.new
|
17
|
-
suite.instance_variable_get(:@filtered).should be_false
|
18
|
-
end
|
19
|
-
|
20
|
-
it "assigns @spec_query_param to an initial state of empty string" do
|
21
|
-
suite = Snapdragon::Suite.new
|
22
|
-
suite.instance_variable_get(:@spec_query_param).should eq('')
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
describe "#spec_files" do
|
27
|
-
it "returns the array of specs which the suite contains" do
|
28
|
-
spec_file = stub(:require_paths => [])
|
29
|
-
subject.instance_variable_set(:@specs, [spec_file])
|
30
|
-
subject.spec_files.should eq([spec_file])
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
describe "#add_spec_file" do
|
35
|
-
it "appends the given SpecFile to the suite of specs" do
|
36
|
-
spec_file = stub(:require_paths => [], :filtered? => false)
|
37
|
-
specs = mock
|
38
|
-
subject.instance_variable_set(:@specs, specs)
|
39
|
-
specs.should_receive(:<<).with(spec_file)
|
40
|
-
subject.add_spec_file(spec_file)
|
41
|
-
end
|
42
|
-
|
43
|
-
it "gets the require paths outlined in the spec" do
|
44
|
-
spec_file = mock(:filtered? => false)
|
45
|
-
spec_file.should_receive(:require_paths).and_return([])
|
46
|
-
subject.add_spec_file(spec_file)
|
47
|
-
end
|
48
|
-
|
49
|
-
it "contactinates the specs require paths to the suites require paths collection" do
|
50
|
-
spec_file = stub(:filtered? => false)
|
51
|
-
require_paths = stub
|
52
|
-
suite_require_paths = mock
|
53
|
-
subject.instance_variable_set(:@require_paths, suite_require_paths)
|
54
|
-
spec_file.stub(:require_paths).and_return(require_paths)
|
55
|
-
suite_require_paths.should_receive(:merge).with(require_paths)
|
56
|
-
subject.add_spec_file(spec_file)
|
57
|
-
end
|
58
|
-
|
59
|
-
context "when spec is filtered" do
|
60
|
-
it "assigns @filtered to true" do
|
61
|
-
spec_file = stub(:require_paths => [], :filtered? => true, :spec_query_param => '')
|
62
|
-
subject.add_spec_file(spec_file)
|
63
|
-
subject.instance_variable_get(:@filtered).should be_true
|
64
|
-
end
|
65
|
-
|
66
|
-
it "assigns @spec_query_parm to the spec_files spec_query_parma" do
|
67
|
-
spec_file = stub(:require_paths => [], :filtered? => true, :spec_query_param => 'some_spec_query_param')
|
68
|
-
subject.add_spec_file(spec_file)
|
69
|
-
subject.instance_variable_get(:@spec_query_param).should eq('some_spec_query_param')
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
describe "#add_spec_files" do
|
75
|
-
it "adds each of the spec files" do
|
76
|
-
spec_file_one = stub('spec_file_one')
|
77
|
-
spec_file_two = stub('spec_file_two')
|
78
|
-
subject.should_receive(:add_spec_file).with(spec_file_one)
|
79
|
-
subject.should_receive(:add_spec_file).with(spec_file_two)
|
80
|
-
subject.add_spec_files([spec_file_one, spec_file_two])
|
10
|
+
it "stores the paths in an instance variable" do
|
11
|
+
paths = [stub, stub, stub]
|
12
|
+
suite = Snapdragon::Suite.new(paths)
|
13
|
+
suite.instance_variable_get(:@paths).should eq(paths)
|
81
14
|
end
|
82
15
|
end
|
83
16
|
|
84
17
|
describe "#spec_files" do
|
85
|
-
it "
|
86
|
-
|
87
|
-
|
88
|
-
|
18
|
+
it "creates a path object to represent the path" do
|
19
|
+
paths = ['path_a_str', 'path_b_str']
|
20
|
+
suite = Snapdragon::Suite.new(paths)
|
21
|
+
Snapdragon::Path.should_receive(:new).with('path_a_str').and_return(stub(spec_files: []))
|
22
|
+
Snapdragon::Path.should_receive(:new).with('path_b_str').and_return(stub(spec_files: []))
|
23
|
+
suite.spec_files
|
89
24
|
end
|
90
|
-
end
|
91
|
-
|
92
|
-
describe "#output_spec_dependencies" do
|
93
|
-
it "needs to be tested"
|
94
|
-
end
|
95
25
|
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
26
|
+
it "returns the collection of the spec files of all of the paths" do
|
27
|
+
paths = ['path_a_str', 'path_b_str']
|
28
|
+
suite = Snapdragon::Suite.new(paths)
|
29
|
+
spec_file_a = stub('spec_file_a'), spec_file_b = stub('spec_file_b')
|
30
|
+
Snapdragon::Path.stub(:new).with('path_a_str').and_return(stub(spec_files: [spec_file_a]))
|
31
|
+
Snapdragon::Path.stub(:new).with('path_b_str').and_return(stub(spec_files: [spec_file_b]))
|
32
|
+
suite.spec_files.should eq([spec_file_a, spec_file_b])
|
101
33
|
end
|
102
34
|
end
|
103
35
|
|
104
|
-
describe "#
|
105
|
-
it "returns the
|
106
|
-
|
107
|
-
subject.instance_variable_set(:@filtered, filtered)
|
108
|
-
subject.filtered?.should eq(filtered)
|
36
|
+
describe "#require_paths" do
|
37
|
+
it "returns the merged set of the require paths of each spec file" do
|
38
|
+
pending
|
109
39
|
end
|
110
40
|
end
|
111
41
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: snapdragon
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew De Ponte
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-06-
|
11
|
+
date: 2013-06-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: capybara
|
@@ -131,12 +131,14 @@ files:
|
|
131
131
|
- bin/build_jspec_filter.rb
|
132
132
|
- bin/snapdragon
|
133
133
|
- bin/snapdragon_server
|
134
|
+
- example/spec/bar_spec.js
|
134
135
|
- example/spec/hoopty_spec.js
|
135
136
|
- example/src/hoopty.js
|
136
137
|
- lib/snapdragon.rb
|
137
138
|
- lib/snapdragon/cli_application.rb
|
139
|
+
- lib/snapdragon/path.rb
|
138
140
|
- lib/snapdragon/resources/.gitkeep
|
139
|
-
- lib/snapdragon/resources/
|
141
|
+
- lib/snapdragon/resources/SnapdragonConsoleReporter.js
|
140
142
|
- lib/snapdragon/spec_directory.rb
|
141
143
|
- lib/snapdragon/spec_file.rb
|
142
144
|
- lib/snapdragon/suite.rb
|
@@ -146,6 +148,7 @@ files:
|
|
146
148
|
- lib/snapdragon/web_application.rb
|
147
149
|
- snapdragon.gemspec
|
148
150
|
- spec/lib/snapdragon/cli_application_spec.rb
|
151
|
+
- spec/lib/snapdragon/path_spec.rb
|
149
152
|
- spec/lib/snapdragon/spec_directory_spec.rb
|
150
153
|
- spec/lib/snapdragon/spec_file_spec.rb
|
151
154
|
- spec/lib/snapdragon/suite_spec.rb
|
@@ -186,6 +189,7 @@ specification_version: 4
|
|
186
189
|
summary: A command-line Jasmine JavaScript test runner.
|
187
190
|
test_files:
|
188
191
|
- spec/lib/snapdragon/cli_application_spec.rb
|
192
|
+
- spec/lib/snapdragon/path_spec.rb
|
189
193
|
- spec/lib/snapdragon/spec_directory_spec.rb
|
190
194
|
- spec/lib/snapdragon/spec_file_spec.rb
|
191
195
|
- spec/lib/snapdragon/suite_spec.rb
|
@@ -1,163 +0,0 @@
|
|
1
|
-
jasmine.ConsoleReporter = function() {
|
2
|
-
function ConsoleReporter(options) {
|
3
|
-
var print = function(msg) { console.log(msg); },
|
4
|
-
showColors = options.showColors || true,
|
5
|
-
onComplete = options.onComplete || function() {},
|
6
|
-
specCount,
|
7
|
-
failureCount,
|
8
|
-
passedCount,
|
9
|
-
failedSpecs = [],
|
10
|
-
pendingSpecs = [],
|
11
|
-
pendingCount,
|
12
|
-
startTimestamp,
|
13
|
-
endTimestamp
|
14
|
-
ansi = {
|
15
|
-
green: '\033[32m',
|
16
|
-
red: '\033[31m',
|
17
|
-
yellow: '\033[33m',
|
18
|
-
none: '\033[0m'
|
19
|
-
};
|
20
|
-
|
21
|
-
this.log = function() {
|
22
|
-
};
|
23
|
-
|
24
|
-
// "reportRunnerStarting",
|
25
|
-
this.reportRunnerStarting = function() {
|
26
|
-
startTimestamp = new Date().getTime();
|
27
|
-
specCount = 0;
|
28
|
-
failureCount = 0;
|
29
|
-
passedCount = 0;
|
30
|
-
pendingCount = 0;
|
31
|
-
print("Running examples...");
|
32
|
-
printNewline();
|
33
|
-
};
|
34
|
-
|
35
|
-
// "reportSuiteResults",
|
36
|
-
this.reportSuitResults = function() {
|
37
|
-
};
|
38
|
-
|
39
|
-
// "reportSpecStarting",
|
40
|
-
this.reportSpecStarting = function() {
|
41
|
-
};
|
42
|
-
|
43
|
-
// "reportRunnerResults",
|
44
|
-
this.reportRunnerResults = function(options) {
|
45
|
-
endTimestamp = new Date().getTime();
|
46
|
-
|
47
|
-
// I have commented out the pending section below because v1.3.1 of
|
48
|
-
// jasmine doesn't have a concept of pending. It has a concept of
|
49
|
-
// skipped when you filter tests using the spec query param.
|
50
|
-
|
51
|
-
// if (pendingCount > 0) {
|
52
|
-
// print("Pending:");
|
53
|
-
// }
|
54
|
-
|
55
|
-
// for (var i = 0; i < pendingSpecs.length; i++) {
|
56
|
-
// specPendingDetails(pendingSpecs[i]);
|
57
|
-
// }
|
58
|
-
|
59
|
-
if (failureCount > 0) {
|
60
|
-
print("Failures:");
|
61
|
-
printNewline();
|
62
|
-
}
|
63
|
-
|
64
|
-
for (var i = 0; i < failedSpecs.length; i++) {
|
65
|
-
specFailureDetails(failedSpecs[i], i + 1);
|
66
|
-
}
|
67
|
-
|
68
|
-
var specCounts = specCount + " " + plural("example", specCount) + ", " + failureCount + " " + plural("failure", failureCount);
|
69
|
-
|
70
|
-
if (pendingCount) {
|
71
|
-
specCounts += ", " + pendingCount + " skipped";
|
72
|
-
}
|
73
|
-
|
74
|
-
var seconds = (endTimestamp - startTimestamp) / 1000.0;
|
75
|
-
print("Finished in " + seconds + " " + plural("second", seconds));
|
76
|
-
|
77
|
-
if (failureCount > 0) { // have any failures
|
78
|
-
print(colored("red", specCounts));
|
79
|
-
// } else if (pendingCount > 0) {
|
80
|
-
// print(colored("yellow", specCounts));
|
81
|
-
} else {
|
82
|
-
print(colored("green", specCounts));
|
83
|
-
}
|
84
|
-
|
85
|
-
onComplete();
|
86
|
-
signalCapybaraTestsFinishedRunning();
|
87
|
-
};
|
88
|
-
|
89
|
-
// "reportSpecResults",
|
90
|
-
this.reportSpecResults = function(spec) {
|
91
|
-
var results = spec.results();
|
92
|
-
|
93
|
-
if (!results.skipped) { // not pending
|
94
|
-
specCount++;
|
95
|
-
}
|
96
|
-
|
97
|
-
if (results.skipped) { // when you filter out tests with spec query param
|
98
|
-
pendingCount++;
|
99
|
-
pendingSpecs.push(spec);
|
100
|
-
} else if (results.passed()) { // passed
|
101
|
-
passedCount++;
|
102
|
-
} else { // failed
|
103
|
-
failureCount++;
|
104
|
-
failedSpecs.push(spec);
|
105
|
-
}
|
106
|
-
};
|
107
|
-
|
108
|
-
return this;
|
109
|
-
|
110
|
-
function printNewline() {
|
111
|
-
print("");
|
112
|
-
}
|
113
|
-
|
114
|
-
function colored(color, str) {
|
115
|
-
return showColors ? (ansi[color] + str + ansi.none) : str;
|
116
|
-
}
|
117
|
-
|
118
|
-
function plural(str, count) {
|
119
|
-
return count == 1 ? str : str + "s";
|
120
|
-
}
|
121
|
-
|
122
|
-
function repeat(thing, times) {
|
123
|
-
var arr = [];
|
124
|
-
for (var i = 0; i < times; i++) {
|
125
|
-
arr.push(thing);
|
126
|
-
}
|
127
|
-
return arr;
|
128
|
-
}
|
129
|
-
|
130
|
-
function indent(str, spaces) {
|
131
|
-
var lines = (str || '').split("\n");
|
132
|
-
var newArr = [];
|
133
|
-
for (var i = 0; i < lines.length; i++) {
|
134
|
-
newArr.push(repeat(" ", spaces).join("") + lines[i]);
|
135
|
-
}
|
136
|
-
return newArr.join("\n");
|
137
|
-
}
|
138
|
-
|
139
|
-
function specFailureDetails(spec, failure_number) {
|
140
|
-
var results = spec.results();
|
141
|
-
print(indent(failure_number + ") " + spec.getFullName(), 2));
|
142
|
-
|
143
|
-
for (var i = 0; i < results.items_.length; i++) {
|
144
|
-
var failedExpectation = results.items_[i];
|
145
|
-
print(indent(colored("red", failedExpectation.message), 6));
|
146
|
-
}
|
147
|
-
printNewline();
|
148
|
-
}
|
149
|
-
|
150
|
-
function specPendingDetails(spec) {
|
151
|
-
print(indent(colored("yellow", spec.getFullName()), 2));
|
152
|
-
printNewline();
|
153
|
-
}
|
154
|
-
|
155
|
-
function signalCapybaraTestsFinishedRunning() {
|
156
|
-
var div = document.createElement('div');
|
157
|
-
div.id = 'testscomplete';
|
158
|
-
document.body.appendChild(div);
|
159
|
-
}
|
160
|
-
}
|
161
|
-
|
162
|
-
return ConsoleReporter;
|
163
|
-
};
|