jasmine-headless-webkit 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +5 -1
- data/Guardfile +23 -0
- data/bin/jasmine-headless-webkit +11 -4
- data/ext/jasmine-webkit-specrunner/specrunner.cpp +30 -4
- data/lib/jasmine/cli.rb +13 -0
- data/lib/jasmine-headless-webkit/version.rb +1 -1
- data/spec/bin/jasmine-headless-webkit_spec.rb +31 -3
- metadata +12 -5
data/Gemfile
CHANGED
data/Guardfile
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
|
2
|
+
# Add files and commands to this file, like the example:
|
3
|
+
# watch('file/path') { `command(s)` }
|
4
|
+
#
|
5
|
+
|
6
|
+
guard 'shell' do
|
7
|
+
watch(%r{ext/jasmine-webkit-specrunner/specrunner.cpp}) { compile }
|
8
|
+
end
|
9
|
+
# A sample Guardfile
|
10
|
+
# More info at https://github.com/guard/guard#readme
|
11
|
+
|
12
|
+
guard 'rspec', :version => 2 do
|
13
|
+
watch(%r{^spec/.+_spec\.rb})
|
14
|
+
watch(%r{^lib/(.+)\.rb}) { |m| "spec/lib/#{m[1]}_spec.rb" }
|
15
|
+
watch(%r{^bin/(.+)}) { |m| "spec/bin/#{m[1]}_spec.rb" }
|
16
|
+
watch('spec/spec_helper.rb') { "spec" }
|
17
|
+
end
|
18
|
+
|
19
|
+
def compile
|
20
|
+
system %{cd ext/jasmine-webkit-specrunner && ruby extconf.rb}
|
21
|
+
end
|
22
|
+
|
23
|
+
compile
|
data/bin/jasmine-headless-webkit
CHANGED
@@ -2,7 +2,10 @@
|
|
2
2
|
|
3
3
|
require 'rubygems'
|
4
4
|
|
5
|
-
gem_dir
|
5
|
+
def gem_dir
|
6
|
+
File.expand_path('../..', __FILE__)
|
7
|
+
end
|
8
|
+
|
6
9
|
$:.unshift(File.join(gem_dir, 'lib'))
|
7
10
|
|
8
11
|
require 'yaml'
|
@@ -25,13 +28,15 @@ opts = GetoptLong.new(
|
|
25
28
|
[ '--colors', '-c', GetoptLong::NO_ARGUMENT ],
|
26
29
|
[ '--no-colors', GetoptLong::NO_ARGUMENT ],
|
27
30
|
[ '--keep', GetoptLong::NO_ARGUMENT ],
|
31
|
+
[ '--report', GetoptLong::REQUIRED_ARGUMENT ],
|
28
32
|
[ '--jasmine-config', '-j', GetoptLong::REQUIRED_ARGUMENT ]
|
29
33
|
)
|
30
34
|
|
31
35
|
options = {
|
32
36
|
:colors => false,
|
33
37
|
:remove_html_file => true,
|
34
|
-
:jasmine_config => 'spec/javascripts/support/jasmine.yml'
|
38
|
+
:jasmine_config => 'spec/javascripts/support/jasmine.yml',
|
39
|
+
:report => false
|
35
40
|
}
|
36
41
|
|
37
42
|
@process_options = lambda { |*args|
|
@@ -42,8 +47,10 @@ options = {
|
|
42
47
|
options[:colors] = true
|
43
48
|
when '--no-colors', '-nc'
|
44
49
|
options[:colors] = false
|
45
|
-
when '--keep'
|
50
|
+
when '--keep'
|
46
51
|
options[:remove_html_file] = false
|
52
|
+
when '--report'
|
53
|
+
options[:report] = arg
|
47
54
|
when '--jasmine-config', '-j'
|
48
55
|
options[:jasmine_config] = arg
|
49
56
|
end
|
@@ -97,7 +104,7 @@ files = files.collect { |file|
|
|
97
104
|
output = jasmine_html_template(files)
|
98
105
|
|
99
106
|
File.open(target = "specrunner.#{$$}.html", 'w') { |fh| fh.print output }
|
100
|
-
system
|
107
|
+
system jasmine_command(options, target)
|
101
108
|
status = $?.exitstatus
|
102
109
|
FileUtils.rm_f target if options[:remove_html_file] || (status == 0)
|
103
110
|
|
@@ -23,6 +23,8 @@
|
|
23
23
|
|
24
24
|
#include <QtGui>
|
25
25
|
#include <QtWebKit>
|
26
|
+
#include <QFile>
|
27
|
+
#include <QTextStream>
|
26
28
|
#include <iostream>
|
27
29
|
|
28
30
|
#if QT_VERSION < QT_VERSION_CHECK(4, 7, 0)
|
@@ -64,6 +66,7 @@ public:
|
|
64
66
|
HeadlessSpecRunner();
|
65
67
|
void load(const QString &spec);
|
66
68
|
void setColors(bool colors);
|
69
|
+
void reportFile(const QString &file);
|
67
70
|
public slots:
|
68
71
|
void log(const QString &msg);
|
69
72
|
void specPassed();
|
@@ -88,6 +91,7 @@ private:
|
|
88
91
|
bool isFinished;
|
89
92
|
bool didFail;
|
90
93
|
bool consoleNotUsedThisRun;
|
94
|
+
QString reportFilename;
|
91
95
|
|
92
96
|
void red();
|
93
97
|
void green();
|
@@ -142,6 +146,11 @@ void HeadlessSpecRunner::setColors(bool colors)
|
|
142
146
|
showColors = colors;
|
143
147
|
}
|
144
148
|
|
149
|
+
void HeadlessSpecRunner::reportFile(const QString &file)
|
150
|
+
{
|
151
|
+
reportFilename = file;
|
152
|
+
}
|
153
|
+
|
145
154
|
void HeadlessSpecRunner::red()
|
146
155
|
{
|
147
156
|
if (showColors) std::cout << "\033[0;31m";
|
@@ -246,6 +255,18 @@ void HeadlessSpecRunner::finishSuite(const QString &duration, const QString &tot
|
|
246
255
|
clear();
|
247
256
|
std::cout << std::endl;
|
248
257
|
|
258
|
+
if (!reportFilename.isEmpty()) {
|
259
|
+
QFile reportFH(reportFilename);
|
260
|
+
|
261
|
+
if (reportFH.open(QFile::WriteOnly)) {
|
262
|
+
QTextStream report(&reportFH);
|
263
|
+
report << qPrintable(total) << "/" << qPrintable(failed) << "/";
|
264
|
+
report << (usedConsole ? "T" : "F");
|
265
|
+
report << "/" << qPrintable(duration) << "\n";
|
266
|
+
reportFH.close();
|
267
|
+
}
|
268
|
+
}
|
269
|
+
|
249
270
|
isFinished = true;
|
250
271
|
}
|
251
272
|
|
@@ -284,16 +305,20 @@ void HeadlessSpecRunner::timerEvent(QTimerEvent *event)
|
|
284
305
|
|
285
306
|
int main(int argc, char** argv)
|
286
307
|
{
|
287
|
-
bool showColors = false;
|
288
308
|
char *filename = NULL;
|
309
|
+
char *reporter = NULL;
|
310
|
+
char showColors = false;
|
289
311
|
|
290
312
|
int c, index;
|
291
313
|
|
292
|
-
while ((c = getopt(argc, argv, "
|
314
|
+
while ((c = getopt(argc, argv, "cr:")) != -1) {
|
293
315
|
switch(c) {
|
294
316
|
case 'c':
|
295
317
|
showColors = true;
|
296
318
|
break;
|
319
|
+
case 'r':
|
320
|
+
reporter = optarg;
|
321
|
+
break;
|
297
322
|
}
|
298
323
|
}
|
299
324
|
|
@@ -311,10 +336,11 @@ int main(int argc, char** argv)
|
|
311
336
|
}
|
312
337
|
|
313
338
|
QApplication app(argc, argv);
|
314
|
-
|
315
339
|
HeadlessSpecRunner runner;
|
316
|
-
runner.setColors(
|
340
|
+
runner.setColors(true);
|
341
|
+
runner.reportFile(reporter);
|
317
342
|
runner.load(QString::fromLocal8Bit(filename));
|
318
343
|
return app.exec();
|
319
344
|
}
|
320
345
|
|
346
|
+
|
data/lib/jasmine/cli.rb
CHANGED
@@ -52,6 +52,19 @@ module Jasmine
|
|
52
52
|
HTML
|
53
53
|
end
|
54
54
|
|
55
|
+
def runner_path
|
56
|
+
@runner_path ||= File.join(gem_dir, RUNNER)
|
57
|
+
end
|
58
|
+
|
59
|
+
def jasmine_command(options, target)
|
60
|
+
[
|
61
|
+
runner_path,
|
62
|
+
options[:colors] ? '-c' : nil,
|
63
|
+
options[:report] ? "-r #{options[:report]}" : nil,
|
64
|
+
target
|
65
|
+
].join(" ")
|
66
|
+
end
|
67
|
+
|
55
68
|
private
|
56
69
|
def read_config_file(file)
|
57
70
|
|
@@ -1,24 +1,52 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe "jasmine-headless-webkit" do
|
4
|
+
let(:report) { 'spec/report.txt' }
|
5
|
+
|
6
|
+
before do
|
7
|
+
FileUtils.rm_f report
|
8
|
+
end
|
9
|
+
|
10
|
+
after do
|
11
|
+
FileUtils.rm_f report
|
12
|
+
end
|
13
|
+
|
4
14
|
describe 'success' do
|
5
15
|
it "should succeed with error code 0" do
|
6
|
-
%
|
16
|
+
system %{bin/jasmine-headless-webkit -j spec/jasmine/success/success.yml --report #{report}}
|
7
17
|
$?.exitstatus.should == 0
|
18
|
+
|
19
|
+
parts = File.read(report).strip.split('/')
|
20
|
+
parts.length.should == 4
|
21
|
+
parts[0].should == "1"
|
22
|
+
parts[1].should == "0"
|
23
|
+
parts[2].should == "F"
|
8
24
|
end
|
9
25
|
end
|
10
26
|
|
11
27
|
describe 'failure' do
|
12
28
|
it "should fail with an error code of 1" do
|
13
|
-
%
|
29
|
+
system %{bin/jasmine-headless-webkit -j spec/jasmine/failure/failure.yml --report #{report}}
|
14
30
|
$?.exitstatus.should == 1
|
31
|
+
|
32
|
+
parts = File.read(report).strip.split('/')
|
33
|
+
parts.length.should == 4
|
34
|
+
parts[0].should == "1"
|
35
|
+
parts[1].should == "1"
|
36
|
+
parts[2].should == "F"
|
15
37
|
end
|
16
38
|
end
|
17
39
|
|
18
40
|
describe 'with console.log' do
|
19
41
|
it "should succeed, but has a console.log so an error code of 2" do
|
20
|
-
%
|
42
|
+
system %{bin/jasmine-headless-webkit -j spec/jasmine/console_log/console_log.yml --report #{report}}
|
21
43
|
$?.exitstatus.should == 2
|
44
|
+
|
45
|
+
parts = File.read(report).strip.split('/')
|
46
|
+
parts.length.should == 4
|
47
|
+
parts[0].should == "1"
|
48
|
+
parts[1].should == "0"
|
49
|
+
parts[2].should == "T"
|
22
50
|
end
|
23
51
|
end
|
24
52
|
end
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: jasmine-headless-webkit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.2.
|
5
|
+
version: 0.2.2
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- John Bintz
|
@@ -12,12 +12,11 @@ autorequire:
|
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
14
|
|
15
|
-
date: 2011-05-
|
15
|
+
date: 2011-05-29 00:00:00 -04:00
|
16
16
|
default_executable:
|
17
17
|
dependencies:
|
18
18
|
- !ruby/object:Gem::Dependency
|
19
19
|
name: jasmine
|
20
|
-
prerelease: false
|
21
20
|
requirement: &id001 !ruby/object:Gem::Requirement
|
22
21
|
none: false
|
23
22
|
requirements:
|
@@ -25,10 +24,10 @@ dependencies:
|
|
25
24
|
- !ruby/object:Gem::Version
|
26
25
|
version: "0"
|
27
26
|
type: :runtime
|
27
|
+
prerelease: false
|
28
28
|
version_requirements: *id001
|
29
29
|
- !ruby/object:Gem::Dependency
|
30
30
|
name: coffee-script
|
31
|
-
prerelease: false
|
32
31
|
requirement: &id002 !ruby/object:Gem::Requirement
|
33
32
|
none: false
|
34
33
|
requirements:
|
@@ -36,10 +35,10 @@ dependencies:
|
|
36
35
|
- !ruby/object:Gem::Version
|
37
36
|
version: "0"
|
38
37
|
type: :runtime
|
38
|
+
prerelease: false
|
39
39
|
version_requirements: *id002
|
40
40
|
- !ruby/object:Gem::Dependency
|
41
41
|
name: rainbow
|
42
|
-
prerelease: false
|
43
42
|
requirement: &id003 !ruby/object:Gem::Requirement
|
44
43
|
none: false
|
45
44
|
requirements:
|
@@ -47,6 +46,7 @@ dependencies:
|
|
47
46
|
- !ruby/object:Gem::Version
|
48
47
|
version: "0"
|
49
48
|
type: :runtime
|
49
|
+
prerelease: false
|
50
50
|
version_requirements: *id003
|
51
51
|
description: Run Jasmine specs headlessly
|
52
52
|
email:
|
@@ -63,6 +63,7 @@ files:
|
|
63
63
|
- .rspec
|
64
64
|
- CHANGELOG.md
|
65
65
|
- Gemfile
|
66
|
+
- Guardfile
|
66
67
|
- README.md
|
67
68
|
- Rakefile
|
68
69
|
- bin/jasmine-headless-webkit
|
@@ -109,12 +110,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
109
110
|
requirements:
|
110
111
|
- - ">="
|
111
112
|
- !ruby/object:Gem::Version
|
113
|
+
hash: -221398851887146257
|
114
|
+
segments:
|
115
|
+
- 0
|
112
116
|
version: "0"
|
113
117
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
114
118
|
none: false
|
115
119
|
requirements:
|
116
120
|
- - ">="
|
117
121
|
- !ruby/object:Gem::Version
|
122
|
+
hash: -221398851887146257
|
123
|
+
segments:
|
124
|
+
- 0
|
118
125
|
version: "0"
|
119
126
|
requirements: []
|
120
127
|
|