edgecase-jasmine 1.0.1.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.
- data/README.markdown +45 -0
- data/bin/jasmine +6 -0
- data/generators/jasmine/jasmine_generator.rb +30 -0
- data/generators/jasmine/templates/INSTALL +9 -0
- data/generators/jasmine/templates/jasmine-example/SpecRunner.html +27 -0
- data/generators/jasmine/templates/jasmine-example/spec/PlayerSpec.js +58 -0
- data/generators/jasmine/templates/jasmine-example/spec/SpecHelper.js +9 -0
- data/generators/jasmine/templates/jasmine-example/src/Player.js +22 -0
- data/generators/jasmine/templates/jasmine-example/src/Song.js +7 -0
- data/generators/jasmine/templates/lib/tasks/jasmine.rake +2 -0
- data/generators/jasmine/templates/spec/javascripts/support/jasmine-rails.yml +81 -0
- data/generators/jasmine/templates/spec/javascripts/support/jasmine.yml +73 -0
- data/generators/jasmine/templates/spec/javascripts/support/jasmine_runner.rb +21 -0
- data/jasmine/example/SpecRunner.html +27 -0
- data/jasmine/lib/jasmine-html.js +188 -0
- data/jasmine/lib/jasmine.css +166 -0
- data/jasmine/lib/jasmine.js +2421 -0
- data/jasmine/lib/json2.js +478 -0
- data/lib/jasmine.rb +8 -0
- data/lib/jasmine/base.rb +59 -0
- data/lib/jasmine/command_line_tool.rb +68 -0
- data/lib/jasmine/config.rb +186 -0
- data/lib/jasmine/run.html.erb +43 -0
- data/lib/jasmine/selenium_driver.rb +44 -0
- data/lib/jasmine/server.rb +120 -0
- data/lib/jasmine/spec_builder.rb +152 -0
- data/lib/jasmine/tasks/jasmine.rake +31 -0
- data/spec/config_spec.rb +259 -0
- data/spec/jasmine_command_line_tool_spec.rb +26 -0
- data/spec/jasmine_self_test_config.rb +15 -0
- data/spec/jasmine_self_test_spec.rb +18 -0
- data/spec/rails_generator_spec.rb +27 -0
- data/spec/server_spec.rb +82 -0
- data/spec/spec_helper.rb +40 -0
- metadata +204 -0
data/README.markdown
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
jasmine-gem
|
2
|
+
============
|
3
|
+
|
4
|
+
Jasmine Gem dynamically serves and runs suites for [Jasmine](http://github.com/pivotal/jasmine).
|
5
|
+
|
6
|
+
To use:
|
7
|
+
|
8
|
+
`gem install jasmine`
|
9
|
+
|
10
|
+
You also need a JSON parser - `json`, `json_pure`, `yajl-ruby` or `ActiveSupport::JSON` (any of them will do).
|
11
|
+
|
12
|
+
Post-installation:
|
13
|
+
|
14
|
+
For Rails2 support, use
|
15
|
+
|
16
|
+
`script/generate jasmine`
|
17
|
+
|
18
|
+
For Rails3 support, use
|
19
|
+
|
20
|
+
`bundle exec jasmine init`
|
21
|
+
|
22
|
+
For other Ruby projects (including Merb), use
|
23
|
+
|
24
|
+
`jasmine init`
|
25
|
+
|
26
|
+
After initializing a project, you may
|
27
|
+
|
28
|
+
`rake jasmine`
|
29
|
+
|
30
|
+
to set up a server. Opening localhost:8888 in a web browser will now run your jasmine specs.
|
31
|
+
|
32
|
+
You may also
|
33
|
+
|
34
|
+
`rake jasmine:ci`
|
35
|
+
|
36
|
+
which will run your Jasmine suites using selenium and rspec. This task is suitable for running in continuous integration environments. There is currently a known issue using this rake task with RSpec2 beta.
|
37
|
+
|
38
|
+
Simple Configuration:
|
39
|
+
|
40
|
+
Customize `spec/javascripts/support/jasmine.yml` to enumerate the source files, stylesheets, and spec files you would like the Jasmine runner to include.
|
41
|
+
You may use dir glob strings.
|
42
|
+
|
43
|
+
It is also possible to add overrides into the `spec/javascripts/support/jasmine_config.rb` file directly if you require further customization.
|
44
|
+
|
45
|
+
Copyright (c) 2008-2010 Pivotal Labs. This software is licensed under the MIT License.
|
data/bin/jasmine
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
class JasmineGenerator < Rails::Generator::Base
|
2
|
+
def manifest
|
3
|
+
record do |m|
|
4
|
+
|
5
|
+
m.directory "public/javascripts"
|
6
|
+
m.file "jasmine-example/src/Player.js", "public/javascripts/Player.js"
|
7
|
+
m.file "jasmine-example/src/Song.js", "public/javascripts/Song.js"
|
8
|
+
|
9
|
+
m.directory "spec/javascripts"
|
10
|
+
m.file "jasmine-example/spec/PlayerSpec.js", "spec/javascripts/PlayerSpec.js"
|
11
|
+
|
12
|
+
m.directory "spec/javascripts/helpers"
|
13
|
+
m.file "jasmine-example/spec/SpecHelper.js", "spec/javascripts/helpers/SpecHelper.js"
|
14
|
+
|
15
|
+
m.directory "spec/javascripts/support"
|
16
|
+
m.file "spec/javascripts/support/jasmine_runner.rb", "spec/javascripts/support/jasmine_runner.rb"
|
17
|
+
m.file "spec/javascripts/support/jasmine-rails.yml", "spec/javascripts/support/jasmine.yml"
|
18
|
+
|
19
|
+
m.directory "lib/tasks"
|
20
|
+
m.file "lib/tasks/jasmine.rake", "lib/tasks/jasmine.rake"
|
21
|
+
|
22
|
+
m.readme "INSTALL"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def file_name
|
27
|
+
"create_blog"
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
2
|
+
"http://www.w3.org/TR/html4/loose.dtd">
|
3
|
+
<html>
|
4
|
+
<head>
|
5
|
+
<title>Jasmine Test Runner</title>
|
6
|
+
<link rel="stylesheet" type="text/css" href="lib/jasmine-##JASMINE_VERSION##/jasmine.css">
|
7
|
+
<script type="text/javascript" src="lib/jasmine-##JASMINE_VERSION##/jasmine.js"></script>
|
8
|
+
<script type="text/javascript" src="lib/jasmine-##JASMINE_VERSION##/jasmine-html.js"></script>
|
9
|
+
|
10
|
+
<!-- include source files here... -->
|
11
|
+
<script type="text/javascript" src="src/Player.js"></script>
|
12
|
+
<script type="text/javascript" src="src/Song.js"></script>
|
13
|
+
|
14
|
+
<!-- include spec files here... -->
|
15
|
+
<script type="text/javascript" src="spec/SpecHelper.js"></script>
|
16
|
+
<script type="text/javascript" src="spec/PlayerSpec.js"></script>
|
17
|
+
|
18
|
+
</head>
|
19
|
+
<body>
|
20
|
+
<div id="REMOVE_THIS_LINE_FROM_BUILD"><p>You must be trying to look at examples in the Jasmine source tree.</p><p>Please download a distribution version of Jasmine at <a href="http://pivotal.github.com/jasmine/">http://pivotal.github.com/jasmine/</a>.</p></div>
|
21
|
+
<script type="text/javascript">
|
22
|
+
jasmine.getEnv().addReporter(new jasmine.TrivialReporter());
|
23
|
+
jasmine.getEnv().execute();
|
24
|
+
</script>
|
25
|
+
|
26
|
+
</body>
|
27
|
+
</html>
|
@@ -0,0 +1,58 @@
|
|
1
|
+
describe("Player", function() {
|
2
|
+
var player;
|
3
|
+
var song;
|
4
|
+
|
5
|
+
beforeEach(function() {
|
6
|
+
player = new Player();
|
7
|
+
song = new Song();
|
8
|
+
});
|
9
|
+
|
10
|
+
it("should be able to play a Song", function() {
|
11
|
+
player.play(song);
|
12
|
+
expect(player.currentlyPlayingSong).toEqual(song);
|
13
|
+
|
14
|
+
//demonstrates use of custom matcher
|
15
|
+
expect(player).toBePlaying(song);
|
16
|
+
});
|
17
|
+
|
18
|
+
describe("when song has been paused", function() {
|
19
|
+
beforeEach(function() {
|
20
|
+
player.play(song);
|
21
|
+
player.pause();
|
22
|
+
});
|
23
|
+
|
24
|
+
it("should indicate that the song is currently paused", function() {
|
25
|
+
expect(player.isPlaying).toBeFalsy();
|
26
|
+
|
27
|
+
// demonstrates use of 'not' with a custom matcher
|
28
|
+
expect(player).not.toBePlaying(song);
|
29
|
+
});
|
30
|
+
|
31
|
+
it("should be possible to resume", function() {
|
32
|
+
player.resume();
|
33
|
+
expect(player.isPlaying).toBeTruthy();
|
34
|
+
expect(player.currentlyPlayingSong).toEqual(song);
|
35
|
+
});
|
36
|
+
});
|
37
|
+
|
38
|
+
// demonstrates use of spies to intercept and test method calls
|
39
|
+
it("tells the current song if the user has made it a favorite", function() {
|
40
|
+
spyOn(song, 'persistFavoriteStatus');
|
41
|
+
|
42
|
+
player.play(song);
|
43
|
+
player.makeFavorite();
|
44
|
+
|
45
|
+
expect(song.persistFavoriteStatus).toHaveBeenCalledWith(true);
|
46
|
+
});
|
47
|
+
|
48
|
+
//demonstrates use of expected exceptions
|
49
|
+
describe("#resume", function() {
|
50
|
+
it("should throw an exception if song is already playing", function() {
|
51
|
+
player.play(song);
|
52
|
+
|
53
|
+
expect(function() {
|
54
|
+
player.resume();
|
55
|
+
}).toThrow("song is already playing");
|
56
|
+
});
|
57
|
+
});
|
58
|
+
});
|
@@ -0,0 +1,22 @@
|
|
1
|
+
function Player() {
|
2
|
+
}
|
3
|
+
Player.prototype.play = function(song) {
|
4
|
+
this.currentlyPlayingSong = song;
|
5
|
+
this.isPlaying = true;
|
6
|
+
};
|
7
|
+
|
8
|
+
Player.prototype.pause = function() {
|
9
|
+
this.isPlaying = false;
|
10
|
+
};
|
11
|
+
|
12
|
+
Player.prototype.resume = function() {
|
13
|
+
if (this.isPlaying) {
|
14
|
+
throw new Error("song is already playing");
|
15
|
+
}
|
16
|
+
|
17
|
+
this.isPlaying = true;
|
18
|
+
};
|
19
|
+
|
20
|
+
Player.prototype.makeFavorite = function() {
|
21
|
+
this.currentlyPlayingSong.persistFavoriteStatus(true);
|
22
|
+
};
|
@@ -0,0 +1,81 @@
|
|
1
|
+
# src_files
|
2
|
+
#
|
3
|
+
# Return an array of filepaths relative to src_dir to include before jasmine specs.
|
4
|
+
# Default: []
|
5
|
+
#
|
6
|
+
# EXAMPLE:
|
7
|
+
#
|
8
|
+
# src_files:
|
9
|
+
# - lib/source1.js
|
10
|
+
# - lib/source2.js
|
11
|
+
# - dist/**/*.js
|
12
|
+
#
|
13
|
+
src_files:
|
14
|
+
- public/javascripts/prototype.js
|
15
|
+
- public/javascripts/effects.js
|
16
|
+
- public/javascripts/controls.js
|
17
|
+
- public/javascripts/dragdrop.js
|
18
|
+
- public/javascripts/application.js
|
19
|
+
- public/javascripts/**/*.js
|
20
|
+
|
21
|
+
# stylesheets
|
22
|
+
#
|
23
|
+
# Return an array of stylesheet filepaths relative to src_dir to include before jasmine specs.
|
24
|
+
# Default: []
|
25
|
+
#
|
26
|
+
# EXAMPLE:
|
27
|
+
#
|
28
|
+
# stylesheets:
|
29
|
+
# - css/style.css
|
30
|
+
# - stylesheets/*.css
|
31
|
+
#
|
32
|
+
stylesheets:
|
33
|
+
- stylesheets/**/*.css
|
34
|
+
|
35
|
+
# helpers
|
36
|
+
#
|
37
|
+
# Return an array of filepaths relative to spec_dir to include before jasmine specs.
|
38
|
+
# Default: ["helpers/**/*.js"]
|
39
|
+
#
|
40
|
+
# EXAMPLE:
|
41
|
+
#
|
42
|
+
# helpers:
|
43
|
+
# - helpers/**/*.js
|
44
|
+
#
|
45
|
+
helpers:
|
46
|
+
- helpers/**/*.js
|
47
|
+
|
48
|
+
# spec_files
|
49
|
+
#
|
50
|
+
# Return an array of filepaths relative to spec_dir to include.
|
51
|
+
# Default: ["**/*[sS]pec.js"]
|
52
|
+
#
|
53
|
+
# EXAMPLE:
|
54
|
+
#
|
55
|
+
# spec_files:
|
56
|
+
# - **/*[sS]pec.js
|
57
|
+
#
|
58
|
+
spec_files:
|
59
|
+
- **/*[sS]pec.js
|
60
|
+
|
61
|
+
# src_dir
|
62
|
+
#
|
63
|
+
# Source directory path. Your src_files must be returned relative to this path. Will use root if left blank.
|
64
|
+
# Default: project root
|
65
|
+
#
|
66
|
+
# EXAMPLE:
|
67
|
+
#
|
68
|
+
# src_dir: public
|
69
|
+
#
|
70
|
+
src_dir:
|
71
|
+
|
72
|
+
# spec_dir
|
73
|
+
#
|
74
|
+
# Spec directory path. Your spec_files must be returned relative to this path.
|
75
|
+
# Default: spec/javascripts
|
76
|
+
#
|
77
|
+
# EXAMPLE:
|
78
|
+
#
|
79
|
+
# spec_dir: spec/javascripts
|
80
|
+
#
|
81
|
+
spec_dir: spec/javascripts
|
@@ -0,0 +1,73 @@
|
|
1
|
+
# src_files
|
2
|
+
#
|
3
|
+
# Return an array of filepaths relative to src_dir to include before jasmine specs.
|
4
|
+
# Default: []
|
5
|
+
#
|
6
|
+
# EXAMPLE:
|
7
|
+
#
|
8
|
+
# src_files:
|
9
|
+
# - lib/source1.js
|
10
|
+
# - lib/source2.js
|
11
|
+
# - dist/**/*.js
|
12
|
+
#
|
13
|
+
src_files:
|
14
|
+
- public/javascripts/**/*.js
|
15
|
+
|
16
|
+
# stylesheets
|
17
|
+
#
|
18
|
+
# Return an array of stylesheet filepaths relative to src_dir to include before jasmine specs.
|
19
|
+
# Default: []
|
20
|
+
#
|
21
|
+
# EXAMPLE:
|
22
|
+
#
|
23
|
+
# stylesheets:
|
24
|
+
# - css/style.css
|
25
|
+
# - stylesheets/*.css
|
26
|
+
#
|
27
|
+
stylesheets:
|
28
|
+
|
29
|
+
# helpers
|
30
|
+
#
|
31
|
+
# Return an array of filepaths relative to spec_dir to include before jasmine specs.
|
32
|
+
# Default: ["helpers/**/*.js"]
|
33
|
+
#
|
34
|
+
# EXAMPLE:
|
35
|
+
#
|
36
|
+
# helpers:
|
37
|
+
# - helpers/**/*.js
|
38
|
+
#
|
39
|
+
helpers:
|
40
|
+
|
41
|
+
# spec_files
|
42
|
+
#
|
43
|
+
# Return an array of filepaths relative to spec_dir to include.
|
44
|
+
# Default: ["**/*[sS]pec.js"]
|
45
|
+
#
|
46
|
+
# EXAMPLE:
|
47
|
+
#
|
48
|
+
# spec_files:
|
49
|
+
# - **/*[sS]pec.js
|
50
|
+
#
|
51
|
+
spec_files:
|
52
|
+
|
53
|
+
# src_dir
|
54
|
+
#
|
55
|
+
# Source directory path. Your src_files must be returned relative to this path. Will use root if left blank.
|
56
|
+
# Default: project root
|
57
|
+
#
|
58
|
+
# EXAMPLE:
|
59
|
+
#
|
60
|
+
# src_dir: public
|
61
|
+
#
|
62
|
+
src_dir:
|
63
|
+
|
64
|
+
# spec_dir
|
65
|
+
#
|
66
|
+
# Spec directory path. Your spec_files must be returned relative to this path.
|
67
|
+
# Default: spec/javascripts
|
68
|
+
#
|
69
|
+
# EXAMPLE:
|
70
|
+
#
|
71
|
+
# spec_dir: spec/javascripts
|
72
|
+
#
|
73
|
+
spec_dir:
|
@@ -0,0 +1,21 @@
|
|
1
|
+
$:.unshift(ENV['JASMINE_GEM_PATH']) if ENV['JASMINE_GEM_PATH'] # for gem testing purposes
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'jasmine'
|
5
|
+
jasmine_config_overrides = File.expand_path(File.join(File.dirname(__FILE__), 'jasmine_config.rb'))
|
6
|
+
require jasmine_config_overrides if File.exists?(jasmine_config_overrides)
|
7
|
+
|
8
|
+
jasmine_config = Jasmine::Config.new
|
9
|
+
spec_builder = Jasmine::SpecBuilder.new(jasmine_config)
|
10
|
+
|
11
|
+
should_stop = false
|
12
|
+
|
13
|
+
Spec::Runner.configure do |config|
|
14
|
+
config.after(:suite) do
|
15
|
+
spec_builder.stop if should_stop
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
spec_builder.start
|
20
|
+
should_stop = true
|
21
|
+
spec_builder.declare_suites
|
@@ -0,0 +1,27 @@
|
|
1
|
+
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
2
|
+
"http://www.w3.org/TR/html4/loose.dtd">
|
3
|
+
<html>
|
4
|
+
<head>
|
5
|
+
<title>Jasmine Test Runner</title>
|
6
|
+
<link rel="stylesheet" type="text/css" href="lib/jasmine-##JASMINE_VERSION##/jasmine.css">
|
7
|
+
<script type="text/javascript" src="lib/jasmine-##JASMINE_VERSION##/jasmine.js"></script>
|
8
|
+
<script type="text/javascript" src="lib/jasmine-##JASMINE_VERSION##/jasmine-html.js"></script>
|
9
|
+
|
10
|
+
<!-- include source files here... -->
|
11
|
+
<script type="text/javascript" src="src/Player.js"></script>
|
12
|
+
<script type="text/javascript" src="src/Song.js"></script>
|
13
|
+
|
14
|
+
<!-- include spec files here... -->
|
15
|
+
<script type="text/javascript" src="spec/SpecHelper.js"></script>
|
16
|
+
<script type="text/javascript" src="spec/PlayerSpec.js"></script>
|
17
|
+
|
18
|
+
</head>
|
19
|
+
<body>
|
20
|
+
<div id="REMOVE_THIS_LINE_FROM_BUILD"><p>You must be trying to look at examples in the Jasmine source tree.</p><p>Please download a distribution version of Jasmine at <a href="http://pivotal.github.com/jasmine/">http://pivotal.github.com/jasmine/</a>.</p></div>
|
21
|
+
<script type="text/javascript">
|
22
|
+
jasmine.getEnv().addReporter(new jasmine.TrivialReporter());
|
23
|
+
jasmine.getEnv().execute();
|
24
|
+
</script>
|
25
|
+
|
26
|
+
</body>
|
27
|
+
</html>
|
@@ -0,0 +1,188 @@
|
|
1
|
+
jasmine.TrivialReporter = function(doc) {
|
2
|
+
this.document = doc || document;
|
3
|
+
this.suiteDivs = {};
|
4
|
+
this.logRunningSpecs = false;
|
5
|
+
};
|
6
|
+
|
7
|
+
jasmine.TrivialReporter.prototype.createDom = function(type, attrs, childrenVarArgs) {
|
8
|
+
var el = document.createElement(type);
|
9
|
+
|
10
|
+
for (var i = 2; i < arguments.length; i++) {
|
11
|
+
var child = arguments[i];
|
12
|
+
|
13
|
+
if (typeof child === 'string') {
|
14
|
+
el.appendChild(document.createTextNode(child));
|
15
|
+
} else {
|
16
|
+
if (child) { el.appendChild(child); }
|
17
|
+
}
|
18
|
+
}
|
19
|
+
|
20
|
+
for (var attr in attrs) {
|
21
|
+
if (attr == "className") {
|
22
|
+
el[attr] = attrs[attr];
|
23
|
+
} else {
|
24
|
+
el.setAttribute(attr, attrs[attr]);
|
25
|
+
}
|
26
|
+
}
|
27
|
+
|
28
|
+
return el;
|
29
|
+
};
|
30
|
+
|
31
|
+
jasmine.TrivialReporter.prototype.reportRunnerStarting = function(runner) {
|
32
|
+
var showPassed, showSkipped;
|
33
|
+
|
34
|
+
this.outerDiv = this.createDom('div', { className: 'jasmine_reporter' },
|
35
|
+
this.createDom('div', { className: 'banner' },
|
36
|
+
this.createDom('div', { className: 'logo' },
|
37
|
+
this.createDom('a', { href: 'http://pivotal.github.com/jasmine/', target: "_blank" }, "Jasmine"),
|
38
|
+
this.createDom('span', { className: 'version' }, runner.env.versionString())),
|
39
|
+
this.createDom('div', { className: 'options' },
|
40
|
+
"Show ",
|
41
|
+
showPassed = this.createDom('input', { id: "__jasmine_TrivialReporter_showPassed__", type: 'checkbox' }),
|
42
|
+
this.createDom('label', { "for": "__jasmine_TrivialReporter_showPassed__" }, " passed "),
|
43
|
+
showSkipped = this.createDom('input', { id: "__jasmine_TrivialReporter_showSkipped__", type: 'checkbox' }),
|
44
|
+
this.createDom('label', { "for": "__jasmine_TrivialReporter_showSkipped__" }, " skipped")
|
45
|
+
)
|
46
|
+
),
|
47
|
+
|
48
|
+
this.runnerDiv = this.createDom('div', { className: 'runner running' },
|
49
|
+
this.createDom('a', { className: 'run_spec', href: '?' }, "run all"),
|
50
|
+
this.runnerMessageSpan = this.createDom('span', {}, "Running..."),
|
51
|
+
this.finishedAtSpan = this.createDom('span', { className: 'finished-at' }, ""))
|
52
|
+
);
|
53
|
+
|
54
|
+
this.document.body.appendChild(this.outerDiv);
|
55
|
+
|
56
|
+
var suites = runner.suites();
|
57
|
+
for (var i = 0; i < suites.length; i++) {
|
58
|
+
var suite = suites[i];
|
59
|
+
var suiteDiv = this.createDom('div', { className: 'suite' },
|
60
|
+
this.createDom('a', { className: 'run_spec', href: '?spec=' + encodeURIComponent(suite.getFullName()) }, "run"),
|
61
|
+
this.createDom('a', { className: 'description', href: '?spec=' + encodeURIComponent(suite.getFullName()) }, suite.description));
|
62
|
+
this.suiteDivs[suite.id] = suiteDiv;
|
63
|
+
var parentDiv = this.outerDiv;
|
64
|
+
if (suite.parentSuite) {
|
65
|
+
parentDiv = this.suiteDivs[suite.parentSuite.id];
|
66
|
+
}
|
67
|
+
parentDiv.appendChild(suiteDiv);
|
68
|
+
}
|
69
|
+
|
70
|
+
this.startedAt = new Date();
|
71
|
+
|
72
|
+
var self = this;
|
73
|
+
showPassed.onclick = function(evt) {
|
74
|
+
if (showPassed.checked) {
|
75
|
+
self.outerDiv.className += ' show-passed';
|
76
|
+
} else {
|
77
|
+
self.outerDiv.className = self.outerDiv.className.replace(/ show-passed/, '');
|
78
|
+
}
|
79
|
+
};
|
80
|
+
|
81
|
+
showSkipped.onclick = function(evt) {
|
82
|
+
if (showSkipped.checked) {
|
83
|
+
self.outerDiv.className += ' show-skipped';
|
84
|
+
} else {
|
85
|
+
self.outerDiv.className = self.outerDiv.className.replace(/ show-skipped/, '');
|
86
|
+
}
|
87
|
+
};
|
88
|
+
};
|
89
|
+
|
90
|
+
jasmine.TrivialReporter.prototype.reportRunnerResults = function(runner) {
|
91
|
+
var results = runner.results();
|
92
|
+
var className = (results.failedCount > 0) ? "runner failed" : "runner passed";
|
93
|
+
this.runnerDiv.setAttribute("class", className);
|
94
|
+
//do it twice for IE
|
95
|
+
this.runnerDiv.setAttribute("className", className);
|
96
|
+
var specs = runner.specs();
|
97
|
+
var specCount = 0;
|
98
|
+
for (var i = 0; i < specs.length; i++) {
|
99
|
+
if (this.specFilter(specs[i])) {
|
100
|
+
specCount++;
|
101
|
+
}
|
102
|
+
}
|
103
|
+
var message = "" + specCount + " spec" + (specCount == 1 ? "" : "s" ) + ", " + results.failedCount + " failure" + ((results.failedCount == 1) ? "" : "s");
|
104
|
+
message += " in " + ((new Date().getTime() - this.startedAt.getTime()) / 1000) + "s";
|
105
|
+
this.runnerMessageSpan.replaceChild(this.createDom('a', { className: 'description', href: '?'}, message), this.runnerMessageSpan.firstChild);
|
106
|
+
|
107
|
+
this.finishedAtSpan.appendChild(document.createTextNode("Finished at " + new Date().toString()));
|
108
|
+
};
|
109
|
+
|
110
|
+
jasmine.TrivialReporter.prototype.reportSuiteResults = function(suite) {
|
111
|
+
var results = suite.results();
|
112
|
+
var status = results.passed() ? 'passed' : 'failed';
|
113
|
+
if (results.totalCount == 0) { // todo: change this to check results.skipped
|
114
|
+
status = 'skipped';
|
115
|
+
}
|
116
|
+
this.suiteDivs[suite.id].className += " " + status;
|
117
|
+
};
|
118
|
+
|
119
|
+
jasmine.TrivialReporter.prototype.reportSpecStarting = function(spec) {
|
120
|
+
if (this.logRunningSpecs) {
|
121
|
+
this.log('>> Jasmine Running ' + spec.suite.description + ' ' + spec.description + '...');
|
122
|
+
}
|
123
|
+
};
|
124
|
+
|
125
|
+
jasmine.TrivialReporter.prototype.reportSpecResults = function(spec) {
|
126
|
+
var results = spec.results();
|
127
|
+
var status = results.passed() ? 'passed' : 'failed';
|
128
|
+
if (results.skipped) {
|
129
|
+
status = 'skipped';
|
130
|
+
}
|
131
|
+
var specDiv = this.createDom('div', { className: 'spec ' + status },
|
132
|
+
this.createDom('a', { className: 'run_spec', href: '?spec=' + encodeURIComponent(spec.getFullName()) }, "run"),
|
133
|
+
this.createDom('a', {
|
134
|
+
className: 'description',
|
135
|
+
href: '?spec=' + encodeURIComponent(spec.getFullName()),
|
136
|
+
title: spec.getFullName()
|
137
|
+
}, spec.description));
|
138
|
+
|
139
|
+
|
140
|
+
var resultItems = results.getItems();
|
141
|
+
var messagesDiv = this.createDom('div', { className: 'messages' });
|
142
|
+
for (var i = 0; i < resultItems.length; i++) {
|
143
|
+
var result = resultItems[i];
|
144
|
+
|
145
|
+
if (result.type == 'log') {
|
146
|
+
messagesDiv.appendChild(this.createDom('div', {className: 'resultMessage log'}, result.toString()));
|
147
|
+
} else if (result.type == 'expect' && result.passed && !result.passed()) {
|
148
|
+
messagesDiv.appendChild(this.createDom('div', {className: 'resultMessage fail'}, result.message));
|
149
|
+
|
150
|
+
if (result.trace.stack) {
|
151
|
+
messagesDiv.appendChild(this.createDom('div', {className: 'stackTrace'}, result.trace.stack));
|
152
|
+
}
|
153
|
+
}
|
154
|
+
}
|
155
|
+
|
156
|
+
if (messagesDiv.childNodes.length > 0) {
|
157
|
+
specDiv.appendChild(messagesDiv);
|
158
|
+
}
|
159
|
+
|
160
|
+
this.suiteDivs[spec.suite.id].appendChild(specDiv);
|
161
|
+
};
|
162
|
+
|
163
|
+
jasmine.TrivialReporter.prototype.log = function() {
|
164
|
+
var console = jasmine.getGlobal().console;
|
165
|
+
if (console && console.log) {
|
166
|
+
if (console.log.apply) {
|
167
|
+
console.log.apply(console, arguments);
|
168
|
+
} else {
|
169
|
+
console.log(arguments); // ie fix: console.log.apply doesn't exist on ie
|
170
|
+
}
|
171
|
+
}
|
172
|
+
};
|
173
|
+
|
174
|
+
jasmine.TrivialReporter.prototype.getLocation = function() {
|
175
|
+
return this.document.location;
|
176
|
+
};
|
177
|
+
|
178
|
+
jasmine.TrivialReporter.prototype.specFilter = function(spec) {
|
179
|
+
var paramMap = {};
|
180
|
+
var params = this.getLocation().search.substring(1).split('&');
|
181
|
+
for (var i = 0; i < params.length; i++) {
|
182
|
+
var p = params[i].split('=');
|
183
|
+
paramMap[decodeURIComponent(p[0])] = decodeURIComponent(p[1]);
|
184
|
+
}
|
185
|
+
|
186
|
+
if (!paramMap["spec"]) return true;
|
187
|
+
return spec.getFullName().indexOf(paramMap["spec"]) == 0;
|
188
|
+
};
|