js-test-driver-rails 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (94) hide show
  1. data/Gemfile +2 -1
  2. data/README +40 -0
  3. data/Rakefile +1 -0
  4. data/VERSION +1 -1
  5. data/lib/js_test_driver.rb +5 -1
  6. data/lib/js_test_driver/config.rb +84 -7
  7. data/lib/js_test_driver/html_fixture.rb +40 -0
  8. data/lib/js_test_driver/runner.rb +21 -3
  9. data/test/fixtures/a.html +1 -0
  10. data/test/fixtures/b.html +1 -0
  11. data/test/fixtures/baz/a.html +1 -0
  12. data/test/fixtures/c.html +1 -0
  13. data/test/fixtures/foo/a.html +1 -0
  14. data/test/fixtures/foo/bar/a.html +1 -0
  15. data/test/fixtures/hello.txt +1 -0
  16. data/test/test_helper.rb +19 -0
  17. data/test/unit/config_test.rb +75 -2
  18. data/test/unit/html_fixture_test.rb +70 -0
  19. data/vendor/VERSIONS +3 -0
  20. data/vendor/jasmine-jstd-adapter/MIT.LICENSE +22 -0
  21. data/vendor/jasmine-jstd-adapter/README.md +25 -0
  22. data/vendor/jasmine-jstd-adapter/jsTestDriver.conf +6 -0
  23. data/vendor/jasmine-jstd-adapter/lib/jasmine/jasmine-0.11.1.js +2343 -0
  24. data/vendor/jasmine-jstd-adapter/lib/jstestdriver/JsTestDriver.jar +0 -0
  25. data/vendor/jasmine-jstd-adapter/server.sh +1 -0
  26. data/vendor/jasmine-jstd-adapter/src-test/tests.js +89 -0
  27. data/vendor/jasmine-jstd-adapter/src/JasmineAdapter.js +111 -0
  28. data/vendor/jasmine-jstd-adapter/test.sh +1 -0
  29. data/vendor/jasmine/Gemfile +6 -0
  30. data/vendor/jasmine/MIT.LICENSE +20 -0
  31. data/vendor/jasmine/README.markdown +28 -0
  32. data/vendor/jasmine/Rakefile +178 -0
  33. data/vendor/jasmine/cruise_config.rb +21 -0
  34. data/vendor/jasmine/example/SpecRunner.html +27 -0
  35. data/vendor/jasmine/example/spec/PlayerSpec.js +58 -0
  36. data/vendor/jasmine/example/spec/SpecHelper.js +9 -0
  37. data/vendor/jasmine/example/src/Player.js +22 -0
  38. data/vendor/jasmine/example/src/Song.js +7 -0
  39. data/vendor/jasmine/images/fail-16.png +0 -0
  40. data/vendor/jasmine/images/fail.png +0 -0
  41. data/vendor/jasmine/images/go-16.png +0 -0
  42. data/vendor/jasmine/images/go.png +0 -0
  43. data/vendor/jasmine/images/pending-16.png +0 -0
  44. data/vendor/jasmine/images/pending.png +0 -0
  45. data/vendor/jasmine/images/question-bk.png +0 -0
  46. data/vendor/jasmine/images/questionbk-16.png +0 -0
  47. data/vendor/jasmine/images/spinner.gif +0 -0
  48. data/vendor/jasmine/lib/jasmine-html.js +182 -0
  49. data/vendor/jasmine/lib/jasmine.css +166 -0
  50. data/vendor/jasmine/lib/jasmine.js +2421 -0
  51. data/vendor/jasmine/lib/json2.js +478 -0
  52. data/vendor/jasmine/spec/runner.html +80 -0
  53. data/vendor/jasmine/spec/suites/BaseSpec.js +27 -0
  54. data/vendor/jasmine/spec/suites/CustomMatchersSpec.js +97 -0
  55. data/vendor/jasmine/spec/suites/EnvSpec.js +158 -0
  56. data/vendor/jasmine/spec/suites/ExceptionsSpec.js +107 -0
  57. data/vendor/jasmine/spec/suites/JsApiReporterSpec.js +103 -0
  58. data/vendor/jasmine/spec/suites/MatchersSpec.js +795 -0
  59. data/vendor/jasmine/spec/suites/MockClockSpec.js +38 -0
  60. data/vendor/jasmine/spec/suites/MultiReporterSpec.js +45 -0
  61. data/vendor/jasmine/spec/suites/NestedResultsSpec.js +54 -0
  62. data/vendor/jasmine/spec/suites/PrettyPrintSpec.js +93 -0
  63. data/vendor/jasmine/spec/suites/QueueSpec.js +23 -0
  64. data/vendor/jasmine/spec/suites/ReporterSpec.js +56 -0
  65. data/vendor/jasmine/spec/suites/RunnerSpec.js +267 -0
  66. data/vendor/jasmine/spec/suites/SpecRunningSpec.js +1253 -0
  67. data/vendor/jasmine/spec/suites/SpecSpec.js +124 -0
  68. data/vendor/jasmine/spec/suites/SpySpec.js +201 -0
  69. data/vendor/jasmine/spec/suites/SuiteSpec.js +120 -0
  70. data/vendor/jasmine/spec/suites/TrivialReporterSpec.js +235 -0
  71. data/vendor/jasmine/spec/suites/UtilSpec.js +40 -0
  72. data/vendor/jasmine/spec/suites/WaitsForBlockSpec.js +87 -0
  73. data/vendor/jasmine/src/Block.js +22 -0
  74. data/vendor/jasmine/src/Env.js +264 -0
  75. data/vendor/jasmine/src/JsApiReporter.js +102 -0
  76. data/vendor/jasmine/src/Matchers.js +354 -0
  77. data/vendor/jasmine/src/MultiReporter.js +35 -0
  78. data/vendor/jasmine/src/NestedResults.js +80 -0
  79. data/vendor/jasmine/src/PrettyPrinter.js +122 -0
  80. data/vendor/jasmine/src/Queue.js +99 -0
  81. data/vendor/jasmine/src/Reporter.js +31 -0
  82. data/vendor/jasmine/src/Runner.js +77 -0
  83. data/vendor/jasmine/src/Spec.js +242 -0
  84. data/vendor/jasmine/src/Suite.js +82 -0
  85. data/vendor/jasmine/src/WaitsBlock.js +13 -0
  86. data/vendor/jasmine/src/WaitsForBlock.js +52 -0
  87. data/vendor/jasmine/src/base.js +589 -0
  88. data/vendor/jasmine/src/html/TrivialReporter.js +182 -0
  89. data/vendor/jasmine/src/html/jasmine.css +166 -0
  90. data/vendor/jasmine/src/mock-timeout.js +183 -0
  91. data/vendor/jasmine/src/util.js +67 -0
  92. data/vendor/jasmine/src/version.json +5 -0
  93. metadata +102 -5
  94. data/test/unit/jsTestDriver.conf +0 -2
