jasmine-blanket 2.0.2.1 → 2.0.2.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +22 -1
- data/lib/jasmine-blanket.rb +33 -1
- data/lib/jasmine-blanket/configuration.rb +1 -1
- data/lib/jasmine-blanket/version.rb +1 -1
- data/lib/phantom_jasmine_runner.js +68 -0
- data/lib/run.html.erb +1 -1
- data/vendor/assets/javascripts/jasmine-blanket.js +70 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 33a437f12e82400b356f055a8d78f5e0b881beaf
|
4
|
+
data.tar.gz: 2714845f9062db778b9f96a2c4c15a221fe23d1c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f60bcf595fb7ded876d14d5e37c3281b16ed1479fd52094f805dfd7fa8390723f4b97a2db9e6e2898e8e19c7d1920d89d83173fb9632bd6785100d9e835d5eee
|
7
|
+
data.tar.gz: ddd5de28f71739128097d512fc70d506cd362a650f92f193d286d4083eea27c1350899ed06d5bf66d901b28b7ff6a9b66046328435a888e0819a4581c65cb661
|
data/README.md
CHANGED
@@ -41,13 +41,34 @@ In jasmine.yml
|
|
41
41
|
- '__spec__'
|
42
42
|
- '/templates/'
|
43
43
|
|
44
|
+
coverage_threshold: 90
|
45
|
+
|
44
46
|
In jasmine_helper.rb
|
45
47
|
|
46
48
|
Jasmine::Blanket.load_configuration_from_yaml
|
47
49
|
|
50
|
+
In Browser
|
51
|
+
|
52
|
+
rake jasmine
|
53
|
+
|
54
|
+
Headless or CI
|
55
|
+
|
56
|
+
rake jasmine:ci
|
57
|
+
|
58
|
+
## Acknowledgements
|
59
|
+
|
60
|
+
Jasmine adaptor is from @alex-seville's [Blanket.js]((http://blanketjs.org/))
|
61
|
+
Travis Coverage JS is also @alex-seville's [TravisCov](https://github.com/alex-seville/travis-cov)
|
62
|
+
|
48
63
|
## Version
|
49
64
|
|
50
|
-
Matches Jasmine version
|
65
|
+
Matches Jasmine version with a minor version
|
66
|
+
|
67
|
+
## TODO
|
68
|
+
|
69
|
+
* Testing
|
70
|
+
* Clean up the configuration hacks
|
71
|
+
* Find a way around monkey patching jasmine-gem
|
51
72
|
|
52
73
|
## Contributing
|
53
74
|
|
data/lib/jasmine-blanket.rb
CHANGED
@@ -29,6 +29,7 @@ module Jasmine
|
|
29
29
|
Jasmine::Blanket.configure do |config|
|
30
30
|
config.included_folders = yaml_config["included_blanket_folders"] if yaml_config["included_blanket_folders"].any?
|
31
31
|
config.excluded_folders = yaml_config["excluded_blanket_folders"] if yaml_config["excluded_blanket_folders"].any?
|
32
|
+
config.coverage_threshold = yaml_config["coverage_threshold"] if yaml_config["coverage_threshold"]
|
32
33
|
end
|
33
34
|
else
|
34
35
|
raise ConfigNotFound, "Unable to load jasmine config from #{path}"
|
@@ -44,10 +45,41 @@ module Jasmine
|
|
44
45
|
@config.excluded_folders
|
45
46
|
end
|
46
47
|
|
48
|
+
def self.coverage_threshold
|
49
|
+
@config.coverage_threshold
|
50
|
+
end
|
51
|
+
|
47
52
|
end
|
48
53
|
|
49
|
-
# Monkey
|
54
|
+
# Monkey Patches
|
55
|
+
|
56
|
+
# To use our template
|
50
57
|
def self.runner_template
|
51
58
|
File.read(File.join(File.dirname(__FILE__), "run.html.erb"))
|
52
59
|
end
|
60
|
+
|
61
|
+
# To use our jasmine runner
|
62
|
+
module Runners
|
63
|
+
class PhantomJs
|
64
|
+
def run
|
65
|
+
command = "#{phantom_js_path} '#{File.join(File.dirname(__FILE__), 'phantom_jasmine_runner.js')}' #{jasmine_server_url} #{result_batch_size}"
|
66
|
+
|
67
|
+
IO.popen(command) do |output|
|
68
|
+
output.each do |line|
|
69
|
+
if line =~ /^jasmine_result/
|
70
|
+
line = line.sub(/^jasmine_result/, '')
|
71
|
+
raw_results = JSON.parse(line, :max_nesting => false)
|
72
|
+
results = raw_results.map { |r| Result.new(r) }
|
73
|
+
formatter.format(results)
|
74
|
+
elsif line =~ /^coverage_result/
|
75
|
+
puts "\n"
|
76
|
+
puts line.sub(/^coverage_result/, '')
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
formatter.done
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
53
85
|
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
(function() {
|
2
|
+
var PhantomJasmineRunner = (function() {
|
3
|
+
|
4
|
+
function PhantomJasmineRunner(page, exit_func) {
|
5
|
+
this.page = page;
|
6
|
+
this.exit_func = exit_func != null ? exit_func : phantom.exit;
|
7
|
+
}
|
8
|
+
|
9
|
+
PhantomJasmineRunner.prototype.get_status = function() {
|
10
|
+
return this.page.evaluate(function() {
|
11
|
+
// Hack console.log
|
12
|
+
var logged_messages = [];
|
13
|
+
var oldLog = window.console.log;
|
14
|
+
window.console.log = function(message) {
|
15
|
+
logged_messages.push(message);
|
16
|
+
oldLog.apply(console, arguments);
|
17
|
+
}
|
18
|
+
|
19
|
+
var threshold = $('body').data("coverage-threshold");
|
20
|
+
|
21
|
+
logged_messages.push(window.travisCov.check(window._$blanket, { threshold: threshold }));
|
22
|
+
|
23
|
+
return logged_messages;
|
24
|
+
});
|
25
|
+
};
|
26
|
+
|
27
|
+
PhantomJasmineRunner.prototype.terminate = function() {
|
28
|
+
var messages = this.get_status();
|
29
|
+
var status = messages[messages.length-1];
|
30
|
+
|
31
|
+
for(var i = 0; i < messages.length - 1; i++) {
|
32
|
+
console.log('coverage_result' + messages[i]);
|
33
|
+
}
|
34
|
+
|
35
|
+
switch (status) {
|
36
|
+
case true:
|
37
|
+
return this.exit_func(0);
|
38
|
+
case false:
|
39
|
+
return this.exit_func(1);
|
40
|
+
default:
|
41
|
+
return this.exit_func(2);
|
42
|
+
}
|
43
|
+
};
|
44
|
+
|
45
|
+
return PhantomJasmineRunner;
|
46
|
+
|
47
|
+
})();
|
48
|
+
|
49
|
+
var url = phantom.args[0];
|
50
|
+
var page = require('webpage').create();
|
51
|
+
var runner = new PhantomJasmineRunner(page);
|
52
|
+
|
53
|
+
page.onCallback = function(data) {
|
54
|
+
if(data.state === 'specDone') {
|
55
|
+
console.log('jasmine_result' + JSON.stringify([].concat(data.results)));
|
56
|
+
} else {
|
57
|
+
runner.terminate();
|
58
|
+
}
|
59
|
+
};
|
60
|
+
|
61
|
+
page.open(url, function(status) {
|
62
|
+
if (status !== "success") {
|
63
|
+
runner.terminate();
|
64
|
+
}
|
65
|
+
});
|
66
|
+
}).call(this);
|
67
|
+
|
68
|
+
|
data/lib/run.html.erb
CHANGED
@@ -82,4 +82,74 @@
|
|
82
82
|
jasmine.getEnv().execute();
|
83
83
|
}
|
84
84
|
});
|
85
|
+
})();
|
86
|
+
|
87
|
+
// https://github.com/alex-seville/travis-cov
|
88
|
+
(typeof exports !== "undefined" ? exports : window).travisCov = (function(){
|
89
|
+
var main = {
|
90
|
+
check: function(cov,userOptions){
|
91
|
+
if (!cov){
|
92
|
+
return false;
|
93
|
+
}
|
94
|
+
|
95
|
+
var options = {
|
96
|
+
threshold: 50 //defaults to 50%
|
97
|
+
};
|
98
|
+
|
99
|
+
if (userOptions){
|
100
|
+
options.threshold = userOptions.threshold || options.threshold;
|
101
|
+
}
|
102
|
+
|
103
|
+
var totals =[];
|
104
|
+
for (var filename in cov) {
|
105
|
+
var data = cov[filename];
|
106
|
+
totals.push(this.reportFile( data,options));
|
107
|
+
}
|
108
|
+
|
109
|
+
var totalHits = 0;
|
110
|
+
var totalSloc = 0;
|
111
|
+
totals.forEach(function(elem){
|
112
|
+
totalHits += elem[0];
|
113
|
+
totalSloc += elem[1];
|
114
|
+
});
|
115
|
+
|
116
|
+
var globCoverage = (totalHits === 0 || totalSloc === 0) ?
|
117
|
+
0 : totalHits / totalSloc * 100;
|
118
|
+
console.log("Coverage: "+Math.floor(globCoverage)+"%");
|
119
|
+
if (globCoverage < options.threshold || isNaN(globCoverage)){
|
120
|
+
console.log("Code coverage below threshold: "+Math.floor(globCoverage)+ " < "+options.threshold);
|
121
|
+
if (typeof process !== "undefined"){
|
122
|
+
process.exit(1);
|
123
|
+
}
|
124
|
+
return false;
|
125
|
+
|
126
|
+
}else{
|
127
|
+
console.log("Coverage succeeded.");
|
128
|
+
}
|
129
|
+
return true;
|
130
|
+
},
|
131
|
+
reportFile: function( data,options) {
|
132
|
+
var ret = {
|
133
|
+
coverage: 0,
|
134
|
+
hits: 0,
|
135
|
+
misses: 0,
|
136
|
+
sloc: 0
|
137
|
+
};
|
138
|
+
data.source.forEach(function(line, num){
|
139
|
+
num++;
|
140
|
+
if (data[num] === 0) {
|
141
|
+
ret.misses++;
|
142
|
+
ret.sloc++;
|
143
|
+
} else if (data[num] !== undefined) {
|
144
|
+
ret.hits++;
|
145
|
+
ret.sloc++;
|
146
|
+
}
|
147
|
+
});
|
148
|
+
ret.coverage = ret.hits / ret.sloc * 100;
|
149
|
+
|
150
|
+
return [ret.hits,ret.sloc];
|
151
|
+
|
152
|
+
}
|
153
|
+
};
|
154
|
+
return main;
|
85
155
|
})();
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jasmine-blanket
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.2.
|
4
|
+
version: 2.0.2.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Scott Carleton
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-08-
|
11
|
+
date: 2014-08-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -69,6 +69,7 @@ files:
|
|
69
69
|
- lib/jasmine-blanket/configuration.rb
|
70
70
|
- lib/jasmine-blanket/engine.rb
|
71
71
|
- lib/jasmine-blanket/version.rb
|
72
|
+
- lib/phantom_jasmine_runner.js
|
72
73
|
- lib/run.html.erb
|
73
74
|
- vendor/assets/javascripts/jasmine-blanket.js
|
74
75
|
homepage: https://github.com/ScotterC/jasmine-blanket
|