jasmine-junitreporter 0.0.1
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.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +61 -0
- data/Rakefile +8 -0
- data/jasmine-junitreporter.gemspec +20 -0
- data/lib/jasmine/junitreporter.rb +8 -0
- data/lib/jasmine/junitreporter/version.rb +5 -0
- data/vendor/assets/javascripts/JUnitReporter.js +147 -0
- metadata +81 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 0cc398f9f434708c38b5bc054dfe5b07dfa3614e
|
4
|
+
data.tar.gz: 490cfa90bd8c4a2963472a3c95ec88d901dea2cd
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: bcff2ef90679936cb0633afa27f1c51333b83bbc1803221a2d4a016144e80777728f5756c04c6c5258bbd2d1c4fcdb9ed783dfa1b49b24a82b1e6199d46c92f5
|
7
|
+
data.tar.gz: 0e0a6110fb5eb898e02db27e3b9be00e32be02884d7b63bfe3a175c9444cb8f802b2528427a31ce7af227efbc5891400e2662c0103767f4322d590549900e755
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Jake Goulding
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
# Jasmine::JUnitReporter
|
2
|
+
|
3
|
+
Wraps [jasmine-junitreporter][jju] in a gem, suitable for use with [jasmine-rails][jr].
|
4
|
+
|
5
|
+
[jju]: https://github.com/shepmaster/jasmine-junitreporter
|
6
|
+
[jr]: https://github.com/searls/jasmine-rails
|
7
|
+
|
8
|
+
## Installation
|
9
|
+
|
10
|
+
Add this line to your application's Gemfile:
|
11
|
+
|
12
|
+
gem 'jasmine-junitreporter'
|
13
|
+
|
14
|
+
And then execute:
|
15
|
+
|
16
|
+
$ bundle
|
17
|
+
|
18
|
+
Or install it yourself as:
|
19
|
+
|
20
|
+
$ gem install jasmine-junitreporter
|
21
|
+
|
22
|
+
## Usage
|
23
|
+
|
24
|
+
Add this to your `jasmine.yml`:
|
25
|
+
|
26
|
+
```yaml
|
27
|
+
reporters:
|
28
|
+
junit:
|
29
|
+
- "JUnitReporter.js"
|
30
|
+
- "JUnitReporter.boot.js"
|
31
|
+
```
|
32
|
+
|
33
|
+
`JUnitReporter.js` is provided by this gem. `JUnitReporter.boot.js` is
|
34
|
+
the glue code you need to provide to configure and enable the
|
35
|
+
reporter. Create the file with content like:
|
36
|
+
|
37
|
+
```js
|
38
|
+
(function() {
|
39
|
+
var reporter = new jasmine.JUnitReporter({
|
40
|
+
outputDir: 'output/dir'
|
41
|
+
});
|
42
|
+
jasmine.getEnv().addReporter(reporter);
|
43
|
+
})();
|
44
|
+
```
|
45
|
+
|
46
|
+
Alternatively, you can create `JUnitReporter.boot.js.erb`, allowing
|
47
|
+
for configuration via any Ruby code, including environment variables.
|
48
|
+
|
49
|
+
You can then run the tests as:
|
50
|
+
|
51
|
+
```
|
52
|
+
$ RAILS_ENV=test REPORTERS='console,junit' rake spec:javascripts
|
53
|
+
```
|
54
|
+
|
55
|
+
## Contributing
|
56
|
+
|
57
|
+
1. Fork it ( http://github.com/shepmaster/jasmine-junitreporter-gem/fork )
|
58
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
59
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
60
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
61
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
|
3
|
+
desc "Update from the given tag"
|
4
|
+
task :update_from_library, [:tag] do |t, args|
|
5
|
+
tag = args[:tag]
|
6
|
+
sh "wget https://github.com/shepmaster/jasmine-junitreporter/raw/#{tag}/JUnitReporter.js"
|
7
|
+
mv 'JUnitReporter.js', 'vendor/assets/javascripts/JUnitReporter.js'
|
8
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'jasmine/junitreporter/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "jasmine-junitreporter"
|
8
|
+
spec.version = Jasmine::JUnitReporter::VERSION
|
9
|
+
spec.authors = ["Jake Goulding"]
|
10
|
+
spec.email = ["jake.goulding@gmail.com"]
|
11
|
+
spec.summary = %q{Provides a JUnit reporter suitable for use with jasmine-rails}
|
12
|
+
spec.homepage = "http://github.com/shepmaster/jasmine-junitreporter-gem"
|
13
|
+
spec.license = "MIT"
|
14
|
+
|
15
|
+
spec.files = `git ls-files -z`.split("\x0")
|
16
|
+
spec.require_paths = ["lib"]
|
17
|
+
|
18
|
+
spec.add_development_dependency "bundler", "~> 1.5"
|
19
|
+
spec.add_development_dependency "rake"
|
20
|
+
end
|
@@ -0,0 +1,147 @@
|
|
1
|
+
jasmine.JUnitReporter = function JUnitReporter(options) {
|
2
|
+
var options = options || {},
|
3
|
+
outputDir = options.outputDir || '/tmp',
|
4
|
+
traceEnabled = options.traceEnabled || false,
|
5
|
+
currentSuites = [],
|
6
|
+
currentSpec;
|
7
|
+
|
8
|
+
this.jasmineStarted = function(things) {
|
9
|
+
trace("JASMINE STARTED");
|
10
|
+
};
|
11
|
+
|
12
|
+
this.jasmineDone = function(things) {
|
13
|
+
trace("JASMINE DONE");
|
14
|
+
console.log("JUnitReporter finished (files written to " + outputDir + ")");
|
15
|
+
};
|
16
|
+
|
17
|
+
this.suiteStarted = function(result) {
|
18
|
+
trace("SUITE STARTED");
|
19
|
+
|
20
|
+
currentSuites.push({
|
21
|
+
id: result.id,
|
22
|
+
name: result.fullName,
|
23
|
+
tests: 0,
|
24
|
+
startTime: t(),
|
25
|
+
time: 0.0,
|
26
|
+
failed: 0,
|
27
|
+
errored: 0,
|
28
|
+
skipped: 0,
|
29
|
+
specs: []
|
30
|
+
});
|
31
|
+
}
|
32
|
+
|
33
|
+
this.suiteDone = function(result) {
|
34
|
+
var suite = currentSuites.pop();
|
35
|
+
|
36
|
+
trace("SUITE DONE");
|
37
|
+
|
38
|
+
suite.endTime = t();
|
39
|
+
suite.time = suite.endTime - suite.startTime;
|
40
|
+
|
41
|
+
saveXML(result.id, suite.name, suiteToXML(suite));
|
42
|
+
};
|
43
|
+
|
44
|
+
this.specStarted = function(result) {
|
45
|
+
trace("SPEC STARTED");
|
46
|
+
|
47
|
+
currentSpec = {
|
48
|
+
name: result.fullName,
|
49
|
+
time: 0.0,
|
50
|
+
startTime: t(),
|
51
|
+
failures: []
|
52
|
+
}
|
53
|
+
};
|
54
|
+
|
55
|
+
this.specDone = function(result) {
|
56
|
+
var suite = currentSuite();
|
57
|
+
var spec = currentSpec;
|
58
|
+
currentSpec = undefined;
|
59
|
+
|
60
|
+
trace("SPEC DONE");
|
61
|
+
|
62
|
+
spec.endTime = t();
|
63
|
+
spec.time = spec.endTime - spec.startTime;
|
64
|
+
|
65
|
+
suite.tests++;
|
66
|
+
if (result.status === 'pending') {
|
67
|
+
suite.skipped++;
|
68
|
+
} else if (result.status === 'failed') {
|
69
|
+
suite.failed++;
|
70
|
+
}
|
71
|
+
|
72
|
+
result.failedExpectations.forEach(function(expectation) {
|
73
|
+
spec.failures.push({
|
74
|
+
message: expectation.message,
|
75
|
+
stack: expectation.stack
|
76
|
+
});
|
77
|
+
});
|
78
|
+
|
79
|
+
suite.specs.push(spec);
|
80
|
+
};
|
81
|
+
|
82
|
+
return this;
|
83
|
+
|
84
|
+
function currentSuite() {
|
85
|
+
return currentSuites[currentSuites.length - 1];
|
86
|
+
}
|
87
|
+
|
88
|
+
function specToXML(spec) {
|
89
|
+
var xml = document.createElement('testcase');
|
90
|
+
|
91
|
+
xml.setAttribute("name", spec.name);
|
92
|
+
xml.setAttribute("time", spec.time / 1000);
|
93
|
+
|
94
|
+
spec.failures.forEach(function(failure) {
|
95
|
+
var failXml = document.createElement('failure');
|
96
|
+
|
97
|
+
failXml.setAttribute("message", failure.message);
|
98
|
+
failXml.textContent = failure.stack;
|
99
|
+
|
100
|
+
xml.appendChild(failXml);
|
101
|
+
});
|
102
|
+
|
103
|
+
return xml;
|
104
|
+
}
|
105
|
+
|
106
|
+
function suiteToXML(suite) {
|
107
|
+
var xml = document.createElement('testsuite');
|
108
|
+
|
109
|
+
xml.setAttribute("name", suite.name);
|
110
|
+
xml.setAttribute("tests", suite.tests);
|
111
|
+
xml.setAttribute("time", suite.time / 1000);
|
112
|
+
xml.setAttribute("failures", suite.failed);
|
113
|
+
xml.setAttribute("errors", suite.errored);
|
114
|
+
xml.setAttribute("skipped", suite.skipped);
|
115
|
+
|
116
|
+
suite.specs.forEach(function(spec) {
|
117
|
+
xml.appendChild(specToXML(spec));
|
118
|
+
});
|
119
|
+
|
120
|
+
return xml;
|
121
|
+
}
|
122
|
+
|
123
|
+
function filename(suiteId, suiteName) {
|
124
|
+
return "SPEC-" + suiteId + "-" + suiteName.replace(/\W/g, '_') + ".xml";
|
125
|
+
}
|
126
|
+
|
127
|
+
function saveXML(suiteId, suiteName, node) {
|
128
|
+
var outputFilename = outputDir + "/" + filename(suiteId, suiteName);
|
129
|
+
|
130
|
+
trace("Saving XML:", node.outerHTML);
|
131
|
+
|
132
|
+
window.callPhantom({event: 'writeFile',
|
133
|
+
filename: outputFilename,
|
134
|
+
text: node.outerHTML});
|
135
|
+
}
|
136
|
+
|
137
|
+
function trace() {
|
138
|
+
if (traceEnabled) {
|
139
|
+
console.log.apply(console, arguments);
|
140
|
+
}
|
141
|
+
}
|
142
|
+
|
143
|
+
// Current milliseconds since the epoch
|
144
|
+
function t() {
|
145
|
+
return new Date().getTime();
|
146
|
+
}
|
147
|
+
}
|
metadata
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: jasmine-junitreporter
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jake Goulding
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-05-13 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.5'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.5'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description:
|
42
|
+
email:
|
43
|
+
- jake.goulding@gmail.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- ".gitignore"
|
49
|
+
- Gemfile
|
50
|
+
- LICENSE.txt
|
51
|
+
- README.md
|
52
|
+
- Rakefile
|
53
|
+
- jasmine-junitreporter.gemspec
|
54
|
+
- lib/jasmine/junitreporter.rb
|
55
|
+
- lib/jasmine/junitreporter/version.rb
|
56
|
+
- vendor/assets/javascripts/JUnitReporter.js
|
57
|
+
homepage: http://github.com/shepmaster/jasmine-junitreporter-gem
|
58
|
+
licenses:
|
59
|
+
- MIT
|
60
|
+
metadata: {}
|
61
|
+
post_install_message:
|
62
|
+
rdoc_options: []
|
63
|
+
require_paths:
|
64
|
+
- lib
|
65
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
75
|
+
requirements: []
|
76
|
+
rubyforge_project:
|
77
|
+
rubygems_version: 2.2.2
|
78
|
+
signing_key:
|
79
|
+
specification_version: 4
|
80
|
+
summary: Provides a JUnit reporter suitable for use with jasmine-rails
|
81
|
+
test_files: []
|