@@ -0,0 +1,122 @@
1
+ /**
2
+ * Base class for pretty printing for expectation results.
3
+ */
4
+ jasmine.PrettyPrinter = function() {
5
+ this.ppNestLevel_ = 0;
6
+ };
7
+
8
+ /**
9
+ * Formats a value in a nice, human-readable string.
10
+ *
11
+ * @param value
12
+ */
13
+ jasmine.PrettyPrinter.prototype.format = function(value) {
14
+ if (this.ppNestLevel_ > 40) {
15
+ throw new Error('jasmine.PrettyPrinter: format() nested too deeply!');
16
+ }
17
+
18
+ this.ppNestLevel_++;
19
+ try {
20
+ if (value === jasmine.undefined) {
21
+ this.emitScalar('undefined');
22
+ } else if (value === null) {
23
+ this.emitScalar('null');
24
+ } else if (value === jasmine.getGlobal()) {
25
+ this.emitScalar('<global>');
26
+ } else if (value instanceof jasmine.Matchers.Any) {
27
+ this.emitScalar(value.toString());
28
+ } else if (typeof value === 'string') {
29
+ this.emitString(value);
30
+ } else if (jasmine.isSpy(value)) {
31
+ this.emitScalar("spy on " + value.identity);
32
+ } else if (value instanceof RegExp) {
33
+ this.emitScalar(value.toString());
34
+ } else if (typeof value === 'function') {
35
+ this.emitScalar('Function');
36
+ } else if (typeof value.nodeType === 'number') {
37
+ this.emitScalar('HTMLNode');
38
+ } else if (value instanceof Date) {
39
+ this.emitScalar('Date(' + value + ')');
40
+ } else if (value.__Jasmine_been_here_before__) {
41
+ this.emitScalar('<circular reference: ' + (jasmine.isArray_(value) ? 'Array' : 'Object') + '>');
42
+ } else if (jasmine.isArray_(value) || typeof value == 'object') {
43
+ value.__Jasmine_been_here_before__ = true;
44
+ if (jasmine.isArray_(value)) {
45
+ this.emitArray(value);
46
+ } else {
47
+ this.emitObject(value);
48
+ }
49
+ delete value.__Jasmine_been_here_before__;
50
+ } else {
51
+ this.emitScalar(value.toString());
52
+ }
53
+ } finally {
54
+ this.ppNestLevel_--;
55
+ }
56
+ };
57
+
58
+ jasmine.PrettyPrinter.prototype.iterateObject = function(obj, fn) {
59
+ for (var property in obj) {
60
+ if (property == '__Jasmine_been_here_before__') continue;
61
+ fn(property, obj.__lookupGetter__ ? (obj.__lookupGetter__(property) != null) : false);
62
+ }
63
+ };
64
+
65
+ jasmine.PrettyPrinter.prototype.emitArray = jasmine.unimplementedMethod_;
66
+ jasmine.PrettyPrinter.prototype.emitObject = jasmine.unimplementedMethod_;
67
+ jasmine.PrettyPrinter.prototype.emitScalar = jasmine.unimplementedMethod_;
68
+ jasmine.PrettyPrinter.prototype.emitString = jasmine.unimplementedMethod_;
69
+
70
+ jasmine.StringPrettyPrinter = function() {
71
+ jasmine.PrettyPrinter.call(this);
72
+
73
+ this.string = '';
74
+ };
75
+ jasmine.util.inherit(jasmine.StringPrettyPrinter, jasmine.PrettyPrinter);
76
+
77
+ jasmine.StringPrettyPrinter.prototype.emitScalar = function(value) {
78
+ this.append(value);
79
+ };
80
+
81
+ jasmine.StringPrettyPrinter.prototype.emitString = function(value) {
82
+ this.append("'" + value + "'");
83
+ };
84
+
85
+ jasmine.StringPrettyPrinter.prototype.emitArray = function(array) {
86
+ this.append('[ ');
87
+ for (var i = 0; i < array.length; i++) {
88
+ if (i > 0) {
89
+ this.append(', ');
90
+ }
91
+ this.format(array[i]);
92
+ }
93
+ this.append(' ]');
94
+ };
95
+
96
+ jasmine.StringPrettyPrinter.prototype.emitObject = function(obj) {
97
+ var self = this;
98
+ this.append('{ ');
99
+ var first = true;
100
+
101
+ this.iterateObject(obj, function(property, isGetter) {
102
+ if (first) {
103
+ first = false;
104
+ } else {
105
+ self.append(', ');
106
+ }
107
+
108
+ self.append(property);
109
+ self.append(' : ');
110
+ if (isGetter) {
111
+ self.append('<getter>');
112
+ } else {
113
+ self.format(obj[property]);
114
+ }
115
+ });
116
+
117
+ this.append(' }');
118
+ };
119
+
120
+ jasmine.StringPrettyPrinter.prototype.append = function(value) {
121
+ this.string += value;
122
+ };
@@ -0,0 +1,99 @@
1
+ jasmine.Queue = function(env) {
2
+ this.env = env;
3
+ this.blocks = [];
4
+ this.running = false;
5
+ this.index = 0;
6
+ this.offset = 0;
7
+ this.abort = false;
8
+ };
9
+
10
+ jasmine.Queue.prototype.addBefore = function(block) {
11
+ this.blocks.unshift(block);
12
+ };
13
+
14
+ jasmine.Queue.prototype.add = function(block) {
15
+ this.blocks.push(block);
16
+ };
17
+
18
+ jasmine.Queue.prototype.insertNext = function(block) {
19
+ this.blocks.splice((this.index + this.offset + 1), 0, block);
20
+ this.offset++;
21
+ };
22
+
23
+ jasmine.Queue.prototype.start = function(onComplete) {
24
+ this.running = true;
25
+ this.onComplete = onComplete;
26
+ this.next_();
27
+ };
28
+
29
+ jasmine.Queue.prototype.isRunning = function() {
30
+ return this.running;
31
+ };
32
+
33
+ jasmine.Queue.LOOP_DONT_RECURSE = true;
34
+
35
+ jasmine.Queue.prototype.next_ = function() {
36
+ var self = this;
37
+ var goAgain = true;
38
+
39
+ while (goAgain) {
40
+ goAgain = false;
41
+
42
+ if (self.index < self.blocks.length && !this.abort) {
43
+ var calledSynchronously = true;
44
+ var completedSynchronously = false;
45
+
46
+ var onComplete = function () {
47
+ if (jasmine.Queue.LOOP_DONT_RECURSE && calledSynchronously) {
48
+ completedSynchronously = true;
49
+ return;
50
+ }
51
+
52
+ if (self.blocks[self.index].abort) {
53
+ self.abort = true;
54
+ }
55
+
56
+ self.offset = 0;
57
+ self.index++;
58
+
59
+ var now = new Date().getTime();
60
+ if (self.env.updateInterval && now - self.env.lastUpdate > self.env.updateInterval) {
61
+ self.env.lastUpdate = now;
62
+ self.env.setTimeout(function() {
63
+ self.next_();
64
+ }, 0);
65
+ } else {
66
+ if (jasmine.Queue.LOOP_DONT_RECURSE && completedSynchronously) {
67
+ goAgain = true;
68
+ } else {
69
+ self.next_();
70
+ }
71
+ }
72
+ };
73
+ self.blocks[self.index].execute(onComplete);
74
+
75
+ calledSynchronously = false;
76
+ if (completedSynchronously) {
77
+ onComplete();
78
+ }
79
+
80
+ } else {
81
+ self.running = false;
82
+ if (self.onComplete) {
83
+ self.onComplete();
84
+ }
85
+ }
86
+ }
87
+ };
88
+
89
+ jasmine.Queue.prototype.results = function() {
90
+ var results = new jasmine.NestedResults();
91
+ for (var i = 0; i < this.blocks.length; i++) {
92
+ if (this.blocks[i].results) {
93
+ results.addResult(this.blocks[i].results());
94
+ }
95
+ }
96
+ return results;
97
+ };
98
+
99
+
@@ -0,0 +1,31 @@
1
+ /** No-op base class for Jasmine reporters.
2
+ *
3
+ * @constructor
4
+ */
5
+ jasmine.Reporter = function() {
6
+ };
7
+
8
+ //noinspection JSUnusedLocalSymbols
9
+ jasmine.Reporter.prototype.reportRunnerStarting = function(runner) {
10
+ };
11
+
12
+ //noinspection JSUnusedLocalSymbols
13
+ jasmine.Reporter.prototype.reportRunnerResults = function(runner) {
14
+ };
15
+
16
+ //noinspection JSUnusedLocalSymbols
17
+ jasmine.Reporter.prototype.reportSuiteResults = function(suite) {
18
+ };
19
+
20
+ //noinspection JSUnusedLocalSymbols
21
+ jasmine.Reporter.prototype.reportSpecStarting = function(spec) {
22
+ };
23
+
24
+ //noinspection JSUnusedLocalSymbols
25
+ jasmine.Reporter.prototype.reportSpecResults = function(spec) {
26
+ };
27
+
28
+ //noinspection JSUnusedLocalSymbols
29
+ jasmine.Reporter.prototype.log = function(str) {
30
+ };
31
+
@@ -0,0 +1,77 @@
1
+ /**
2
+ * Runner
3
+ *
4
+ * @constructor
5
+ * @param {jasmine.Env} env
6
+ */
7
+ jasmine.Runner = function(env) {
8
+ var self = this;
9
+ self.env = env;
10
+ self.queue = new jasmine.Queue(env);
11
+ self.before_ = [];
12
+ self.after_ = [];
13
+ self.suites_ = [];
14
+ };
15
+
16
+ jasmine.Runner.prototype.execute = function() {
17
+ var self = this;
18
+ if (self.env.reporter.reportRunnerStarting) {
19
+ self.env.reporter.reportRunnerStarting(this);
20
+ }
21
+ self.queue.start(function () {
22
+ self.finishCallback();
23
+ });
24
+ };
25
+
26
+ jasmine.Runner.prototype.beforeEach = function(beforeEachFunction) {
27
+ beforeEachFunction.typeName = 'beforeEach';
28
+ this.before_.splice(0,0,beforeEachFunction);
29
+ };
30
+
31
+ jasmine.Runner.prototype.afterEach = function(afterEachFunction) {
32
+ afterEachFunction.typeName = 'afterEach';
33
+ this.after_.splice(0,0,afterEachFunction);
34
+ };
35
+
36
+
37
+ jasmine.Runner.prototype.finishCallback = function() {
38
+ this.env.reporter.reportRunnerResults(this);
39
+ };
40
+
41
+ jasmine.Runner.prototype.addSuite = function(suite) {
42
+ this.suites_.push(suite);
43
+ };
44
+
45
+ jasmine.Runner.prototype.add = function(block) {
46
+ if (block instanceof jasmine.Suite) {
47
+ this.addSuite(block);
48
+ }
49
+ this.queue.add(block);
50
+ };
51
+
52
+ jasmine.Runner.prototype.specs = function () {
53
+ var suites = this.suites();
54
+ var specs = [];
55
+ for (var i = 0; i < suites.length; i++) {
56
+ specs = specs.concat(suites[i].specs());
57
+ }
58
+ return specs;
59
+ };
60
+
61
+ jasmine.Runner.prototype.suites = function() {
62
+ return this.suites_;
63
+ };
64
+
65
+ jasmine.Runner.prototype.topLevelSuites = function() {
66
+ var topLevelSuites = [];
67
+ for (var i = 0; i < this.suites_.length; i++) {
68
+ if (!this.suites_[i].parentSuite) {
69
+ topLevelSuites.push(this.suites_[i]);
70
+ }
71
+ }
72
+ return topLevelSuites;
73
+ };
74
+
75
+ jasmine.Runner.prototype.results = function() {
76
+ return this.queue.results();
77
+ };
@@ -0,0 +1,242 @@
1
+ /**
2
+ * Internal representation of a Jasmine specification, or test.
3
+ *
4
+ * @constructor
5
+ * @param {jasmine.Env} env
6
+ * @param {jasmine.Suite} suite
7
+ * @param {String} description
8
+ */
9
+ jasmine.Spec = function(env, suite, description) {
10
+ if (!env) {
11
+ throw new Error('jasmine.Env() required');
12
+ }
13
+ if (!suite) {
14
+ throw new Error('jasmine.Suite() required');
15
+ }
16
+ var spec = this;
17
+ spec.id = env.nextSpecId ? env.nextSpecId() : null;
18
+ spec.env = env;
19
+ spec.suite = suite;
20
+ spec.description = description;
21
+ spec.queue = new jasmine.Queue(env);
22
+
23
+ spec.afterCallbacks = [];
24
+ spec.spies_ = [];
25
+
26
+ spec.results_ = new jasmine.NestedResults();
27
+ spec.results_.description = description;
28
+ spec.matchersClass = null;
29
+ };
30
+
31
+ jasmine.Spec.prototype.getFullName = function() {
32
+ return this.suite.getFullName() + ' ' + this.description + '.';
33
+ };
34
+
35
+
36
+ jasmine.Spec.prototype.results = function() {
37
+ return this.results_;
38
+ };
39
+
40
+ /**
41
+ * All parameters are pretty-printed and concatenated together, then written to the spec's output.
42
+ *
43
+ * Be careful not to leave calls to <code>jasmine.log</code> in production code.
44
+ */
45
+ jasmine.Spec.prototype.log = function() {
46
+ return this.results_.log(arguments);
47
+ };
48
+
49
+ jasmine.Spec.prototype.runs = function (func) {
50
+ var block = new jasmine.Block(this.env, func, this);
51
+ this.addToQueue(block);
52
+ return this;
53
+ };
54
+
55
+ jasmine.Spec.prototype.addToQueue = function (block) {
56
+ if (this.queue.isRunning()) {
57
+ this.queue.insertNext(block);
58
+ } else {
59
+ this.queue.add(block);
60
+ }
61
+ };
62
+
63
+ /**
64
+ * @param {jasmine.ExpectationResult} result
65
+ */
66
+ jasmine.Spec.prototype.addMatcherResult = function(result) {
67
+ this.results_.addResult(result);
68
+ };
69
+
70
+ jasmine.Spec.prototype.expect = function(actual) {
71
+ var positive = new (this.getMatchersClass_())(this.env, actual, this);
72
+ positive.not = new (this.getMatchersClass_())(this.env, actual, this, true);
73
+ return positive;
74
+ };
75
+
76
+ /**
77
+ * Waits a fixed time period before moving to the next block.
78
+ *
79
+ * @deprecated Use waitsFor() instead
80
+ * @param {Number} timeout milliseconds to wait
81
+ */
82
+ jasmine.Spec.prototype.waits = function(timeout) {
83
+ var waitsFunc = new jasmine.WaitsBlock(this.env, timeout, this);
84
+ this.addToQueue(waitsFunc);
85
+ return this;
86
+ };
87
+
88
+ /**
89
+ * Waits for the latchFunction to return true before proceeding to the next block.
90
+ *
91
+ * @param {Function} latchFunction
92
+ * @param {String} optional_timeoutMessage
93
+ * @param {Number} optional_timeout
94
+ */
95
+ jasmine.Spec.prototype.waitsFor = function(latchFunction, optional_timeoutMessage, optional_timeout) {
96
+ var latchFunction_ = null;
97
+ var optional_timeoutMessage_ = null;
98
+ var optional_timeout_ = null;
99
+
100
+ for (var i = 0; i < arguments.length; i++) {
101
+ var arg = arguments[i];
102
+ switch (typeof arg) {
103
+ case 'function':
104
+ latchFunction_ = arg;
105
+ break;
106
+ case 'string':
107
+ optional_timeoutMessage_ = arg;
108
+ break;
109
+ case 'number':
110
+ optional_timeout_ = arg;
111
+ break;
112
+ }
113
+ }
114
+
115
+ var waitsForFunc = new jasmine.WaitsForBlock(this.env, optional_timeout_, latchFunction_, optional_timeoutMessage_, this);
116
+ this.addToQueue(waitsForFunc);
117
+ return this;
118
+ };
119
+
120
+ jasmine.Spec.prototype.fail = function (e) {
121
+ var expectationResult = new jasmine.ExpectationResult({
122
+ passed: false,
123
+ message: e ? jasmine.util.formatException(e) : 'Exception'
124
+ });
125
+ this.results_.addResult(expectationResult);
126
+ };
127
+
128
+ jasmine.Spec.prototype.getMatchersClass_ = function() {
129
+ return this.matchersClass || this.env.matchersClass;
130
+ };
131
+
132
+ jasmine.Spec.prototype.addMatchers = function(matchersPrototype) {
133
+ var parent = this.getMatchersClass_();
134
+ var newMatchersClass = function() {
135
+ parent.apply(this, arguments);
136
+ };
137
+ jasmine.util.inherit(newMatchersClass, parent);
138
+ jasmine.Matchers.wrapInto_(matchersPrototype, newMatchersClass);
139
+ this.matchersClass = newMatchersClass;
140
+ };
141
+
142
+ jasmine.Spec.prototype.finishCallback = function() {
143
+ this.env.reporter.reportSpecResults(this);
144
+ };
145
+
146
+ jasmine.Spec.prototype.finish = function(onComplete) {
147
+ this.removeAllSpies();
148
+ this.finishCallback();
149
+ if (onComplete) {
150
+ onComplete();
151
+ }
152
+ };
153
+
154
+ jasmine.Spec.prototype.after = function(doAfter) {
155
+ if (this.queue.isRunning()) {
156
+ this.queue.add(new jasmine.Block(this.env, doAfter, this));
157
+ } else {
158
+ this.afterCallbacks.unshift(doAfter);
159
+ }
160
+ };
161
+
162
+ jasmine.Spec.prototype.execute = function(onComplete) {
163
+ var spec = this;
164
+ if (!spec.env.specFilter(spec)) {
165
+ spec.results_.skipped = true;
166
+ spec.finish(onComplete);
167
+ return;
168
+ }
169
+
170
+ this.env.reporter.reportSpecStarting(this);
171
+
172
+ spec.env.currentSpec = spec;
173
+
174
+ spec.addBeforesAndAftersToQueue();
175
+
176
+ spec.queue.start(function () {
177
+ spec.finish(onComplete);
178
+ });
179
+ };
180
+
181
+ jasmine.Spec.prototype.addBeforesAndAftersToQueue = function() {
182
+ var runner = this.env.currentRunner();
183
+ var i;
184
+
185
+ for (var suite = this.suite; suite; suite = suite.parentSuite) {
186
+ for (i = 0; i < suite.before_.length; i++) {
187
+ this.queue.addBefore(new jasmine.Block(this.env, suite.before_[i], this));
188
+ }
189
+ }
190
+ for (i = 0; i < runner.before_.length; i++) {
191
+ this.queue.addBefore(new jasmine.Block(this.env, runner.before_[i], this));
192
+ }
193
+ for (i = 0; i < this.afterCallbacks.length; i++) {
194
+ this.queue.add(new jasmine.Block(this.env, this.afterCallbacks[i], this));
195
+ }
196
+ for (suite = this.suite; suite; suite = suite.parentSuite) {
197
+ for (i = 0; i < suite.after_.length; i++) {
198
+ this.queue.add(new jasmine.Block(this.env, suite.after_[i], this));
199
+ }
200
+ }
201
+ for (i = 0; i < runner.after_.length; i++) {
202
+ this.queue.add(new jasmine.Block(this.env, runner.after_[i], this));
203
+ }
204
+ };
205
+
206
+ jasmine.Spec.prototype.explodes = function() {
207
+ throw 'explodes function should not have been called';
208
+ };
209
+
210
+ jasmine.Spec.prototype.spyOn = function(obj, methodName, ignoreMethodDoesntExist) {
211
+ if (obj == jasmine.undefined) {
212
+ throw "spyOn could not find an object to spy upon for " + methodName + "()";
213
+ }
214
+
215
+ if (!ignoreMethodDoesntExist && obj[methodName] === jasmine.undefined) {
216
+ throw methodName + '() method does not exist';
217
+ }
218
+
219
+ if (!ignoreMethodDoesntExist && obj[methodName] && obj[methodName].isSpy) {
220
+ throw new Error(methodName + ' has already been spied upon');
221
+ }
222
+
223
+ var spyObj = jasmine.createSpy(methodName);
224
+
225
+ this.spies_.push(spyObj);
226
+ spyObj.baseObj = obj;
227
+ spyObj.methodName = methodName;
228
+ spyObj.originalValue = obj[methodName];
229
+
230
+ obj[methodName] = spyObj;
231
+
232
+ return spyObj;
233
+ };
234
+
235
+ jasmine.Spec.prototype.removeAllSpies = function() {
236
+ for (var i = 0; i < this.spies_.length; i++) {
237
+ var spy = this.spies_[i];
238
+ spy.baseObj[spy.methodName] = spy.originalValue;
239
+ }
240
+ this.spies_ = [];
241
+ };
242
+