js-test-driver-rails 0.4.3 → 0.5.0.pre1
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/Gemfile.lock +17 -2
- data/TODO +6 -0
- data/bin/jstd +74 -0
- data/js-test-driver-rails.gemspec +2 -0
- data/lib/js_test_driver/application.rb +52 -0
- data/lib/js_test_driver/cli/capture_browsers.rb +34 -0
- data/lib/js_test_driver/cli/run.rb +56 -0
- data/lib/js_test_driver/cli/run_tests.rb +22 -0
- data/lib/js_test_driver/cli/start_server.rb +20 -0
- data/lib/js_test_driver/commands/base_command.rb +43 -0
- data/lib/js_test_driver/commands/generate_coverage_report.rb +17 -0
- data/lib/js_test_driver/commands/jstd_jar_command.rb +61 -0
- data/lib/js_test_driver/config.rb +84 -15
- data/lib/js_test_driver/config_factory.rb +21 -0
- data/lib/js_test_driver/missing_dependency_error.rb +4 -0
- data/lib/js_test_driver/remote_browser.rb +57 -0
- data/lib/js_test_driver/runner.rb +5 -217
- data/lib/js_test_driver/runtime_config.rb +155 -0
- data/lib/js_test_driver/tasks.rb +10 -8
- data/lib/js_test_driver/version.rb +1 -1
- data/lib/js_test_driver.rb +27 -3
- data/test/integration/sample_test.rb +3 -4
- data/test/sample/config/js_test_driver.rb +4 -0
- data/test/test_helper.rb +52 -1
- data/test/unit/capture_browsers_test.rb +30 -0
- data/test/unit/config_test.rb +31 -23
- data/test/unit/run_test.rb +28 -0
- data/test/unit/run_tests_test.rb +20 -0
- data/test/unit/runtime_config_test.rb +19 -0
- data/test/unit/start_server_test.rb +15 -0
- data/vendor/JasmineAdapter.js +3 -2
- data/vendor/jasmine.js +60 -23
- metadata +53 -11
- data/test/unit/runner_test.rb +0 -107
@@ -0,0 +1,28 @@
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'test_helper'))
|
2
|
+
|
3
|
+
module JsTestDriver
|
4
|
+
class RunTest < Test::Unit::TestCase
|
5
|
+
|
6
|
+
def test_should_run_with_all_arguments_at_once
|
7
|
+
config.browser 'foo', 'bar', 'baz'
|
8
|
+
|
9
|
+
application.run(:tests => 'TestCase',
|
10
|
+
:browsers => 'aaa,bbb',
|
11
|
+
:output_xml => true,
|
12
|
+
:capture_console => true)
|
13
|
+
|
14
|
+
assert_run("java -jar #{runtime_config.jar_path} --serverHandlerPrefix jstd --port 4224 --config #{runtime_config.config_yml_path} --browser aaa,bbb --tests TestCase --testOutput #{runtime_config.test_xml_data_path} --captureConsole")
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_when_measuring_coverage
|
18
|
+
config.measure_coverage
|
19
|
+
config.browser 'foo'
|
20
|
+
|
21
|
+
application.run(:output_xml => true)
|
22
|
+
|
23
|
+
assert_run("genhtml -o #{runtime_config.coverage_files_path} #{runtime_config.coverage_data_file}")
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'test_helper'))
|
2
|
+
|
3
|
+
module JsTestDriver
|
4
|
+
class RunTestsTest < Test::Unit::TestCase
|
5
|
+
|
6
|
+
def test_should_run_all_tests_by_default
|
7
|
+
application.run_tests
|
8
|
+
|
9
|
+
assert_run("java -jar #{runtime_config.jar_path} --serverHandlerPrefix jstd --config #{runtime_config.config_yml_path} --tests all")
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_should_run_selected_tests
|
13
|
+
application.run_tests(:tests => 'MyTestCase.some_test')
|
14
|
+
|
15
|
+
assert_run("java -jar #{runtime_config.jar_path} --serverHandlerPrefix jstd --config #{runtime_config.config_yml_path} --tests MyTestCase.some_test")
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'test_helper'))
|
2
|
+
|
3
|
+
module JsTestDriver
|
4
|
+
class RuntimeConfigTest < Test::Unit::TestCase
|
5
|
+
|
6
|
+
def test_should_have_default_config_path
|
7
|
+
assert application.runtime_config.config_path
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_should_have_default_jar_path
|
11
|
+
assert application.runtime_config.jar_path
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_should_have_default_tmp_path
|
15
|
+
assert application.runtime_config.config_yml_path
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'test_helper'))
|
2
|
+
|
3
|
+
module JsTestDriver
|
4
|
+
class StartServerTest < Test::Unit::TestCase
|
5
|
+
|
6
|
+
def test_should_run_server_with_given_port_number
|
7
|
+
application.config.port(6666)
|
8
|
+
|
9
|
+
application.start_server
|
10
|
+
|
11
|
+
assert_run("java -jar #{runtime_config.jar_path} --serverHandlerPrefix jstd --port #{config.port}")
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
end
|
data/vendor/JasmineAdapter.js
CHANGED
@@ -108,14 +108,15 @@ describe = intercept('describe');
|
|
108
108
|
beforeEach = intercept('beforeEach');
|
109
109
|
afterEach = intercept('afterEach');
|
110
110
|
|
111
|
-
var
|
111
|
+
var JASMINE_TYPE = 'jasmine test case';
|
112
|
+
TestCase('Jasmine Adapter Tests', null, JASMINE_TYPE);
|
112
113
|
|
113
114
|
jstestdriver.pluginRegistrar.register({
|
114
115
|
|
115
116
|
name: 'jasmine',
|
116
117
|
|
117
118
|
runTestConfiguration: function(config, onTestDone, onComplete){
|
118
|
-
if (config.
|
119
|
+
if (config.getTestCaseInfo().getType() != JASMINE_TYPE) return false;
|
119
120
|
(jasmine.currentEnv_ = new Env(onTestDone, onComplete)).execute();
|
120
121
|
return true;
|
121
122
|
},
|
data/vendor/jasmine.js
CHANGED
@@ -22,6 +22,12 @@ jasmine.unimplementedMethod_ = function() {
|
|
22
22
|
*/
|
23
23
|
jasmine.undefined = jasmine.___undefined___;
|
24
24
|
|
25
|
+
/**
|
26
|
+
* Show diagnostic messages in the console if set to true
|
27
|
+
*
|
28
|
+
*/
|
29
|
+
jasmine.VERBOSE = false;
|
30
|
+
|
25
31
|
/**
|
26
32
|
* Default interval in milliseconds for event loop yields (e.g. to allow network activity or to refresh the screen with the HTML-based runner). Small values here may result in slow test running. Zero means no updates until all tests have completed.
|
27
33
|
*
|
@@ -74,7 +80,7 @@ jasmine.MessageResult = function(values) {
|
|
74
80
|
|
75
81
|
jasmine.MessageResult.prototype.toString = function() {
|
76
82
|
var text = "";
|
77
|
-
for(var i = 0; i < this.values.length; i++) {
|
83
|
+
for (var i = 0; i < this.values.length; i++) {
|
78
84
|
if (i > 0) text += " ";
|
79
85
|
if (jasmine.isString_(this.values[i])) {
|
80
86
|
text += this.values[i];
|
@@ -91,9 +97,10 @@ jasmine.ExpectationResult = function(params) {
|
|
91
97
|
this.passed_ = params.passed;
|
92
98
|
this.expected = params.expected;
|
93
99
|
this.actual = params.actual;
|
94
|
-
|
95
100
|
this.message = this.passed_ ? 'Passed.' : params.message;
|
96
|
-
|
101
|
+
|
102
|
+
var trace = (params.trace || new Error(this.message));
|
103
|
+
this.trace = this.passed_ ? '' : trace;
|
97
104
|
};
|
98
105
|
|
99
106
|
jasmine.ExpectationResult.prototype.toString = function () {
|
@@ -119,7 +126,7 @@ jasmine.getEnv = function() {
|
|
119
126
|
* @returns {Boolean}
|
120
127
|
*/
|
121
128
|
jasmine.isArray_ = function(value) {
|
122
|
-
return jasmine.isA_("Array", value);
|
129
|
+
return jasmine.isA_("Array", value);
|
123
130
|
};
|
124
131
|
|
125
132
|
/**
|
@@ -587,17 +594,25 @@ jasmine.XmlHttpRequest = (typeof XMLHttpRequest == "undefined") ? function() {
|
|
587
594
|
try {
|
588
595
|
return f();
|
589
596
|
} catch(e) {
|
590
|
-
}
|
597
|
+
}
|
591
598
|
return null;
|
592
599
|
}
|
593
|
-
|
594
|
-
var xhr = tryIt(function(){
|
595
|
-
|
596
|
-
|
597
|
-
|
600
|
+
|
601
|
+
var xhr = tryIt(function() {
|
602
|
+
return new ActiveXObject("Msxml2.XMLHTTP.6.0");
|
603
|
+
}) ||
|
604
|
+
tryIt(function() {
|
605
|
+
return new ActiveXObject("Msxml2.XMLHTTP.3.0");
|
606
|
+
}) ||
|
607
|
+
tryIt(function() {
|
608
|
+
return new ActiveXObject("Msxml2.XMLHTTP");
|
609
|
+
}) ||
|
610
|
+
tryIt(function() {
|
611
|
+
return new ActiveXObject("Microsoft.XMLHTTP");
|
612
|
+
});
|
598
613
|
|
599
614
|
if (!xhr) throw new Error("This browser does not support XMLHttpRequest.");
|
600
|
-
|
615
|
+
|
601
616
|
return xhr;
|
602
617
|
} : XMLHttpRequest;
|
603
618
|
/**
|
@@ -773,14 +788,14 @@ jasmine.Env.prototype.describe = function(description, specDefinitions) {
|
|
773
788
|
declarationError = e;
|
774
789
|
}
|
775
790
|
|
776
|
-
this.currentSuite = parentSuite;
|
777
|
-
|
778
791
|
if (declarationError) {
|
779
792
|
this.it("encountered a declaration exception", function() {
|
780
793
|
throw declarationError;
|
781
794
|
});
|
782
795
|
}
|
783
796
|
|
797
|
+
this.currentSuite = parentSuite;
|
798
|
+
|
784
799
|
return suite;
|
785
800
|
};
|
786
801
|
|
@@ -1318,13 +1333,13 @@ jasmine.Matchers.prototype.toHaveBeenCalledWith = function() {
|
|
1318
1333
|
if (this.actual.callCount === 0) {
|
1319
1334
|
// todo: what should the failure message for .not.toHaveBeenCalledWith() be? is this right? test better. [xw]
|
1320
1335
|
return [
|
1321
|
-
"Expected spy to have been called with " + jasmine.pp(expectedArgs) + " but it was never called.",
|
1322
|
-
"Expected spy not to have been called with " + jasmine.pp(expectedArgs) + " but it was."
|
1336
|
+
"Expected spy " + this.actual.identity + " to have been called with " + jasmine.pp(expectedArgs) + " but it was never called.",
|
1337
|
+
"Expected spy " + this.actual.identity + " not to have been called with " + jasmine.pp(expectedArgs) + " but it was."
|
1323
1338
|
];
|
1324
1339
|
} else {
|
1325
1340
|
return [
|
1326
|
-
"Expected spy to have been called with " + jasmine.pp(expectedArgs) + " but was called with " + jasmine.pp(this.actual.argsForCall),
|
1327
|
-
"Expected spy not to have been called with " + jasmine.pp(expectedArgs) + " but was called with " + jasmine.pp(this.actual.argsForCall)
|
1341
|
+
"Expected spy " + this.actual.identity + " to have been called with " + jasmine.pp(expectedArgs) + " but was called with " + jasmine.pp(this.actual.argsForCall),
|
1342
|
+
"Expected spy " + this.actual.identity + " not to have been called with " + jasmine.pp(expectedArgs) + " but was called with " + jasmine.pp(this.actual.argsForCall)
|
1328
1343
|
];
|
1329
1344
|
}
|
1330
1345
|
};
|
@@ -1379,6 +1394,23 @@ jasmine.Matchers.prototype.toBeGreaterThan = function(expected) {
|
|
1379
1394
|
return this.actual > expected;
|
1380
1395
|
};
|
1381
1396
|
|
1397
|
+
/**
|
1398
|
+
* Matcher that checks that the expected item is equal to the actual item
|
1399
|
+
* up to a given level of decimal precision (default 2).
|
1400
|
+
*
|
1401
|
+
* @param {Number} expected
|
1402
|
+
* @param {Number} precision
|
1403
|
+
*/
|
1404
|
+
jasmine.Matchers.prototype.toBeCloseTo = function(expected, precision) {
|
1405
|
+
if (!(precision === 0)) {
|
1406
|
+
precision = precision || 2;
|
1407
|
+
}
|
1408
|
+
var multiplier = Math.pow(10, precision);
|
1409
|
+
var actual = Math.round(this.actual * multiplier);
|
1410
|
+
expected = Math.round(expected * multiplier);
|
1411
|
+
return expected == actual;
|
1412
|
+
};
|
1413
|
+
|
1382
1414
|
/**
|
1383
1415
|
* Matcher that checks that the expected exception was thrown by the actual.
|
1384
1416
|
*
|
@@ -1976,7 +2008,8 @@ jasmine.Spec.prototype.waitsFor = function(latchFunction, optional_timeoutMessag
|
|
1976
2008
|
jasmine.Spec.prototype.fail = function (e) {
|
1977
2009
|
var expectationResult = new jasmine.ExpectationResult({
|
1978
2010
|
passed: false,
|
1979
|
-
message: e ? jasmine.util.formatException(e) : 'Exception'
|
2011
|
+
message: e ? jasmine.util.formatException(e) : 'Exception',
|
2012
|
+
trace: { stack: e.stack }
|
1980
2013
|
});
|
1981
2014
|
this.results_.addResult(expectationResult);
|
1982
2015
|
};
|
@@ -2186,7 +2219,9 @@ jasmine.WaitsBlock = function(env, timeout, spec) {
|
|
2186
2219
|
jasmine.util.inherit(jasmine.WaitsBlock, jasmine.Block);
|
2187
2220
|
|
2188
2221
|
jasmine.WaitsBlock.prototype.execute = function (onComplete) {
|
2189
|
-
|
2222
|
+
if (jasmine.VERBOSE) {
|
2223
|
+
this.env.reporter.log('>> Jasmine waiting for ' + this.timeout + ' ms...');
|
2224
|
+
}
|
2190
2225
|
this.env.setTimeout(function () {
|
2191
2226
|
onComplete();
|
2192
2227
|
}, this.timeout);
|
@@ -2214,7 +2249,9 @@ jasmine.util.inherit(jasmine.WaitsForBlock, jasmine.Block);
|
|
2214
2249
|
jasmine.WaitsForBlock.TIMEOUT_INCREMENT = 10;
|
2215
2250
|
|
2216
2251
|
jasmine.WaitsForBlock.prototype.execute = function(onComplete) {
|
2217
|
-
|
2252
|
+
if (jasmine.VERBOSE) {
|
2253
|
+
this.env.reporter.log('>> Jasmine waiting for ' + (this.message || 'something to happen'));
|
2254
|
+
}
|
2218
2255
|
var latchFunctionResult;
|
2219
2256
|
try {
|
2220
2257
|
latchFunctionResult = this.latchFunction.apply(this.spec);
|
@@ -2429,7 +2466,7 @@ jasmine.getGlobal().clearInterval = function(timeoutKey) {
|
|
2429
2466
|
|
2430
2467
|
jasmine.version_= {
|
2431
2468
|
"major": 1,
|
2432
|
-
"minor":
|
2433
|
-
"build":
|
2434
|
-
"revision":
|
2469
|
+
"minor": 1,
|
2470
|
+
"build": 0,
|
2471
|
+
"revision": 1307546962
|
2435
2472
|
};
|
metadata
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: js-test-driver-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
prerelease:
|
5
|
-
version: 0.
|
4
|
+
prerelease: 6
|
5
|
+
version: 0.5.0.pre1
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Adam Pohorecki
|
@@ -10,7 +10,8 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-
|
13
|
+
date: 2011-06-09 00:00:00 +02:00
|
14
|
+
default_executable:
|
14
15
|
dependencies:
|
15
16
|
- !ruby/object:Gem::Dependency
|
16
17
|
name: json
|
@@ -35,7 +36,7 @@ dependencies:
|
|
35
36
|
type: :runtime
|
36
37
|
version_requirements: *id002
|
37
38
|
- !ruby/object:Gem::Dependency
|
38
|
-
name:
|
39
|
+
name: commander
|
39
40
|
prerelease: false
|
40
41
|
requirement: &id003 !ruby/object:Gem::Requirement
|
41
42
|
none: false
|
@@ -43,13 +44,35 @@ dependencies:
|
|
43
44
|
- - ">="
|
44
45
|
- !ruby/object:Gem::Version
|
45
46
|
version: "0"
|
46
|
-
type: :
|
47
|
+
type: :runtime
|
47
48
|
version_requirements: *id003
|
49
|
+
- !ruby/object:Gem::Dependency
|
50
|
+
name: selenium-webdriver
|
51
|
+
prerelease: false
|
52
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
53
|
+
none: false
|
54
|
+
requirements:
|
55
|
+
- - ">="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: "0"
|
58
|
+
type: :runtime
|
59
|
+
version_requirements: *id004
|
60
|
+
- !ruby/object:Gem::Dependency
|
61
|
+
name: mocha
|
62
|
+
prerelease: false
|
63
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
64
|
+
none: false
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: "0"
|
69
|
+
type: :development
|
70
|
+
version_requirements: *id005
|
48
71
|
description: Use ruby to configure JsTestDriver, capture browsers and run tests.
|
49
72
|
email:
|
50
73
|
- adam@pohorecki.pl
|
51
|
-
executables:
|
52
|
-
|
74
|
+
executables:
|
75
|
+
- jstd
|
53
76
|
extensions: []
|
54
77
|
|
55
78
|
extra_rdoc_files: []
|
@@ -62,11 +85,25 @@ files:
|
|
62
85
|
- LICENSE
|
63
86
|
- README.markdown
|
64
87
|
- Rakefile
|
88
|
+
- TODO
|
89
|
+
- bin/jstd
|
65
90
|
- js-test-driver-rails.gemspec
|
66
91
|
- lib/js_test_driver.rb
|
92
|
+
- lib/js_test_driver/application.rb
|
93
|
+
- lib/js_test_driver/cli/capture_browsers.rb
|
94
|
+
- lib/js_test_driver/cli/run.rb
|
95
|
+
- lib/js_test_driver/cli/run_tests.rb
|
96
|
+
- lib/js_test_driver/cli/start_server.rb
|
97
|
+
- lib/js_test_driver/commands/base_command.rb
|
98
|
+
- lib/js_test_driver/commands/generate_coverage_report.rb
|
99
|
+
- lib/js_test_driver/commands/jstd_jar_command.rb
|
67
100
|
- lib/js_test_driver/config.rb
|
101
|
+
- lib/js_test_driver/config_factory.rb
|
68
102
|
- lib/js_test_driver/html_fixture.rb
|
103
|
+
- lib/js_test_driver/missing_dependency_error.rb
|
104
|
+
- lib/js_test_driver/remote_browser.rb
|
69
105
|
- lib/js_test_driver/runner.rb
|
106
|
+
- lib/js_test_driver/runtime_config.rb
|
70
107
|
- lib/js_test_driver/tasks.rb
|
71
108
|
- lib/js_test_driver/version.rb
|
72
109
|
- test/fixtures/a.html
|
@@ -82,14 +119,19 @@ files:
|
|
82
119
|
- test/sample/specs/calculator_spec.js
|
83
120
|
- test/sample/specs/spec_helper.js
|
84
121
|
- test/test_helper.rb
|
122
|
+
- test/unit/capture_browsers_test.rb
|
85
123
|
- test/unit/config_test.rb
|
86
124
|
- test/unit/html_fixture_test.rb
|
87
|
-
- test/unit/
|
125
|
+
- test/unit/run_test.rb
|
126
|
+
- test/unit/run_tests_test.rb
|
127
|
+
- test/unit/runtime_config_test.rb
|
128
|
+
- test/unit/start_server_test.rb
|
88
129
|
- vendor/JasmineAdapter.js
|
89
130
|
- vendor/VERSIONS
|
90
131
|
- vendor/coverage.jar
|
91
132
|
- vendor/jasmine.js
|
92
133
|
- vendor/js_test_driver.jar
|
134
|
+
has_rdoc: true
|
93
135
|
homepage: http://github.com/psyho/js-test-driver-rails
|
94
136
|
licenses: []
|
95
137
|
|
@@ -107,13 +149,13 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
107
149
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
108
150
|
none: false
|
109
151
|
requirements:
|
110
|
-
- - "
|
152
|
+
- - ">"
|
111
153
|
- !ruby/object:Gem::Version
|
112
|
-
version:
|
154
|
+
version: 1.3.1
|
113
155
|
requirements: []
|
114
156
|
|
115
157
|
rubyforge_project: js-test-driver-rails
|
116
|
-
rubygems_version: 1.
|
158
|
+
rubygems_version: 1.6.2
|
117
159
|
signing_key:
|
118
160
|
specification_version: 3
|
119
161
|
summary: A wrapper for JsTestDriver for use with ruby/rails projects
|
data/test/unit/runner_test.rb
DELETED
@@ -1,107 +0,0 @@
|
|
1
|
-
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'test_helper'))
|
2
|
-
|
3
|
-
module JsTestDriver
|
4
|
-
class RunnerTest < Test::Unit::TestCase
|
5
|
-
|
6
|
-
def given_a_runner(opts = {})
|
7
|
-
return JsTestDriver::Runner.new(opts)
|
8
|
-
end
|
9
|
-
|
10
|
-
def test_should_have_default_config_path
|
11
|
-
# given
|
12
|
-
runner = given_a_runner
|
13
|
-
|
14
|
-
# then
|
15
|
-
assert runner.config_path
|
16
|
-
end
|
17
|
-
|
18
|
-
def test_should_have_default_jar_path
|
19
|
-
# given
|
20
|
-
runner = given_a_runner
|
21
|
-
|
22
|
-
# then
|
23
|
-
assert runner.jar_path
|
24
|
-
end
|
25
|
-
|
26
|
-
def test_should_have_default_tmp_path
|
27
|
-
# given
|
28
|
-
runner = given_a_runner
|
29
|
-
|
30
|
-
# then
|
31
|
-
assert runner.config_yml_path
|
32
|
-
end
|
33
|
-
|
34
|
-
def expect_command_to_be_executed(cmd)
|
35
|
-
JsTestDriver::Runner::Command.any_instance.expects(:system).with(cmd)
|
36
|
-
end
|
37
|
-
|
38
|
-
def expect_spawn(cmd)
|
39
|
-
JsTestDriver::Runner.any_instance.expects(:spawn).with(cmd)
|
40
|
-
end
|
41
|
-
|
42
|
-
def test_should_run_server_with_given_port_number
|
43
|
-
config = JsTestDriver::Config.new(:port => 6666)
|
44
|
-
runner = given_a_runner(:config => config)
|
45
|
-
|
46
|
-
expect_command_to_be_executed("java -jar #{runner.jar_path} --port #{config.port}")
|
47
|
-
|
48
|
-
runner.start_server
|
49
|
-
end
|
50
|
-
|
51
|
-
def test_should_run_all_tests_by_default
|
52
|
-
runner = given_a_runner(:config => JsTestDriver::Config.new)
|
53
|
-
|
54
|
-
expect_command_to_be_executed("java -jar #{runner.jar_path} --config #{runner.config_yml_path} --tests all")
|
55
|
-
|
56
|
-
runner.run_tests
|
57
|
-
end
|
58
|
-
|
59
|
-
def test_should_run_selected_tests
|
60
|
-
runner = given_a_runner(:config => JsTestDriver::Config.new)
|
61
|
-
|
62
|
-
expect_command_to_be_executed("java -jar #{runner.jar_path} --config #{runner.config_yml_path} --tests MyTestCase.some_test")
|
63
|
-
|
64
|
-
runner.run_tests('MyTestCase.some_test')
|
65
|
-
end
|
66
|
-
|
67
|
-
def test_should_capture_default_browsers
|
68
|
-
runner = given_a_runner(:config => JsTestDriver::Config.new(:browsers => ['foo', 'bar', 'baz']))
|
69
|
-
|
70
|
-
['foo', 'bar', 'baz'].each do |browser|
|
71
|
-
expect_spawn("#{browser} 'http://localhost:4224/capture'")
|
72
|
-
end
|
73
|
-
|
74
|
-
runner.capture_browsers
|
75
|
-
end
|
76
|
-
|
77
|
-
def test_should_capture_given_browsers
|
78
|
-
runner = given_a_runner(:config => JsTestDriver::Config.new(:browsers => ['foo', 'bar', 'baz']))
|
79
|
-
|
80
|
-
['aaa', 'bbb'].each do |browser|
|
81
|
-
expect_spawn("#{browser} 'http://localhost:4224/capture'")
|
82
|
-
end
|
83
|
-
|
84
|
-
runner.capture_browsers('aaa,bbb')
|
85
|
-
end
|
86
|
-
|
87
|
-
def test_should_run_with_all_arguments_at_once
|
88
|
-
runner = given_a_runner(:config => JsTestDriver::Config.new(:browsers => ['foo', 'bar', 'baz']))
|
89
|
-
|
90
|
-
expect_command_to_be_executed("java -jar #{runner.jar_path} --port 4224 --config #{runner.config_yml_path} --browser aaa,bbb --tests TestCase --testOutput #{File.expand_path('.js_test_driver')} --captureConsole")
|
91
|
-
|
92
|
-
runner.start_server_capture_and_run('TestCase', 'aaa,bbb', '.js_test_driver', true)
|
93
|
-
end
|
94
|
-
|
95
|
-
def test_when_measuring_coverage
|
96
|
-
config = JsTestDriver::Config.new
|
97
|
-
config.measure_coverage
|
98
|
-
runner = given_a_runner(:config => config)
|
99
|
-
|
100
|
-
JsTestDriver::Runner::Command.any_instance.expects(:system)
|
101
|
-
runner.expects(:system).with("genhtml -o #{File.expand_path('.js_test_driver/coverage')} #{File.expand_path('.js_test_driver/jsTestDriver.conf-coverage.dat')}")
|
102
|
-
|
103
|
-
runner.start_server_capture_and_run(nil, 'aaa', '.js_test_driver')
|
104
|
-
end
|
105
|
-
|
106
|
-
end
|
107
|
-
end
|