evergreen 0.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (104) hide show
  1. data/README.rdoc +101 -3
  2. data/bin/evergreen +2 -2
  3. data/lib/evergreen.rb +14 -2
  4. data/lib/evergreen/evergreen.js +23 -0
  5. data/lib/evergreen/rails.rb +8 -0
  6. data/lib/evergreen/runner.rb +21 -14
  7. data/lib/evergreen/spec.rb +12 -33
  8. data/lib/evergreen/version.rb +1 -1
  9. data/lib/evergreen/views/list.erb +1 -1
  10. data/lib/evergreen/views/spec.erb +9 -22
  11. data/lib/jasmine/README.markdown +21 -28
  12. data/lib/jasmine/Rakefile +98 -68
  13. data/lib/jasmine/example/SpecRunner.html +27 -0
  14. data/lib/jasmine/example/spec/PlayerSpec.js +58 -0
  15. data/lib/jasmine/example/spec/SpecHelper.js +9 -0
  16. data/lib/jasmine/example/src/Player.js +22 -0
  17. data/lib/jasmine/example/src/Song.js +7 -0
  18. data/lib/jasmine/lib/jasmine-html.js +182 -0
  19. data/lib/jasmine/lib/{jasmine-0.10.4.js → jasmine.js} +127 -155
  20. data/lib/jasmine/spec/runner.html +4 -3
  21. data/lib/jasmine/spec/suites/BaseSpec.js +27 -0
  22. data/lib/jasmine/spec/suites/CustomMatchersSpec.js +0 -24
  23. data/lib/jasmine/spec/suites/EnvSpec.js +1 -1
  24. data/lib/jasmine/spec/suites/JsApiReporterSpec.js +16 -9
  25. data/lib/jasmine/spec/suites/MatchersSpec.js +49 -42
  26. data/lib/jasmine/spec/suites/MockClockSpec.js +4 -0
  27. data/lib/jasmine/spec/suites/MultiReporterSpec.js +23 -8
  28. data/lib/jasmine/spec/suites/PrettyPrintSpec.js +2 -2
  29. data/lib/jasmine/spec/suites/ReporterSpec.js +10 -14
  30. data/lib/jasmine/spec/suites/RunnerSpec.js +6 -6
  31. data/lib/jasmine/spec/suites/SpecRunningSpec.js +1 -1
  32. data/lib/jasmine/spec/suites/SpecSpec.js +15 -1
  33. data/lib/jasmine/spec/suites/SpySpec.js +3 -3
  34. data/lib/jasmine/spec/suites/TrivialReporterSpec.js +91 -14
  35. data/lib/jasmine/spec/suites/WaitsForBlockSpec.js +5 -6
  36. data/lib/jasmine/src/JsApiReporter.js +4 -6
  37. data/lib/jasmine/src/Matchers.js +19 -19
  38. data/lib/jasmine/src/MultiReporter.js +8 -1
  39. data/lib/jasmine/src/NestedResults.js +5 -5
  40. data/lib/jasmine/src/PrettyPrinter.js +2 -2
  41. data/lib/jasmine/src/Reporter.js +4 -0
  42. data/lib/jasmine/src/Spec.js +12 -8
  43. data/lib/jasmine/src/base.js +40 -44
  44. data/lib/jasmine/{lib → src/html}/TrivialReporter.js +17 -6
  45. data/lib/jasmine/src/html/jasmine.css +166 -0
  46. data/lib/jasmine/src/mock-timeout.js +22 -16
  47. data/lib/jasmine/src/version.json +2 -2
  48. data/lib/tasks/evergreen.rake +7 -0
  49. data/spec/evergreen_spec.rb +18 -0
  50. data/spec/fixtures/public/jquery.js +152 -0
  51. data/spec/fixtures/spec/javascripts/bar_spec.js +0 -0
  52. data/spec/fixtures/spec/javascripts/failing_spec.js +12 -0
  53. data/spec/fixtures/spec/javascripts/foo_spec.js +0 -0
  54. data/spec/fixtures/spec/javascripts/templates_spec.html +1 -0
  55. data/spec/fixtures/spec/javascripts/templates_spec.js +23 -0
  56. data/spec/fixtures/spec/javascripts/testing_spec.js +11 -0
  57. data/spec/fixtures/spec/javascripts/transactions_spec.js +14 -0
  58. data/spec/meta_spec.rb +17 -0
  59. data/spec/runner_spec.rb +35 -0
  60. data/spec/spec_helper.rb +33 -0
  61. data/spec/spec_spec.rb +30 -0
  62. metadata +64 -48
  63. data/lib/jasmine/doc/files.html +0 -460
  64. data/lib/jasmine/doc/index.html +0 -322
  65. data/lib/jasmine/doc/symbols/_global_.html +0 -918
  66. data/lib/jasmine/doc/symbols/jasmine.Block.html +0 -417
  67. data/lib/jasmine/doc/symbols/jasmine.Clock.html +0 -678
  68. data/lib/jasmine/doc/symbols/jasmine.Env.html +0 -1169
  69. data/lib/jasmine/doc/symbols/jasmine.JsApiReporter.html +0 -822
  70. data/lib/jasmine/doc/symbols/jasmine.Matchers.html +0 -1474
  71. data/lib/jasmine/doc/symbols/jasmine.MultiReporter.html +0 -394
  72. data/lib/jasmine/doc/symbols/jasmine.NestedResults.html +0 -710
  73. data/lib/jasmine/doc/symbols/jasmine.Reporter.html +0 -574
  74. data/lib/jasmine/doc/symbols/jasmine.Runner.html +0 -710
  75. data/lib/jasmine/doc/symbols/jasmine.Spec.html +0 -1253
  76. data/lib/jasmine/doc/symbols/jasmine.Spy.html +0 -855
  77. data/lib/jasmine/doc/symbols/jasmine.Suite.html +0 -705
  78. data/lib/jasmine/doc/symbols/jasmine.html +0 -1345
  79. data/lib/jasmine/doc/symbols/jasmine.util.html +0 -535
  80. data/lib/jasmine/doc/symbols/src/lib_TrivialReporter.js.html +0 -124
  81. data/lib/jasmine/doc/symbols/src/src_Block.js.html +0 -29
  82. data/lib/jasmine/doc/symbols/src/src_Env.js.html +0 -248
  83. data/lib/jasmine/doc/symbols/src/src_JsApiReporter.js.html +0 -111
  84. data/lib/jasmine/doc/symbols/src/src_Matchers.js.html +0 -344
  85. data/lib/jasmine/doc/symbols/src/src_MultiReporter.js.html +0 -36
  86. data/lib/jasmine/doc/symbols/src/src_NestedResults.js.html +0 -88
  87. data/lib/jasmine/doc/symbols/src/src_PrettyPrinter.js.html +0 -130
  88. data/lib/jasmine/doc/symbols/src/src_Queue.js.html +0 -102
  89. data/lib/jasmine/doc/symbols/src/src_Reporter.js.html +0 -35
  90. data/lib/jasmine/doc/symbols/src/src_Reporters.js.html +0 -51
  91. data/lib/jasmine/doc/symbols/src/src_Runner.js.html +0 -75
  92. data/lib/jasmine/doc/symbols/src/src_Spec.js.html +0 -214
  93. data/lib/jasmine/doc/symbols/src/src_Suite.js.html +0 -77
  94. data/lib/jasmine/doc/symbols/src/src_WaitsBlock.js.html +0 -21
  95. data/lib/jasmine/doc/symbols/src/src_WaitsForBlock.js.html +0 -45
  96. data/lib/jasmine/doc/symbols/src/src_base.js.html +0 -585
  97. data/lib/jasmine/doc/symbols/src/src_mock-timeout.js.html +0 -185
  98. data/lib/jasmine/doc/symbols/src/src_util.js.html +0 -75
  99. data/lib/jasmine/example/example_runner.html +0 -22
  100. data/lib/jasmine/example/spec/example_suite.js +0 -11
  101. data/lib/jasmine/spec/jasmine_helper.rb +0 -44
  102. data/lib/jasmine/spec/jasmine_spec.rb +0 -31
  103. data/lib/jasmine/spec/saucelabs.yml +0 -24
  104. data/lib/jasmine/src/Reporters.js +0 -43
