evergreen 0.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +101 -3
- data/bin/evergreen +2 -2
- data/lib/evergreen.rb +14 -2
- data/lib/evergreen/evergreen.js +23 -0
- data/lib/evergreen/rails.rb +8 -0
- data/lib/evergreen/runner.rb +21 -14
- data/lib/evergreen/spec.rb +12 -33
- data/lib/evergreen/version.rb +1 -1
- data/lib/evergreen/views/list.erb +1 -1
- data/lib/evergreen/views/spec.erb +9 -22
- data/lib/jasmine/README.markdown +21 -28
- data/lib/jasmine/Rakefile +98 -68
- data/lib/jasmine/example/SpecRunner.html +27 -0
- data/lib/jasmine/example/spec/PlayerSpec.js +58 -0
- data/lib/jasmine/example/spec/SpecHelper.js +9 -0
- data/lib/jasmine/example/src/Player.js +22 -0
- data/lib/jasmine/example/src/Song.js +7 -0
- data/lib/jasmine/lib/jasmine-html.js +182 -0
- data/lib/jasmine/lib/{jasmine-0.10.4.js → jasmine.js} +127 -155
- data/lib/jasmine/spec/runner.html +4 -3
- data/lib/jasmine/spec/suites/BaseSpec.js +27 -0
- data/lib/jasmine/spec/suites/CustomMatchersSpec.js +0 -24
- data/lib/jasmine/spec/suites/EnvSpec.js +1 -1
- data/lib/jasmine/spec/suites/JsApiReporterSpec.js +16 -9
- data/lib/jasmine/spec/suites/MatchersSpec.js +49 -42
- data/lib/jasmine/spec/suites/MockClockSpec.js +4 -0
- data/lib/jasmine/spec/suites/MultiReporterSpec.js +23 -8
- data/lib/jasmine/spec/suites/PrettyPrintSpec.js +2 -2
- data/lib/jasmine/spec/suites/ReporterSpec.js +10 -14
- data/lib/jasmine/spec/suites/RunnerSpec.js +6 -6
- data/lib/jasmine/spec/suites/SpecRunningSpec.js +1 -1
- data/lib/jasmine/spec/suites/SpecSpec.js +15 -1
- data/lib/jasmine/spec/suites/SpySpec.js +3 -3
- data/lib/jasmine/spec/suites/TrivialReporterSpec.js +91 -14
- data/lib/jasmine/spec/suites/WaitsForBlockSpec.js +5 -6
- data/lib/jasmine/src/JsApiReporter.js +4 -6
- data/lib/jasmine/src/Matchers.js +19 -19
- data/lib/jasmine/src/MultiReporter.js +8 -1
- data/lib/jasmine/src/NestedResults.js +5 -5
- data/lib/jasmine/src/PrettyPrinter.js +2 -2
- data/lib/jasmine/src/Reporter.js +4 -0
- data/lib/jasmine/src/Spec.js +12 -8
- data/lib/jasmine/src/base.js +40 -44
- data/lib/jasmine/{lib → src/html}/TrivialReporter.js +17 -6
- data/lib/jasmine/src/html/jasmine.css +166 -0
- data/lib/jasmine/src/mock-timeout.js +22 -16
- data/lib/jasmine/src/version.json +2 -2
- data/lib/tasks/evergreen.rake +7 -0
- data/spec/evergreen_spec.rb +18 -0
- data/spec/fixtures/public/jquery.js +152 -0
- data/spec/fixtures/spec/javascripts/bar_spec.js +0 -0
- data/spec/fixtures/spec/javascripts/failing_spec.js +12 -0
- data/spec/fixtures/spec/javascripts/foo_spec.js +0 -0
- data/spec/fixtures/spec/javascripts/templates_spec.html +1 -0
- data/spec/fixtures/spec/javascripts/templates_spec.js +23 -0
- data/spec/fixtures/spec/javascripts/testing_spec.js +11 -0
- data/spec/fixtures/spec/javascripts/transactions_spec.js +14 -0
- data/spec/meta_spec.rb +17 -0
- data/spec/runner_spec.rb +35 -0
- data/spec/spec_helper.rb +33 -0
- data/spec/spec_spec.rb +30 -0
- metadata +64 -48
- data/lib/jasmine/doc/files.html +0 -460
- data/lib/jasmine/doc/index.html +0 -322
- data/lib/jasmine/doc/symbols/_global_.html +0 -918
- data/lib/jasmine/doc/symbols/jasmine.Block.html +0 -417
- data/lib/jasmine/doc/symbols/jasmine.Clock.html +0 -678
- data/lib/jasmine/doc/symbols/jasmine.Env.html +0 -1169
- data/lib/jasmine/doc/symbols/jasmine.JsApiReporter.html +0 -822
- data/lib/jasmine/doc/symbols/jasmine.Matchers.html +0 -1474
- data/lib/jasmine/doc/symbols/jasmine.MultiReporter.html +0 -394
- data/lib/jasmine/doc/symbols/jasmine.NestedResults.html +0 -710
- data/lib/jasmine/doc/symbols/jasmine.Reporter.html +0 -574
- data/lib/jasmine/doc/symbols/jasmine.Runner.html +0 -710
- data/lib/jasmine/doc/symbols/jasmine.Spec.html +0 -1253
- data/lib/jasmine/doc/symbols/jasmine.Spy.html +0 -855
- data/lib/jasmine/doc/symbols/jasmine.Suite.html +0 -705
- data/lib/jasmine/doc/symbols/jasmine.html +0 -1345
- data/lib/jasmine/doc/symbols/jasmine.util.html +0 -535
- data/lib/jasmine/doc/symbols/src/lib_TrivialReporter.js.html +0 -124
- data/lib/jasmine/doc/symbols/src/src_Block.js.html +0 -29
- data/lib/jasmine/doc/symbols/src/src_Env.js.html +0 -248
- data/lib/jasmine/doc/symbols/src/src_JsApiReporter.js.html +0 -111
- data/lib/jasmine/doc/symbols/src/src_Matchers.js.html +0 -344
- data/lib/jasmine/doc/symbols/src/src_MultiReporter.js.html +0 -36
- data/lib/jasmine/doc/symbols/src/src_NestedResults.js.html +0 -88
- data/lib/jasmine/doc/symbols/src/src_PrettyPrinter.js.html +0 -130
- data/lib/jasmine/doc/symbols/src/src_Queue.js.html +0 -102
- data/lib/jasmine/doc/symbols/src/src_Reporter.js.html +0 -35
- data/lib/jasmine/doc/symbols/src/src_Reporters.js.html +0 -51
- data/lib/jasmine/doc/symbols/src/src_Runner.js.html +0 -75
- data/lib/jasmine/doc/symbols/src/src_Spec.js.html +0 -214
- data/lib/jasmine/doc/symbols/src/src_Suite.js.html +0 -77
- data/lib/jasmine/doc/symbols/src/src_WaitsBlock.js.html +0 -21
- data/lib/jasmine/doc/symbols/src/src_WaitsForBlock.js.html +0 -45
- data/lib/jasmine/doc/symbols/src/src_base.js.html +0 -585
- data/lib/jasmine/doc/symbols/src/src_mock-timeout.js.html +0 -185
- data/lib/jasmine/doc/symbols/src/src_util.js.html +0 -75
- data/lib/jasmine/example/example_runner.html +0 -22
- data/lib/jasmine/example/spec/example_suite.js +0 -11
- data/lib/jasmine/spec/jasmine_helper.rb +0 -44
- data/lib/jasmine/spec/jasmine_spec.rb +0 -31
- data/lib/jasmine/spec/saucelabs.yml +0 -24
- data/lib/jasmine/src/Reporters.js +0 -43
data/lib/jasmine/Rakefile
CHANGED
@@ -1,38 +1,34 @@
|
|
1
|
-
require File.expand_path(File.join(File.dirname(__FILE__), "spec/jasmine_helper.rb"))
|
2
|
-
|
3
1
|
def jasmine_sources
|
4
2
|
sources = ["src/base.js", "src/util.js", "src/Env.js", "src/Reporter.js", "src/Block.js"]
|
5
|
-
sources += Dir.glob('src/*.js').reject{|f| f == 'src/base.js' || sources.include?(f)}.sort
|
3
|
+
sources += Dir.glob('src/*.js').reject { |f| f == 'src/base.js' || sources.include?(f) }.sort
|
6
4
|
sources
|
7
5
|
end
|
8
6
|
|
9
|
-
def
|
10
|
-
"
|
7
|
+
def jasmine_html_sources
|
8
|
+
["src/html/TrivialReporter.js"]
|
11
9
|
end
|
12
10
|
|
13
|
-
def
|
14
|
-
|
11
|
+
def jasmine_version
|
12
|
+
"#{version_hash['major']}.#{version_hash['minor']}.#{version_hash['build']}"
|
15
13
|
end
|
16
14
|
|
17
|
-
def
|
18
|
-
require
|
19
|
-
|
20
|
-
puts "your tests are here:"
|
21
|
-
puts " http://localhost:8888/run.html"
|
22
|
-
|
23
|
-
Jasmine::SimpleServer.start(
|
24
|
-
8888,
|
25
|
-
lambda { JasmineHelper.specs },
|
26
|
-
JasmineHelper.dir_mappings,
|
27
|
-
:jasmine_files => jasmine_includes)
|
15
|
+
def version_hash
|
16
|
+
require 'json'
|
17
|
+
@version ||= JSON.parse(File.new("src/version.json").read);
|
28
18
|
end
|
29
19
|
|
30
20
|
task :default => 'jasmine:dist'
|
31
21
|
|
22
|
+
def substitute_jasmine_version(filename)
|
23
|
+
contents = File.read(filename)
|
24
|
+
contents = contents.gsub(/##JASMINE_VERSION##/, (jasmine_version))
|
25
|
+
File.open(filename, 'w') { |f| f.write(contents) }
|
26
|
+
end
|
27
|
+
|
32
28
|
namespace :jasmine do
|
33
29
|
|
34
30
|
desc 'Prepares for distribution'
|
35
|
-
task :dist => ['jasmine:build', 'jasmine:doc']
|
31
|
+
task :dist => ['jasmine:build', 'jasmine:doc', 'jasmine:build_example_project', 'jasmine:fill_index_downloads']
|
36
32
|
|
37
33
|
desc 'Check jasmine sources for coding problems'
|
38
34
|
task :lint do
|
@@ -46,6 +42,11 @@ namespace :jasmine do
|
|
46
42
|
puts "Dangerous undefined at #{src}:#{i}:\n > #{line}"
|
47
43
|
passed = false
|
48
44
|
end
|
45
|
+
|
46
|
+
if line.scan(/window/).length > 0
|
47
|
+
puts "Dangerous window at #{src}:#{i}:\n > #{line}"
|
48
|
+
passed = false
|
49
|
+
end
|
49
50
|
end
|
50
51
|
end
|
51
52
|
|
@@ -58,89 +59,118 @@ namespace :jasmine do
|
|
58
59
|
desc 'Builds lib/jasmine from source'
|
59
60
|
task :build => :lint do
|
60
61
|
puts 'Building Jasmine from source'
|
61
|
-
require 'json'
|
62
62
|
|
63
63
|
sources = jasmine_sources
|
64
64
|
version = version_hash
|
65
65
|
|
66
66
|
old_jasmine_files = Dir.glob('lib/jasmine*.js')
|
67
|
-
old_jasmine_files.each
|
68
|
-
File.delete(file)
|
69
|
-
end
|
70
|
-
|
71
|
-
jasmine = File.new("lib/#{jasmine_filename version}", 'w')
|
67
|
+
old_jasmine_files.each { |file| File.delete(file) }
|
72
68
|
|
73
|
-
|
74
|
-
|
75
|
-
|
69
|
+
File.open("lib/jasmine.js", 'w') do |jasmine|
|
70
|
+
sources.each do |source_filename|
|
71
|
+
jasmine.puts(File.read(source_filename))
|
72
|
+
end
|
76
73
|
|
77
|
-
|
74
|
+
jasmine.puts %{
|
78
75
|
jasmine.version_= {
|
79
76
|
"major": #{version['major']},
|
80
77
|
"minor": #{version['minor']},
|
81
78
|
"build": #{version['build']},
|
82
79
|
"revision": #{Time.now.to_i}
|
83
|
-
|
80
|
+
};
|
84
81
|
}
|
82
|
+
end
|
83
|
+
|
84
|
+
File.open("lib/jasmine-html.js", 'w') do |jasmine_html|
|
85
|
+
jasmine_html_sources.each do |source_filename|
|
86
|
+
jasmine_html.puts(File.read(source_filename))
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
FileUtils.cp("src/html/jasmine.css", "lib/jasmine.css")
|
91
|
+
end
|
85
92
|
|
86
|
-
|
93
|
+
task :need_pages_submodule do
|
94
|
+
unless File.exists?('pages/index.html')
|
95
|
+
raise "Jasmine pages submodule isn't present. Run git submodule update --init"
|
96
|
+
end
|
87
97
|
end
|
88
98
|
|
89
99
|
desc "Build jasmine documentation"
|
90
|
-
task :doc do
|
100
|
+
task :doc => :need_pages_submodule do
|
91
101
|
puts 'Creating Jasmine Documentation'
|
92
102
|
require 'rubygems'
|
93
103
|
#sudo gem install ragaskar-jsdoc_helper
|
94
104
|
require 'jsdoc_helper'
|
95
105
|
|
106
|
+
FileUtils.rm_r "pages/jsdoc", :force => true
|
96
107
|
|
97
108
|
JsdocHelper::Rake::Task.new(:lambda_jsdoc) do |t|
|
98
|
-
t[:files] = jasmine_sources <<
|
109
|
+
t[:files] = jasmine_sources << jasmine_html_sources
|
99
110
|
t[:options] = "-a"
|
111
|
+
t[:out] = "pages/jsdoc"
|
100
112
|
end
|
101
113
|
Rake::Task[:lambda_jsdoc].invoke
|
102
114
|
end
|
103
115
|
|
116
|
+
desc "Build example project"
|
117
|
+
task :build_example_project => :need_pages_submodule do
|
118
|
+
require 'tmpdir'
|
119
|
+
|
120
|
+
temp_dir = File.join(Dir.tmpdir, 'jasmine-standalone-project')
|
121
|
+
puts "Building Example Project in #{temp_dir}"
|
122
|
+
FileUtils.rm_r temp_dir if File.exists?(temp_dir)
|
123
|
+
Dir.mkdir(temp_dir)
|
124
|
+
|
125
|
+
root = File.expand_path(File.dirname(__FILE__))
|
126
|
+
FileUtils.cp_r File.join(root, 'example/.'), File.join(temp_dir)
|
127
|
+
substitute_jasmine_version(File.join(temp_dir, "SpecRunner.html"))
|
128
|
+
|
129
|
+
lib_dir = File.join(temp_dir, "lib/jasmine-#{jasmine_version}")
|
130
|
+
FileUtils.mkdir_p(lib_dir)
|
131
|
+
{
|
132
|
+
"lib/jasmine.js" => "jasmine.js",
|
133
|
+
"lib/jasmine-html.js" => "jasmine-html.js",
|
134
|
+
"src/html/jasmine.css" => "jasmine.css"
|
135
|
+
}.each_pair do |src, dest|
|
136
|
+
FileUtils.cp(File.join(root, src), File.join(lib_dir, dest))
|
137
|
+
end
|
104
138
|
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
task :server_build => 'jasmine:build' do
|
115
|
-
|
116
|
-
start_jasmine_server
|
139
|
+
dist_dir = File.join(root, 'pages/downloads')
|
140
|
+
zip_file_name = File.join(dist_dir, "jasmine-standalone-#{jasmine_version}.zip")
|
141
|
+
puts "Zipping Example Project and moving to #{zip_file_name}"
|
142
|
+
FileUtils.mkdir(dist_dir) unless File.exist?(dist_dir)
|
143
|
+
if File.exist?(zip_file_name)
|
144
|
+
puts "WARNING!!! #{zip_file_name} already exists!"
|
145
|
+
FileUtils.rm(zip_file_name)
|
146
|
+
end
|
147
|
+
exec "cd #{temp_dir} && zip -r #{zip_file_name} . -x .[a-zA-Z0-9]*"
|
117
148
|
end
|
118
149
|
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
ENV['SAUCELABS'] = 'true'
|
135
|
-
Rake::Task['jasmine:test:ci:local'].invoke
|
136
|
-
end
|
150
|
+
task :fill_index_downloads do
|
151
|
+
require 'digest/sha1'
|
152
|
+
|
153
|
+
download_html = "<!-- START_DOWNLOADS -->\n"
|
154
|
+
download_html += "<table>\n<tr><th/><th>Version</th><th>Size</th><th>Date</th><th>SHA1</th></tr>\n"
|
155
|
+
Dir.glob('pages/downloads/*.zip').sort.reverse.each do |f|
|
156
|
+
sha1 = Digest::SHA1.hexdigest File.read(f)
|
157
|
+
|
158
|
+
fn = f.sub(/^pages\//, '')
|
159
|
+
version = /jasmine-standalone-(.*).zip/.match(f)[1]
|
160
|
+
download_html += "<td><a href='#{fn}'>#{fn.sub(/downloads\//, '')}</a></td>"
|
161
|
+
download_html += "<td>#{version}</td>\n"
|
162
|
+
download_html += "<td>#{File.size(f) / 1024}k</td>\n"
|
163
|
+
download_html += "<td>#{File.mtime(f).strftime("%Y/%m/%d %H:%M:%S")}</td>\n"
|
164
|
+
download_html += "<td>#{sha1}</td>\n"
|
137
165
|
end
|
138
|
-
|
166
|
+
download_html += "</table>\n<!-- END_DOWNLOADS -->"
|
139
167
|
|
140
|
-
|
141
|
-
|
142
|
-
|
168
|
+
index_page = File.read('pages/index.html')
|
169
|
+
matcher = /<!-- START_DOWNLOADS -->.*<!-- END_DOWNLOADS -->/m
|
170
|
+
index_page = index_page.sub(matcher, download_html)
|
171
|
+
File.open('pages/index.html', 'w') {|f| f.write(index_page)}
|
172
|
+
puts "rewrote that file"
|
143
173
|
end
|
144
174
|
end
|
145
175
|
|
146
|
-
task :jasmine => ['jasmine:
|
176
|
+
task :jasmine => ['jasmine:dist']
|
@@ -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
|
+
<script type="text/javascript">
|
21
|
+
jasmine.getEnv().addReporter(new jasmine.TrivialReporter());
|
22
|
+
jasmine.getEnv().execute();
|
23
|
+
</script>
|
24
|
+
|
25
|
+
</body>
|
26
|
+
</html>
|
27
|
+
|
@@ -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,182 @@
|
|
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
|
+
"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.onchange = function(evt) {
|
74
|
+
if (evt.target.checked) {
|
75
|
+
self.outerDiv.className += ' show-passed';
|
76
|
+
} else {
|
77
|
+
self.outerDiv.className = self.outerDiv.className.replace(/ show-passed/, '');
|
78
|
+
}
|
79
|
+
};
|
80
|
+
|
81
|
+
showSkipped.onchange = function(evt) {
|
82
|
+
if (evt.target.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) console.log.apply(console, arguments);
|
166
|
+
};
|
167
|
+
|
168
|
+
jasmine.TrivialReporter.prototype.getLocation = function() {
|
169
|
+
return this.document.location;
|
170
|
+
};
|
171
|
+
|
172
|
+
jasmine.TrivialReporter.prototype.specFilter = function(spec) {
|
173
|
+
var paramMap = {};
|
174
|
+
var params = this.getLocation().search.substring(1).split('&');
|
175
|
+
for (var i = 0; i < params.length; i++) {
|
176
|
+
var p = params[i].split('=');
|
177
|
+
paramMap[decodeURIComponent(p[0])] = decodeURIComponent(p[1]);
|
178
|
+
}
|
179
|
+
|
180
|
+
if (!paramMap["spec"]) return true;
|
181
|
+
return spec.getFullName().indexOf(paramMap["spec"]) == 0;
|
182
|
+
};
|