js-test-driver-rails 0.4.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitmodules CHANGED
@@ -1,6 +1,6 @@
1
- [submodule "vendor/jasmine-jstd-adapter"]
2
- path = vendor/jasmine-jstd-adapter
3
- url = git://github.com/mhevery/jasmine-jstd-adapter.git
4
1
  [submodule "vendor/jasmine"]
5
2
  path = vendor/jasmine
6
3
  url = git://github.com/pivotal/jasmine.git
4
+ [submodule "vendor/jasmine-jstd-adapter"]
5
+ path = vendor/jasmine-jstd-adapter
6
+ url = git://github.com/ibolmo/jasmine-jstd-adapter.git
@@ -1,3 +1,3 @@
1
1
  module JsTestDriver
2
- VERSION = "0.4.0"
2
+ VERSION = "0.4.1"
3
3
  end
@@ -1,186 +1,179 @@
1
1
  /**
2
2
  * @fileoverview Jasmine JsTestDriver Adapter.
3
3
  * @author misko@hevery.com (Misko Hevery)
4
+ * @author olmo.maldonado@gmail.com (Olmo Maldonado)
4
5
  */
5
- (function(window) {
6
- var rootDescribes = new Describes(window);
7
- var describePath = [];
8
- rootDescribes.collectMode();
9
-
10
- var jasmineTest = TestCase('Jasmine Adapter Tests', null, 'jasmine test case');
11
-
12
- var jasminePlugin = {
13
- name:'jasmine',
14
- runTestConfiguration: function(testRunConfiguration, onTestDone, onTestRunConfigurationComplete){
15
- if (testRunConfiguration.testCaseInfo_.template_ !== jasmineTest) return;
16
-
17
- var jasmineEnv = jasmine.currentEnv_ = new jasmine.Env();
18
- rootDescribes.playback();
19
- var specLog = jstestdriver.console.log_ = [];
20
- var start;
21
- jasmineEnv.specFilter = function(spec) {
22
- return rootDescribes.isExclusive(spec);
23
- };
24
- jasmineEnv.reporter = {
25
- log: function(str){
26
- specLog.push(str);
27
- },
28
-
29
- reportRunnerStarting: function(runner) { },
30
-
31
- reportSpecStarting: function(spec) {
32
- specLog = jstestdriver.console.log_ = [];
33
- start = new Date().getTime();
34
- },
35
-
36
- reportSpecResults: function(spec) {
37
- var suite = spec.suite;
38
- var results = spec.results();
39
- if (results.skipped) return;
40
- var end = new Date().getTime();
41
- var messages = [];
42
- var resultItems = results.getItems();
43
- var state = 'passed';
44
- for ( var i = 0; i < resultItems.length; i++) {
45
- if (!resultItems[i].passed()) {
46
- state = resultItems[i].message.match(/AssertionError:/) ? 'error' : 'failed';
47
- messages.push({
48
- message: resultItems[i].toString(),
49
- name: resultItems[i].trace.name,
50
- stack: formatStack(resultItems[i].trace.stack)
51
- });
52
- }
53
- }
54
- onTestDone(
55
- new jstestdriver.TestResult(
56
- suite.getFullName(),
57
- spec.description,
58
- state,
59
- jstestdriver.angular.toJson(messages),
60
- specLog.join('\n'),
61
- end - start));
62
- },
63
-
64
- reportSuiteResults: function(suite) {},
65
-
66
- reportRunnerResults: function(runner) {
67
- onTestRunConfigurationComplete();
68
- }
69
- };
70
- jasmineEnv.execute();
71
- return true;
72
- },
73
- onTestsFinish: function(){
74
- jasmine.currentEnv_ = null;
75
- rootDescribes.collectMode();
76
- }
77
- };
78
- jstestdriver.pluginRegistrar.register(jasminePlugin);
79
-
80
- function formatStack(stack) {
81
- var lines = (stack||'').split(/\r?\n/);
82
- var frames = [];
83
- for (i = 0; i < lines.length; i++) {
84
- if (!lines[i].match(/\/jasmine[\.-]/)) {
85
- frames.push(lines[i].replace(/https?:\/\/\w+(:\d+)?\/test\//, '').replace(/^\s*/, ' '));
86
- }
87
- }
88
- return frames.join('\n');
89
- }
90
-
91
- function noop(){}
92
- function Describes(window){
93
- var describes = {};
94
- var beforeEachs = {};
95
- var afterEachs = {};
96
- // Here we store:
97
- // 0: everyone runs
98
- // 1: run everything under ddescribe
99
- // 2: run only iits (ignore ddescribe)
100
- var exclusive = 0;
101
- var collectMode = true;
102
- intercept('describe', describes);
103
- intercept('xdescribe', describes);
104
- intercept('beforeEach', beforeEachs);
105
- intercept('afterEach', afterEachs);
106
-
107
- function intercept(functionName, collection){
108
- window[functionName] = function(desc, fn){
109
- if (collectMode) {
110
- collection[desc] = function(){
111
- jasmine.getEnv()[functionName](desc, fn);
112
- };
113
- } else {
114
- jasmine.getEnv()[functionName](desc, fn);
115
- }
116
- };
117
- }
118
- window.ddescribe = function(name, fn){
119
- if (exclusive < 1) {
120
- exclusive = 1; // run ddescribe only
121
- }
122
- window.describe(name, function(){
123
- var oldIt = window.it;
124
- window.it = function(name, fn){
125
- fn.exclusive = 1; // run anything under ddescribe
126
- jasmine.getEnv().it(name, fn);
127
- };
128
- try {
129
- fn.call(this);
130
- } finally {
131
- window.it = oldIt;
132
- };
133
- });
134
- };
135
- window.iit = function(name, fn){
136
- exclusive = fn.exclusive = 2; // run only iits
137
- jasmine.getEnv().it(name, fn);
138
- };
139
-
140
-
141
- this.collectMode = function() {
142
- collectMode = true;
143
- exclusive = 0; // run everything
144
- };
145
- this.playback = function(){
146
- collectMode = false;
147
- playback(beforeEachs);
148
- playback(afterEachs);
149
- playback(describes);
150
-
151
- function playback(set) {
152
- for ( var name in set) {
153
- set[name]();
154
- }
155
- }
156
- };
157
-
158
- this.isExclusive = function(spec) {
159
- if (exclusive) {
160
- var blocks = spec.queue.blocks;
161
- for ( var i = 0; i < blocks.length; i++) {
162
- if (blocks[i].func.exclusive >= exclusive) {
163
- return true;
164
- }
165
- }
166
- return false;
167
- }
168
- return true;
169
- };
170
- }
171
-
172
- })(window);
6
+ (function(){
7
+
8
+
9
+ var Env = function(onTestDone, onComplete){
10
+ jasmine.Env.call(this);
11
+
12
+ this.specFilter = function(spec){
13
+ if (!this.exclusive) return true;
14
+ var blocks = spec.queue.blocks, l = blocks.length;
15
+ for (var i = 0; i < l; i++) if (blocks[i].func.exclusive >= this.exclusive) return true;
16
+ return false;
17
+ };
18
+
19
+ this.reporter = new Reporter(onTestDone, onComplete);
20
+ };
21
+ jasmine.util.inherit(Env, jasmine.Env);
22
+
23
+ // Here we store:
24
+ // 0: everyone runs
25
+ // 1: run everything under ddescribe
26
+ // 2: run only iits (ignore ddescribe)
27
+ Env.prototype.exclusive = 0;
28
+
29
+
30
+ Env.prototype.execute = function(){
31
+ collectMode = false;
32
+ playback();
33
+ jasmine.Env.prototype.execute.call(this);
34
+ };
35
+
36
+
37
+ var Reporter = function(onTestDone, onComplete){
38
+ this.onTestDone = onTestDone;
39
+ this.onComplete = onComplete;
40
+ this.reset();
41
+ };
42
+ jasmine.util.inherit(Reporter, jasmine.Reporter);
43
+
44
+
45
+ Reporter.formatStack = function(stack) {
46
+ var line, lines = (stack || '').split(/\r?\n/), l = lines.length, frames = [];
47
+ for (var i = 0; i < l; i++){
48
+ line = lines[i];
49
+ if (line.match(/\/jasmine[\.-]/)) continue;
50
+ frames.push(line.replace(/https?:\/\/\w+(:\d+)?\/test\//, '').replace(/^\s*/, ' '));
51
+ }
52
+ return frames.join('\n');
53
+ };
54
+
55
+
56
+ Reporter.prototype.reset = function(){
57
+ this.specLog = jstestdriver.console.log_ = [];
58
+ };
59
+
60
+
61
+ Reporter.prototype.log = function(str){
62
+ this.specLog.push(str);
63
+ };
64
+
65
+
66
+ Reporter.prototype.reportSpecStarting = function(){
67
+ this.reset();
68
+ this.start = +new Date();
69
+ };
70
+
71
+
72
+ Reporter.prototype.reportSpecResults = function(spec){
73
+ var elapsed = +new Date() - this.start, results = spec.results();
74
+
75
+ if (results.skipped) return;
76
+
77
+ var item, state = 'passed', items = results.getItems(), l = items.length, messages = [];
78
+ for (var i = 0; i < l; i++){
79
+ item = items[i];
80
+ if (item.passed()) continue;
81
+ state = (item.message.indexOf('AssertionError:') != -1) ? 'error' : 'failed';
82
+ messages.push({
83
+ message: item + '',
84
+ name: item.trace.name,
85
+ stack: Reporter.formatStack(item.trace.stack)
86
+ });
87
+ }
88
+
89
+ this.onTestDone(new jstestdriver.TestResult(
90
+ spec.suite.getFullName(),
91
+ spec.description,
92
+ state,
93
+ jstestdriver.angular.toJson(messages),
94
+ this.specLog.join('\n'),
95
+ elapsed
96
+ ));
97
+ };
98
+
99
+
100
+ Reporter.prototype.reportRunnerResults = function(){
101
+ this.onComplete();
102
+ };
103
+
104
+
105
+ var collectMode = true, intercepted = {};
106
+
107
+ describe = intercept('describe');
108
+ beforeEach = intercept('beforeEach');
109
+ afterEach = intercept('afterEach');
110
+
111
+ var template = TestCase('Jasmine Adapter Tests', null, 'jasmine test case');
112
+
113
+ jstestdriver.pluginRegistrar.register({
114
+
115
+ name: 'jasmine',
116
+
117
+ runTestConfiguration: function(config, onTestDone, onComplete){
118
+ if (config.testCaseInfo_.template_ !== template) return;
119
+ (jasmine.currentEnv_ = new Env(onTestDone, onComplete)).execute();
120
+ return true;
121
+ },
122
+
123
+ onTestsFinish: function(){
124
+ jasmine.currentEnv_ = null;
125
+ collectMode = true;
126
+ }
127
+
128
+ });
129
+
130
+ function intercept(method){
131
+ var bucket = intercepted[method] = [], method = window[method];
132
+ return function(desc, fn){
133
+ if (collectMode) bucket.push(function(){ method(desc, fn); });
134
+ else method(desc, fn);
135
+ };
136
+ }
137
+
138
+ function playback(){
139
+ for (var method in intercepted){
140
+ var bucket = intercepted[method];
141
+ for (var i = 0, l = bucket.length; i < l; i++) bucket[i]();
142
+ }
143
+ }
144
+
145
+ })();
146
+
147
+ var ddescribe = function(name, fn){
148
+ var env = jasmine.getEnv();
149
+ if (!env.exclusive) env.exclusive = 1; // run ddescribe only
150
+ describe(name, function(){
151
+ var oldIt = it;
152
+ it = function(name, fn){
153
+ fn.exclusive = 1; // run anything under ddescribe
154
+ env.it(name, fn);
155
+ };
156
+
157
+ try {
158
+ fn.call(this);
159
+ } finally {
160
+ it = oldIt;
161
+ };
162
+ });
163
+ };
164
+
165
+ var iit = function(name, fn){
166
+ var env = jasmine.getEnv();
167
+ env.exclusive = fn.exclusive = 2; // run only iits
168
+ env.it(name, fn);
169
+ };
173
170
 
174
171
  // Patch Jasmine for proper stack traces
175
172
  jasmine.Spec.prototype.fail = function (e) {
176
- var expectationResult = new jasmine.ExpectationResult({
177
- passed: false,
178
- message: e ? jasmine.util.formatException(e) : 'Exception'
179
- });
180
- // PATCH
181
- if (e) {
182
- expectationResult.trace = e;
183
- }
184
- this.results_.addResult(expectationResult);
173
+ var result = new jasmine.ExpectationResult({
174
+ passed: false,
175
+ message: e ? jasmine.util.formatException(e) : 'Exception'
176
+ });
177
+ if(e) result.trace = e;
178
+ this.results_.addResult(result);
185
179
  };
186
-
metadata CHANGED
@@ -1,12 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: js-test-driver-rails
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 0
7
- - 4
8
- - 0
9
- version: 0.4.0
4
+ prerelease:
5
+ version: 0.4.1
10
6
  platform: ruby
11
7
  authors:
12
8
  - Adam Pohorecki
@@ -14,8 +10,7 @@ autorequire:
14
10
  bindir: bin
15
11
  cert_chain: []
16
12
 
17
- date: 2011-04-27 00:00:00 +02:00
18
- default_executable:
13
+ date: 2011-04-29 00:00:00 Z
19
14
  dependencies:
20
15
  - !ruby/object:Gem::Dependency
21
16
  name: json
@@ -25,8 +20,6 @@ dependencies:
25
20
  requirements:
26
21
  - - ">="
27
22
  - !ruby/object:Gem::Version
28
- segments:
29
- - 0
30
23
  version: "0"
31
24
  type: :runtime
32
25
  version_requirements: *id001
@@ -38,8 +31,6 @@ dependencies:
38
31
  requirements:
39
32
  - - ">="
40
33
  - !ruby/object:Gem::Version
41
- segments:
42
- - 0
43
34
  version: "0"
44
35
  type: :runtime
45
36
  version_requirements: *id002
@@ -51,8 +42,6 @@ dependencies:
51
42
  requirements:
52
43
  - - ">="
53
44
  - !ruby/object:Gem::Version
54
- segments:
55
- - 0
56
45
  version: "0"
57
46
  type: :development
58
47
  version_requirements: *id003
@@ -101,7 +90,6 @@ files:
101
90
  - vendor/coverage.jar
102
91
  - vendor/jasmine.js
103
92
  - vendor/js_test_driver.jar
104
- has_rdoc: true
105
93
  homepage: http://github.com/psyho/js-test-driver-rails
106
94
  licenses: []
107
95
 
@@ -115,21 +103,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
115
103
  requirements:
116
104
  - - ">="
117
105
  - !ruby/object:Gem::Version
118
- segments:
119
- - 0
120
106
  version: "0"
121
107
  required_rubygems_version: !ruby/object:Gem::Requirement
122
108
  none: false
123
109
  requirements:
124
110
  - - ">="
125
111
  - !ruby/object:Gem::Version
126
- segments:
127
- - 0
128
112
  version: "0"
129
113
  requirements: []
130
114
 
131
115
  rubyforge_project: js-test-driver-rails
132
- rubygems_version: 1.3.7
116
+ rubygems_version: 1.7.2
133
117
  signing_key:
134
118
  specification_version: 3
135
119
  summary: A wrapper for JsTestDriver for use with ruby/rails projects