@@ -21,8 +21,8 @@ jasmine.PrettyPrinter.prototype.format = function(value) {
21
21
  this.emitScalar('undefined');
22
22
  } else if (value === null) {
23
23
  this.emitScalar('null');
24
- } else if (value.navigator && value.frames && value.setTimeout) {
25
- this.emitScalar('<window>');
24
+ } else if (value === jasmine.getGlobal()) {
25
+ this.emitScalar('<global>');
26
26
  } else if (value instanceof jasmine.Matchers.Any) {
27
27
  this.emitScalar(value.toString());
28
28
  } else if (typeof value === 'string') {
@@ -17,6 +17,10 @@ jasmine.Reporter.prototype.reportRunnerResults = function(runner) {
17
17
  jasmine.Reporter.prototype.reportSuiteResults = function(suite) {
18
18
  };
19
19
 
20
+ //noinspection JSUnusedLocalSymbols
21
+ jasmine.Reporter.prototype.reportSpecStarting = function(spec) {
22
+ };
23
+
20
24
  //noinspection JSUnusedLocalSymbols
21
25
  jasmine.Reporter.prototype.reportSpecResults = function(spec) {
22
26
  };
@@ -37,13 +37,13 @@ jasmine.Spec.prototype.results = function() {
37
37
  return this.results_;
38
38
  };
39
39
 
40
- jasmine.Spec.prototype.log = function(message) {
41
- return this.results_.log(message);
42
- };
43
-
44
- /** @deprecated */
45
- jasmine.Spec.prototype.getResults = function() {
46
- return this.results_;
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
47
  };
48
48
 
49
49
  jasmine.Spec.prototype.runs = function (func) {
@@ -60,6 +60,9 @@ jasmine.Spec.prototype.addToQueue = function (block) {
60
60
  }
61
61
  };
62
62
 
63
+ /**
64
+ * @param {jasmine.ExpectationResult} result
65
+ */
63
66
  jasmine.Spec.prototype.addMatcherResult = function(result) {
64
67
  this.results_.addResult(result);
65
68
  };
@@ -131,7 +134,8 @@ jasmine.Spec.prototype.execute = function(onComplete) {
131
134
  spec.finish(onComplete);
132
135
  return;
133
136
  }
134
- this.env.reporter.log('>> Jasmine Running ' + this.suite.description + ' ' + this.description + '...');
137
+
138
+ this.env.reporter.reportSpecStarting(this);
135
139
 
136
140
  spec.env.currentSpec = spec;
137
141
 
@@ -26,6 +26,14 @@ jasmine.undefined = jasmine.___undefined___;
26
26
  */
27
27
  jasmine.DEFAULT_UPDATE_INTERVAL = 250;
28
28
 
29
+ jasmine.getGlobal = function() {
30
+ function getGlobal() {
31
+ return this;
32
+ }
33
+
34
+ return getGlobal();
35
+ };
36
+
29
37
  /**
30
38
  * Allows for bound functions to be compared. Internal use only.
31
39
  *
@@ -42,35 +50,41 @@ jasmine.bindOriginal_ = function(base, name) {
42
50
  };
43
51
  } else {
44
52
  // IE support
45
- return window[name];
53
+ return jasmine.getGlobal()[name];
46
54
  }
47
55
  };
48
56
 
49
- jasmine.setTimeout = jasmine.bindOriginal_(window, 'setTimeout');
50
- jasmine.clearTimeout = jasmine.bindOriginal_(window, 'clearTimeout');
51
- jasmine.setInterval = jasmine.bindOriginal_(window, 'setInterval');
52
- jasmine.clearInterval = jasmine.bindOriginal_(window, 'clearInterval');
57
+ jasmine.setTimeout = jasmine.bindOriginal_(jasmine.getGlobal(), 'setTimeout');
58
+ jasmine.clearTimeout = jasmine.bindOriginal_(jasmine.getGlobal(), 'clearTimeout');
59
+ jasmine.setInterval = jasmine.bindOriginal_(jasmine.getGlobal(), 'setInterval');
60
+ jasmine.clearInterval = jasmine.bindOriginal_(jasmine.getGlobal(), 'clearInterval');
53
61
 
54
- jasmine.MessageResult = function(text) {
55
- this.type = 'MessageResult';
56
- this.text = text;
62
+ jasmine.MessageResult = function(values) {
63
+ this.type = 'log';
64
+ this.values = values;
57
65
  this.trace = new Error(); // todo: test better
58
66
  };
59
67
 
60
68
  jasmine.MessageResult.prototype.toString = function() {
61
- return this.text;
69
+ var text = "";
70
+ for(var i = 0; i < this.values.length; i++) {
71
+ if (i > 0) text += " ";
72
+ if (jasmine.isString_(this.values[i])) {
73
+ text += this.values[i];
74
+ } else {
75
+ text += jasmine.pp(this.values[i]);
76
+ }
77
+ }
78
+ return text;
62
79
  };
63
80
 
64
81
  jasmine.ExpectationResult = function(params) {
65
- this.type = 'ExpectationResult';
82
+ this.type = 'expect';
66
83
  this.matcherName = params.matcherName;
67
84
  this.passed_ = params.passed;
68
85
  this.expected = params.expected;
69
86
  this.actual = params.actual;
70
87
 
71
- /** @deprecated */
72
- this.details = params.details;
73
-
74
88
  this.message = this.passed_ ? 'Passed.' : params.message;
75
89
  this.trace = this.passed_ ? '' : new Error(this.message);
76
90
  };
@@ -158,7 +172,7 @@ jasmine.isDomNode = function(obj) {
158
172
  *
159
173
  * @example
160
174
  * // don't care about which function is passed in, as long as it's a function
161
- * expect(mySpy).wasCalledWith(jasmine.any(Function));
175
+ * expect(mySpy).toHaveBeenCalledWith(jasmine.any(Function));
162
176
  *
163
177
  * @param {Class} clazz
164
178
  * @returns matchable object of the type clazz
@@ -173,7 +187,8 @@ jasmine.any = function(clazz) {
173
187
  * Spies should be created in test setup, before expectations. They can then be checked, using the standard Jasmine
174
188
  * expectation syntax. Spies can be checked if they were called or not and what the calling params were.
175
189
  *
176
- * A Spy has the following mehtod: wasCalled, callCount, mostRecentCall, and argsForCall (see docs)
190
+ * A Spy has the following fields: wasCalled, callCount, mostRecentCall, and argsForCall (see docs).
191
+ *
177
192
  * Spies are torn down at the end of every spec.
178
193
  *
179
194
  * Note: Do <b>not</b> call new jasmine.Spy() directly - a spy must be created using spyOn, jasmine.createSpy or jasmine.createSpyObj.
@@ -203,8 +218,8 @@ jasmine.any = function(clazz) {
203
218
  *
204
219
  * // mock example
205
220
  * foo.not(7 == 7);
206
- * expect(foo.not).wasCalled();
207
- * expect(foo.not).wasCalledWith(true);
221
+ * expect(foo.not).toHaveBeenCalled();
222
+ * expect(foo.not).toHaveBeenCalledWith(true);
208
223
  *
209
224
  * @constructor
210
225
  * @see spyOn, jasmine.createSpy, jasmine.createSpyObj
@@ -395,8 +410,14 @@ jasmine.createSpyObj = function(baseName, methodNames) {
395
410
  return obj;
396
411
  };
397
412
 
398
- jasmine.log = function(message) {
399
- jasmine.getEnv().currentSpec.log(message);
413
+ /**
414
+ * All parameters are pretty-printed and concatenated together, then written to the current spec's output.
415
+ *
416
+ * Be careful not to leave calls to <code>jasmine.log</code> in production code.
417
+ */
418
+ jasmine.log = function() {
419
+ var spec = jasmine.getEnv().currentSpec;
420
+ spec.log.apply(spec, arguments);
400
421
  };
401
422
 
402
423
  /**
@@ -559,28 +580,3 @@ jasmine.XmlHttpRequest = (typeof XMLHttpRequest == "undefined") ? function() {
559
580
  }
560
581
  throw new Error("This browser does not support XMLHttpRequest.");
561
582
  } : XMLHttpRequest;
562
-
563
- /**
564
- * Adds suite files to an HTML document so that they are executed, thus adding them to the current
565
- * Jasmine environment.
566
- *
567
- * @param {String} url path to the file to include
568
- * @param {Boolean} opt_global
569
- * @deprecated We suggest you use a different method of including JS source files. <code>jasmine.include</code> will be removed soon.
570
- */
571
- jasmine.include = function(url, opt_global) {
572
- if (opt_global) {
573
- document.write('<script type="text/javascript" src="' + url + '"></' + 'script>');
574
- } else {
575
- var xhr;
576
- try {
577
- xhr = new jasmine.XmlHttpRequest();
578
- xhr.open("GET", url, false);
579
- xhr.send(null);
580
- } catch(e) {
581
- throw new Error("couldn't fetch " + url + ": " + e);
582
- }
583
-
584
- return eval(xhr.responseText);
585
- }
586
- };
@@ -1,6 +1,7 @@
1
1
  jasmine.TrivialReporter = function(doc) {
2
2
  this.document = doc || document;
3
3
  this.suiteDivs = {};
4
+ this.logRunningSpecs = false;
4
5
  };
5
6
 
6
7
  jasmine.TrivialReporter.prototype.createDom = function(type, attrs, childrenVarArgs) {
@@ -58,10 +59,10 @@ jasmine.TrivialReporter.prototype.reportRunnerStarting = function(runner) {
58
59
  var suiteDiv = this.createDom('div', { className: 'suite' },
59
60
  this.createDom('a', { className: 'run_spec', href: '?spec=' + encodeURIComponent(suite.getFullName()) }, "run"),
60
61
  this.createDom('a', { className: 'description', href: '?spec=' + encodeURIComponent(suite.getFullName()) }, suite.description));
61
- this.suiteDivs[suite.getFullName()] = suiteDiv;
62
+ this.suiteDivs[suite.id] = suiteDiv;
62
63
  var parentDiv = this.outerDiv;
63
64
  if (suite.parentSuite) {
64
- parentDiv = this.suiteDivs[suite.parentSuite.getFullName()];
65
+ parentDiv = this.suiteDivs[suite.parentSuite.id];
65
66
  }
66
67
  parentDiv.appendChild(suiteDiv);
67
68
  }
@@ -112,7 +113,13 @@ jasmine.TrivialReporter.prototype.reportSuiteResults = function(suite) {
112
113
  if (results.totalCount == 0) { // todo: change this to check results.skipped
113
114
  status = 'skipped';
114
115
  }
115
- this.suiteDivs[suite.getFullName()].className += " " + status;
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
+ }
116
123
  };
117
124
 
118
125
  jasmine.TrivialReporter.prototype.reportSpecResults = function(spec) {
@@ -134,7 +141,10 @@ jasmine.TrivialReporter.prototype.reportSpecResults = function(spec) {
134
141
  var messagesDiv = this.createDom('div', { className: 'messages' });
135
142
  for (var i = 0; i < resultItems.length; i++) {
136
143
  var result = resultItems[i];
137
- if (result.passed && !result.passed()) {
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()) {
138
148
  messagesDiv.appendChild(this.createDom('div', {className: 'resultMessage fail'}, result.message));
139
149
 
140
150
  if (result.trace.stack) {
@@ -147,11 +157,12 @@ jasmine.TrivialReporter.prototype.reportSpecResults = function(spec) {
147
157
  specDiv.appendChild(messagesDiv);
148
158
  }
149
159
 
150
- this.suiteDivs[spec.suite.getFullName()].appendChild(specDiv);
160
+ this.suiteDivs[spec.suite.id].appendChild(specDiv);
151
161
  };
152
162
 
153
163
  jasmine.TrivialReporter.prototype.log = function() {
154
- console.log.apply(console, arguments);
164
+ var console = jasmine.getGlobal().console;
165
+ if (console && console.log) console.log.apply(console, arguments);
155
166
  };
156
167
 
157
168
  jasmine.TrivialReporter.prototype.getLocation = function() {
@@ -0,0 +1,166 @@
1
+ body {
2
+ font-family: "Helvetica Neue Light", "Lucida Grande", "Calibri", "Arial", sans-serif;
3
+ }
4
+
5
+
6
+ .jasmine_reporter a:visited, .jasmine_reporter a {
7
+ color: #303;
8
+ }
9
+
10
+ .jasmine_reporter a:hover, .jasmine_reporter a:active {
11
+ color: blue;
12
+ }
13
+
14
+ .run_spec {
15
+ float:right;
16
+ padding-right: 5px;
17
+ font-size: .8em;
18
+ text-decoration: none;
19
+ }
20
+
21
+ .jasmine_reporter {
22
+ margin: 0 5px;
23
+ }
24
+
25
+ .banner {
26
+ color: #303;
27
+ background-color: #fef;
28
+ padding: 5px;
29
+ }
30
+
31
+ .logo {
32
+ float: left;
33
+ font-size: 1.1em;
34
+ padding-left: 5px;
35
+ }
36
+
37
+ .logo .version {
38
+ font-size: .6em;
39
+ padding-left: 1em;
40
+ }
41
+
42
+ .runner.running {
43
+ background-color: yellow;
44
+ }
45
+
46
+
47
+ .options {
48
+ text-align: right;
49
+ font-size: .8em;
50
+ }
51
+
52
+
53
+
54
+
55
+ .suite {
56
+ border: 1px outset gray;
57
+ margin: 5px 0;
58
+ padding-left: 1em;
59
+ }
60
+
61
+ .suite .suite {
62
+ margin: 5px;
63
+ }
64
+
65
+ .suite.passed {
66
+ background-color: #dfd;
67
+ }
68
+
69
+ .suite.failed {
70
+ background-color: #fdd;
71
+ }
72
+
73
+ .spec {
74
+ margin: 5px;
75
+ padding-left: 1em;
76
+ clear: both;
77
+ }
78
+
79
+ .spec.failed, .spec.passed, .spec.skipped {
80
+ padding-bottom: 5px;
81
+ border: 1px solid gray;
82
+ }
83
+
84
+ .spec.failed {
85
+ background-color: #fbb;
86
+ border-color: red;
87
+ }
88
+
89
+ .spec.passed {
90
+ background-color: #bfb;
91
+ border-color: green;
92
+ }
93
+
94
+ .spec.skipped {
95
+ background-color: #bbb;
96
+ }
97
+
98
+ .messages {
99
+ border-left: 1px dashed gray;
100
+ padding-left: 1em;
101
+ padding-right: 1em;
102
+ }
103
+
104
+ .passed {
105
+ background-color: #cfc;
106
+ display: none;
107
+ }
108
+
109
+ .failed {
110
+ background-color: #fbb;
111
+ }
112
+
113
+ .skipped {
114
+ color: #777;
115
+ background-color: #eee;
116
+ display: none;
117
+ }
118
+
119
+
120
+ /*.resultMessage {*/
121
+ /*white-space: pre;*/
122
+ /*}*/
123
+
124
+ .resultMessage span.result {
125
+ display: block;
126
+ line-height: 2em;
127
+ color: black;
128
+ }
129
+
130
+ .resultMessage .mismatch {
131
+ color: black;
132
+ }
133
+
134
+ .stackTrace {
135
+ white-space: pre;
136
+ font-size: .8em;
137
+ margin-left: 10px;
138
+ max-height: 5em;
139
+ overflow: auto;
140
+ border: 1px inset red;
141
+ padding: 1em;
142
+ background: #eef;
143
+ }
144
+
145
+ .finished-at {
146
+ padding-left: 1em;
147
+ font-size: .6em;
148
+ }
149
+
150
+ .show-passed .passed,
151
+ .show-skipped .skipped {
152
+ display: block;
153
+ }
154
+
155
+
156
+ #jasmine_content {
157
+ position:fixed;
158
+ right: 100%;
159
+ }
160
+
161
+ .runner {
162
+ border: 1px solid gray;
163
+ display: block;
164
+ margin: 5px 0;
165
+ padding: 2px 0 2px 10px;
166
+ }
@@ -64,9 +64,9 @@ jasmine.FakeTimer.prototype.runFunctionsWithinRange = function(oldMillis, nowMil
64
64
  funcToRun.funcToCall();
65
65
  if (funcToRun.recurring) {
66
66
  this.scheduleFunction(funcToRun.timeoutKey,
67
- funcToRun.funcToCall,
68
- funcToRun.millis,
69
- true);
67
+ funcToRun.funcToCall,
68
+ funcToRun.millis,
69
+ true);
70
70
  }
71
71
  } catch(e) {
72
72
  }
@@ -110,10 +110,12 @@ jasmine.Clock = {
110
110
  },
111
111
 
112
112
  useMock: function() {
113
- var spec = jasmine.getEnv().currentSpec;
114
- spec.after(jasmine.Clock.uninstallMock);
113
+ if (!jasmine.Clock.isInstalled()) {
114
+ var spec = jasmine.getEnv().currentSpec;
115
+ spec.after(jasmine.Clock.uninstallMock);
115
116
 
116
- jasmine.Clock.installMock();
117
+ jasmine.Clock.installMock();
118
+ }
117
119
  },
118
120
 
119
121
  installMock: function() {
@@ -126,24 +128,28 @@ jasmine.Clock = {
126
128
  },
127
129
 
128
130
  real: {
129
- setTimeout: window.setTimeout,
130
- clearTimeout: window.clearTimeout,
131
- setInterval: window.setInterval,
132
- clearInterval: window.clearInterval
131
+ setTimeout: jasmine.getGlobal().setTimeout,
132
+ clearTimeout: jasmine.getGlobal().clearTimeout,
133
+ setInterval: jasmine.getGlobal().setInterval,
134
+ clearInterval: jasmine.getGlobal().clearInterval
133
135
  },
134
136
 
135
137
  assertInstalled: function() {
136
- if (jasmine.Clock.installed != jasmine.Clock.defaultFakeTimer) {
138
+ if (!jasmine.Clock.isInstalled()) {
137
139
  throw new Error("Mock clock is not installed, use jasmine.Clock.useMock()");
138
140
  }
139
141
  },
140
142
 
143
+ isInstalled: function() {
144
+ return jasmine.Clock.installed == jasmine.Clock.defaultFakeTimer;
145
+ },
146
+
141
147
  installed: null
142
148
  };
143
149
  jasmine.Clock.installed = jasmine.Clock.real;
144
150
 
145
151
  //else for IE support
146
- window.setTimeout = function(funcToCall, millis) {
152
+ jasmine.getGlobal().setTimeout = function(funcToCall, millis) {
147
153
  if (jasmine.Clock.installed.setTimeout.apply) {
148
154
  return jasmine.Clock.installed.setTimeout.apply(this, arguments);
149
155
  } else {
@@ -151,7 +157,7 @@ window.setTimeout = function(funcToCall, millis) {
151
157
  }
152
158
  };
153
159
 
154
- window.setInterval = function(funcToCall, millis) {
160
+ jasmine.getGlobal().setInterval = function(funcToCall, millis) {
155
161
  if (jasmine.Clock.installed.setInterval.apply) {
156
162
  return jasmine.Clock.installed.setInterval.apply(this, arguments);
157
163
  } else {
@@ -159,7 +165,7 @@ window.setInterval = function(funcToCall, millis) {
159
165
  }
160
166
  };
161
167
 
162
- window.clearTimeout = function(timeoutKey) {
168
+ jasmine.getGlobal().clearTimeout = function(timeoutKey) {
163
169
  if (jasmine.Clock.installed.clearTimeout.apply) {
164
170
  return jasmine.Clock.installed.clearTimeout.apply(this, arguments);
165
171
  } else {
@@ -167,11 +173,11 @@ window.clearTimeout = function(timeoutKey) {
167
173
  }
168
174
  };
169
175
 
170
- window.clearInterval = function(timeoutKey) {
176
+ jasmine.getGlobal().clearInterval = function(timeoutKey) {
171
177
  if (jasmine.Clock.installed.clearTimeout.apply) {
172
178
  return jasmine.Clock.installed.clearInterval.apply(this, arguments);
173
179
  } else {
174
- return jasmine.Clock.installed.clearInterval(timeoutKey);
180
+ return jasmine.Clock.installed.clearInterval(timeoutKey);
175
181
  }
176
182
  };
177
183