jasmine-core 2.4.1 → 2.5.0

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.
Files changed (71) hide show
  1. checksums.yaml +4 -4
  2. data/lib/console/console.js +1 -1
  3. data/lib/jasmine-core/boot.js +1 -1
  4. data/lib/jasmine-core/jasmine-html.js +15 -7
  5. data/lib/jasmine-core/jasmine.js +261 -82
  6. data/lib/jasmine-core/node_boot.js +1 -1
  7. data/lib/jasmine-core/spec/console/ConsoleReporterSpec.js +16 -16
  8. data/lib/jasmine-core/spec/core/CallTrackerSpec.js +26 -11
  9. data/lib/jasmine-core/spec/core/ClockSpec.js +61 -42
  10. data/lib/jasmine-core/spec/core/DelayedFunctionSchedulerSpec.js +28 -15
  11. data/lib/jasmine-core/spec/core/EnvSpec.js +8 -8
  12. data/lib/jasmine-core/spec/core/ExceptionFormatterSpec.js +6 -6
  13. data/lib/jasmine-core/spec/core/ExceptionsSpec.js +1 -1
  14. data/lib/jasmine-core/spec/core/ExpectationResultSpec.js +8 -8
  15. data/lib/jasmine-core/spec/core/ExpectationSpec.js +17 -17
  16. data/lib/jasmine-core/spec/core/JsApiReporterSpec.js +14 -14
  17. data/lib/jasmine-core/spec/core/MockDateSpec.js +14 -14
  18. data/lib/jasmine-core/spec/core/PrettyPrintSpec.js +65 -56
  19. data/lib/jasmine-core/spec/core/QueueRunnerSpec.js +32 -18
  20. data/lib/jasmine-core/spec/core/ReportDispatcherSpec.js +27 -3
  21. data/lib/jasmine-core/spec/core/SpecSpec.js +37 -37
  22. data/lib/jasmine-core/spec/core/SpyRegistrySpec.js +46 -7
  23. data/lib/jasmine-core/spec/core/SpySpec.js +11 -11
  24. data/lib/jasmine-core/spec/core/SpyStrategySpec.js +25 -13
  25. data/lib/jasmine-core/spec/core/SuiteSpec.js +25 -25
  26. data/lib/jasmine-core/spec/core/TimerSpec.js +2 -2
  27. data/lib/jasmine-core/spec/core/TreeProcessorSpec.js +26 -26
  28. data/lib/jasmine-core/spec/core/UtilSpec.js +12 -12
  29. data/lib/jasmine-core/spec/core/asymmetric_equality/AnySpec.js +8 -8
  30. data/lib/jasmine-core/spec/core/asymmetric_equality/AnythingSpec.js +7 -7
  31. data/lib/jasmine-core/spec/core/asymmetric_equality/ArrayContainingSpec.js +6 -6
  32. data/lib/jasmine-core/spec/core/asymmetric_equality/ObjectContainingSpec.js +11 -11
  33. data/lib/jasmine-core/spec/core/asymmetric_equality/StringMatchingSpec.js +4 -4
  34. data/lib/jasmine-core/spec/core/formatErrorMsgSpec.js +13 -0
  35. data/lib/jasmine-core/spec/core/integration/CustomMatchersSpec.js +2 -2
  36. data/lib/jasmine-core/spec/core/integration/EnvSpec.js +195 -76
  37. data/lib/jasmine-core/spec/core/integration/SpecRunningSpec.js +20 -21
  38. data/lib/jasmine-core/spec/core/matchers/matchersUtilSpec.js +164 -114
  39. data/lib/jasmine-core/spec/core/matchers/toBeCloseToSpec.js +4 -4
  40. data/lib/jasmine-core/spec/core/matchers/toBeDefinedSpec.js +2 -2
  41. data/lib/jasmine-core/spec/core/matchers/toBeFalsySpec.js +2 -2
  42. data/lib/jasmine-core/spec/core/matchers/toBeGreaterThanOrEqualSpec.js +29 -0
  43. data/lib/jasmine-core/spec/core/matchers/toBeGreaterThanSpec.js +2 -2
  44. data/lib/jasmine-core/spec/core/matchers/toBeLessThanOrEqualSpec.js +29 -0
  45. data/lib/jasmine-core/spec/core/matchers/toBeLessThanSpec.js +2 -2
  46. data/lib/jasmine-core/spec/core/matchers/toBeNaNSpec.js +3 -3
  47. data/lib/jasmine-core/spec/core/matchers/toBeNullSpec.js +2 -2
  48. data/lib/jasmine-core/spec/core/matchers/toBeSpec.js +2 -2
  49. data/lib/jasmine-core/spec/core/matchers/toBeTruthySpec.js +2 -2
  50. data/lib/jasmine-core/spec/core/matchers/toBeUndefinedSpec.js +2 -2
  51. data/lib/jasmine-core/spec/core/matchers/toContainSpec.js +4 -4
  52. data/lib/jasmine-core/spec/core/matchers/toEqualSpec.js +2 -2
  53. data/lib/jasmine-core/spec/core/matchers/toHaveBeenCalledSpec.js +11 -11
  54. data/lib/jasmine-core/spec/core/matchers/toHaveBeenCalledTimesSpec.js +22 -17
  55. data/lib/jasmine-core/spec/core/matchers/toHaveBeenCalledWithSpec.js +11 -10
  56. data/lib/jasmine-core/spec/core/matchers/toMatchSpec.js +7 -6
  57. data/lib/jasmine-core/spec/core/matchers/toThrowErrorSpec.js +24 -24
  58. data/lib/jasmine-core/spec/core/matchers/toThrowSpec.js +9 -8
  59. data/lib/jasmine-core/spec/helpers/defineJasmineUnderTest.js +3 -3
  60. data/lib/jasmine-core/spec/helpers/nodeDefineJasmineUnderTest.js +5 -5
  61. data/lib/jasmine-core/spec/html/HtmlReporterSpec.js +95 -59
  62. data/lib/jasmine-core/spec/html/HtmlSpecFilterSpec.js +3 -3
  63. data/lib/jasmine-core/spec/html/MatchersHtmlSpec.js +1 -1
  64. data/lib/jasmine-core/spec/html/PrettyPrintHtmlSpec.js +4 -4
  65. data/lib/jasmine-core/spec/html/QueryStringSpec.js +5 -5
  66. data/lib/jasmine-core/spec/html/ResultsNodeSpec.js +4 -4
  67. data/lib/jasmine-core/spec/npmPackage/npmPackageSpec.js +2 -2
  68. data/lib/jasmine-core/spec/performance/large_object_test.js +1 -1
  69. data/lib/jasmine-core/version.rb +1 -1
  70. metadata +5 -3
  71. data/lib/jasmine-core/spec/node_suite.js +0 -195
@@ -2,7 +2,7 @@ describe("jasmine spec running", function () {
2
2
  var env;
3
3
 
4
4
  beforeEach(function() {
5
- env = new j$.Env();
5
+ env = new jasmineUnderTest.Env();
6
6
  });
7
7
 
8
8
  it('should assign spec ids sequentially', function() {
@@ -556,15 +556,24 @@ describe("jasmine spec running", function () {
556
556
  env.execute();
557
557
  });
558
558
 
559
- // TODO: is this useful? It doesn't catch syntax errors
560
- xit("should recover gracefully when there are errors in describe functions", function() {
561
- var specs = [];
562
- var superSimpleReporter = new j$.Reporter();
563
- superSimpleReporter.reportSpecResults = function(result) {
564
- specs.push("Spec: " + result.fullName);
565
- };
559
+ it("should recover gracefully when there are errors in describe functions", function(done) {
560
+ var specs = [],
561
+ reporter = jasmine.createSpyObj(['specDone', 'jasmineDone']);
562
+
563
+ reporter.specDone.and.callFake(function(result) {
564
+ specs.push(result.fullName);
565
+ });
566
566
 
567
- try {
567
+ reporter.jasmineDone.and.callFake(function() {
568
+ expect(specs).toContain('outer1 inner1 should thingy');
569
+ expect(specs).toContain('outer1 inner1 encountered a declaration exception');
570
+ expect(specs).toContain('outer1 inner2 should other thingy');
571
+ expect(specs).toContain('outer1 encountered a declaration exception');
572
+ expect(specs).toContain('outer2 should xxx');
573
+ done();
574
+ });
575
+
576
+ expect(function() {
568
577
  env.describe("outer1", function() {
569
578
  env.describe("inner1", function() {
570
579
  env.it("should thingy", function() {
@@ -583,8 +592,7 @@ describe("jasmine spec running", function () {
583
592
  throw new Error("fake error");
584
593
 
585
594
  });
586
- } catch(e) {
587
- }
595
+ }).not.toThrow();
588
596
 
589
597
  env.describe("outer2", function() {
590
598
  env.it("should xxx", function() {
@@ -592,17 +600,8 @@ describe("jasmine spec running", function () {
592
600
  });
593
601
  });
594
602
 
595
- env.addReporter(superSimpleReporter);
603
+ env.addReporter(reporter);
596
604
  env.execute();
597
-
598
- expect(specs.join('')).toMatch(new RegExp(
599
- 'Spec: outer1 inner1 should thingy.' +
600
- 'Spec: outer1 inner1 encountered a declaration exception.' +
601
- 'Spec: outer1 inner2 should other thingy.' +
602
- 'Spec: outer1 encountered a declaration exception.' +
603
- 'Spec: outer2 should xxx.'
604
- ));
605
-
606
605
  });
607
606
 
608
607
  it("re-enters suites that have no *Alls", function(done) {
@@ -1,61 +1,68 @@
1
1
  describe("matchersUtil", function() {
2
2
  describe("equals", function() {
3
3
  it("passes for literals that are triple-equal", function() {
4
- expect(j$.matchersUtil.equals(null, null)).toBe(true);
5
- expect(j$.matchersUtil.equals(void 0, void 0)).toBe(true);
4
+ expect(jasmineUnderTest.matchersUtil.equals(null, null)).toBe(true);
5
+ expect(jasmineUnderTest.matchersUtil.equals(void 0, void 0)).toBe(true);
6
6
  });
7
7
 
8
8
  it("fails for things that are not equivalent", function() {
9
- expect(j$.matchersUtil.equals({a: "foo"}, 1)).toBe(false);
9
+ expect(jasmineUnderTest.matchersUtil.equals({a: "foo"}, 1)).toBe(false);
10
10
  });
11
11
 
12
12
  it("passes for Strings that are equivalent", function() {
13
- expect(j$.matchersUtil.equals("foo", "foo")).toBe(true);
13
+ expect(jasmineUnderTest.matchersUtil.equals("foo", "foo")).toBe(true);
14
14
  });
15
15
 
16
16
  it("fails for Strings that are not equivalent", function() {
17
- expect(j$.matchersUtil.equals("foo", "bar")).toBe(false);
17
+ expect(jasmineUnderTest.matchersUtil.equals("foo", "bar")).toBe(false);
18
18
  });
19
19
 
20
20
  it("passes for Numbers that are equivalent", function() {
21
- expect(j$.matchersUtil.equals(123, 123)).toBe(true);
21
+ expect(jasmineUnderTest.matchersUtil.equals(123, 123)).toBe(true);
22
22
  });
23
23
 
24
24
  it("fails for Numbers that are not equivalent", function() {
25
- expect(j$.matchersUtil.equals(123, 456)).toBe(false);
25
+ expect(jasmineUnderTest.matchersUtil.equals(123, 456)).toBe(false);
26
26
  });
27
27
 
28
28
  it("passes for Dates that are equivalent", function() {
29
- expect(j$.matchersUtil.equals(new Date("Jan 1, 1970"), new Date("Jan 1, 1970"))).toBe(true);
29
+ expect(jasmineUnderTest.matchersUtil.equals(new Date("Jan 1, 1970"), new Date("Jan 1, 1970"))).toBe(true);
30
30
  });
31
31
 
32
32
  it("fails for Dates that are not equivalent", function() {
33
- expect(j$.matchersUtil.equals(new Date("Jan 1, 1970"), new Date("Feb 3, 1991"))).toBe(false);
33
+ expect(jasmineUnderTest.matchersUtil.equals(new Date("Jan 1, 1970"), new Date("Feb 3, 1991"))).toBe(false);
34
34
  });
35
35
 
36
36
  it("passes for Booleans that are equivalent", function() {
37
- expect(j$.matchersUtil.equals(true, true)).toBe(true);
37
+ expect(jasmineUnderTest.matchersUtil.equals(true, true)).toBe(true);
38
38
  });
39
39
 
40
40
  it("fails for Booleans that are not equivalent", function() {
41
- expect(j$.matchersUtil.equals(true, false)).toBe(false);
41
+ expect(jasmineUnderTest.matchersUtil.equals(true, false)).toBe(false);
42
42
  });
43
43
 
44
44
  it("passes for RegExps that are equivalent", function() {
45
- expect(j$.matchersUtil.equals(/foo/, /foo/)).toBe(true);
45
+ expect(jasmineUnderTest.matchersUtil.equals(/foo/, /foo/)).toBe(true);
46
46
  });
47
47
 
48
48
  it("fails for RegExps that are not equivalent", function() {
49
- expect(j$.matchersUtil.equals(/foo/, /bar/)).toBe(false);
50
- expect(j$.matchersUtil.equals(new RegExp("foo", "i"), new RegExp("foo"))).toBe(false);
49
+ expect(jasmineUnderTest.matchersUtil.equals(/foo/, /bar/)).toBe(false);
50
+ expect(jasmineUnderTest.matchersUtil.equals(new RegExp("foo", "i"), new RegExp("foo"))).toBe(false);
51
51
  });
52
52
 
53
53
  it("passes for Arrays that are equivalent", function() {
54
- expect(j$.matchersUtil.equals([1, 2], [1, 2])).toBe(true);
54
+ expect(jasmineUnderTest.matchersUtil.equals([1, 2], [1, 2])).toBe(true);
55
+ });
56
+
57
+ it("passes for Arrays that are equivalent, with elements added by changing length", function() {
58
+ var foo = [];
59
+ foo.length = 1;
60
+
61
+ expect(jasmineUnderTest.matchersUtil.equals(foo, [undefined])).toBe(true);
55
62
  });
56
63
 
57
64
  it("fails for Arrays that are not equivalent", function() {
58
- expect(j$.matchersUtil.equals([1, 2], [1, 2, 3])).toBe(false);
65
+ expect(jasmineUnderTest.matchersUtil.equals([1, 2], [1, 2, 3])).toBe(false);
59
66
  });
60
67
 
61
68
  it("fails for Arrays whose contents are equivalent, but have differing properties", function() {
@@ -65,31 +72,48 @@ describe("matchersUtil", function() {
65
72
  one.foo = 'bar';
66
73
  two.foo = 'baz';
67
74
 
68
- expect(j$.matchersUtil.equals(one, two)).toBe(false);
75
+ expect(jasmineUnderTest.matchersUtil.equals(one, two)).toBe(false);
76
+ });
77
+
78
+ it("passes for Arrays with equivalent contents and properties", function() {
79
+ var one = [1,2,3],
80
+ two = [1,2,3];
81
+
82
+ one.foo = 'bar';
83
+ two.foo = 'bar';
84
+
85
+ expect(jasmineUnderTest.matchersUtil.equals(one, two)).toBe(true);
69
86
  });
70
87
 
71
88
  it("passes for Errors that are the same type and have the same message", function() {
72
- expect(j$.matchersUtil.equals(new Error("foo"), new Error("foo"))).toBe(true);
89
+ expect(jasmineUnderTest.matchersUtil.equals(new Error("foo"), new Error("foo"))).toBe(true);
73
90
  });
74
91
 
75
92
  it("fails for Errors that are the same type and have different messages", function() {
76
- expect(j$.matchersUtil.equals(new Error("foo"), new Error("bar"))).toBe(false);
93
+ expect(jasmineUnderTest.matchersUtil.equals(new Error("foo"), new Error("bar"))).toBe(false);
94
+ });
95
+
96
+ it("fails for objects with different constructors", function() {
97
+ function One() {}
98
+ function Two() {}
99
+
100
+ expect(jasmineUnderTest.matchersUtil.equals(new One(), new Two())).toBe(false);
77
101
  });
78
102
 
79
103
  it("passes for Objects that are equivalent (simple case)", function() {
80
- expect(j$.matchersUtil.equals({a: "foo"}, {a: "foo"})).toBe(true);
104
+ expect(jasmineUnderTest.matchersUtil.equals({a: "foo"}, {a: "foo"})).toBe(true);
81
105
  });
82
106
 
83
107
  it("fails for Objects that are not equivalent (simple case)", function() {
84
- expect(j$.matchersUtil.equals({a: "foo"}, {a: "bar"})).toBe(false);
108
+ expect(jasmineUnderTest.matchersUtil.equals({a: "foo"}, {a: "bar"})).toBe(false);
85
109
  });
86
110
 
87
111
  it("passes for Objects that are equivalent (deep case)", function() {
88
- expect(j$.matchersUtil.equals({a: "foo", b: { c: "bar"}}, {a: "foo", b: { c: "bar"}})).toBe(true);
112
+ expect(jasmineUnderTest.matchersUtil.equals({a: "foo", b: { c: "bar"}}, {a: "foo", b: { c: "bar"}})).toBe(true);
89
113
  });
90
114
 
91
115
  it("fails for Objects that are not equivalent (deep case)", function() {
92
- expect(j$.matchersUtil.equals({a: "foo", b: { c: "baz"}}, {a: "foo", b: { c: "bar"}})).toBe(false);
116
+ expect(jasmineUnderTest.matchersUtil.equals({a: "foo", b: { c: "baz"}}, {a: "foo", b: { c: "bar"}})).toBe(false);
93
117
  });
94
118
 
95
119
  it("passes for Objects that are equivalent (with cycles)", function() {
@@ -99,7 +123,7 @@ describe("matchersUtil", function() {
99
123
  actual.b = actual;
100
124
  expected.b = actual;
101
125
 
102
- expect(j$.matchersUtil.equals(actual, expected)).toBe(true);
126
+ expect(jasmineUnderTest.matchersUtil.equals(actual, expected)).toBe(true);
103
127
  });
104
128
 
105
129
  it("fails for Objects that are not equivalent (with cycles)", function() {
@@ -109,15 +133,15 @@ describe("matchersUtil", function() {
109
133
  actual.b = actual;
110
134
  expected.b = actual;
111
135
 
112
- expect(j$.matchersUtil.equals(actual, expected)).toBe(false);
136
+ expect(jasmineUnderTest.matchersUtil.equals(actual, expected)).toBe(false);
113
137
  });
114
138
 
115
139
  it("fails when comparing an empty object to an empty array (issue #114)", function() {
116
140
  var emptyObject = {},
117
141
  emptyArray = [];
118
142
 
119
- expect(j$.matchersUtil.equals(emptyObject, emptyArray)).toBe(false);
120
- expect(j$.matchersUtil.equals(emptyArray, emptyObject)).toBe(false);
143
+ expect(jasmineUnderTest.matchersUtil.equals(emptyObject, emptyArray)).toBe(false);
144
+ expect(jasmineUnderTest.matchersUtil.equals(emptyArray, emptyObject)).toBe(false);
121
145
  });
122
146
 
123
147
  it("passes for equivalent frozen objects (GitHub issue #266)", function() {
@@ -129,89 +153,115 @@ describe("matchersUtil", function() {
129
153
  Object.freeze(a);
130
154
  Object.freeze(b);
131
155
 
132
- expect(j$.matchersUtil.equals(a,b)).toBe(true);
156
+ expect(jasmineUnderTest.matchersUtil.equals(a,b)).toBe(true);
133
157
  });
134
158
 
135
- it("passes for equivalent DOM nodes", function() {
136
- if (typeof document === 'undefined') {
137
- return;
159
+ describe("when running in a browser", function() {
160
+ function isNotRunningInBrowser() {
161
+ return typeof document === 'undefined'
138
162
  }
139
- var a = document.createElement("div");
140
- a.setAttribute("test-attr", "attr-value")
141
- a.appendChild(document.createTextNode('test'));
142
163
 
143
- var b = document.createElement("div");
144
- b.setAttribute("test-attr", "attr-value")
145
- b.appendChild(document.createTextNode('test'));
164
+ it("passes for equivalent DOM nodes", function() {
165
+ if (isNotRunningInBrowser()) {
166
+ return;
167
+ }
168
+ var a = document.createElement("div");
169
+ a.setAttribute("test-attr", "attr-value");
170
+ a.appendChild(document.createTextNode('test'));
146
171
 
147
- expect(j$.matchersUtil.equals(a,b)).toBe(true);
148
- });
172
+ var b = document.createElement("div");
173
+ b.setAttribute("test-attr", "attr-value");
174
+ b.appendChild(document.createTextNode('test'));
149
175
 
150
- it("fails for DOM nodes with different attributes or child nodes", function() {
151
- if (typeof document === 'undefined') {
152
- return;
153
- }
154
- var a = document.createElement("div");
155
- a.setAttribute("test-attr", "attr-value")
156
- a.appendChild(document.createTextNode('test'));
176
+ expect(jasmineUnderTest.matchersUtil.equals(a,b)).toBe(true);
177
+ });
157
178
 
158
- var b = document.createElement("div");
159
- b.setAttribute("test-attr", "attr-value2")
160
- b.appendChild(document.createTextNode('test'));
179
+ it("passes for equivalent objects from different frames", function() {
180
+ if (isNotRunningInBrowser()) {
181
+ return;
182
+ }
183
+ // iframe.contentWindow.eval isn't supported in ie8
184
+ if (jasmine.getEnv().ieVersion < 9) {
185
+ return;
186
+ }
187
+ var iframe = document.createElement('iframe');
188
+ document.body.appendChild(iframe);
189
+ iframe.contentWindow.eval('window.testObject = {}');
190
+ expect(jasmineUnderTest.matchersUtil.equals({}, iframe.contentWindow.testObject)).toBe(true);
191
+ document.body.removeChild(iframe);
192
+ });
161
193
 
162
- expect(j$.matchersUtil.equals(a,b)).toBe(false);
194
+ it("fails for DOM nodes with different attributes or child nodes", function() {
195
+ if (isNotRunningInBrowser()) {
196
+ return;
197
+ }
198
+ var a = document.createElement("div");
199
+ a.setAttribute("test-attr", "attr-value")
200
+ a.appendChild(document.createTextNode('test'));
163
201
 
164
- b.setAttribute("test-attr", "attr-value");
165
- expect(j$.matchersUtil.equals(a,b)).toBe(true);
202
+ var b = document.createElement("div");
203
+ b.setAttribute("test-attr", "attr-value2")
204
+ b.appendChild(document.createTextNode('test'));
166
205
 
167
- b.appendChild(document.createTextNode('2'));
168
- expect(j$.matchersUtil.equals(a,b)).toBe(false);
206
+ expect(jasmineUnderTest.matchersUtil.equals(a,b)).toBe(false);
169
207
 
170
- a.appendChild(document.createTextNode('2'));
171
- expect(j$.matchersUtil.equals(a,b)).toBe(true);
172
- });
208
+ b.setAttribute("test-attr", "attr-value");
209
+ expect(jasmineUnderTest.matchersUtil.equals(a,b)).toBe(true);
173
210
 
174
- it("passes for equivalent objects from different vm contexts", function() {
175
- if (typeof require !== 'function') {
176
- return;
177
- }
178
- var vm = require('vm');
179
- var sandbox = {
180
- obj: null
181
- };
182
- vm.runInNewContext('obj = {a: 1, b: 2}', sandbox);
211
+ b.appendChild(document.createTextNode('2'));
212
+ expect(jasmineUnderTest.matchersUtil.equals(a,b)).toBe(false);
183
213
 
184
- expect(j$.matchersUtil.equals(sandbox.obj, {a: 1, b: 2})).toBe(true);
214
+ a.appendChild(document.createTextNode('2'));
215
+ expect(jasmineUnderTest.matchersUtil.equals(a,b)).toBe(true);
216
+ });
185
217
  });
186
218
 
187
- it("passes for equivalent arrays from different vm contexts", function() {
188
- if (typeof require !== 'function') {
189
- return;
219
+ describe("when running in Node", function() {
220
+ function isNotRunningInNode() {
221
+ return typeof require !== 'function'
190
222
  }
191
223
 
192
- var vm = require('vm');
193
- var sandbox = {
194
- arr: null
195
- };
196
- vm.runInNewContext('arr = [1, 2]', sandbox);
224
+ it("passes for equivalent objects from different vm contexts", function() {
225
+ if (isNotRunningInNode()) {
226
+ return;
227
+ }
228
+ var vm = require('vm');
229
+ var sandbox = {
230
+ obj: null
231
+ };
232
+ vm.runInNewContext('obj = {a: 1, b: 2}', sandbox);
233
+
234
+ expect(jasmineUnderTest.matchersUtil.equals(sandbox.obj, {a: 1, b: 2})).toBe(true);
235
+ });
197
236
 
198
- expect(j$.matchersUtil.equals(sandbox.arr, [1, 2])).toBe(true);
237
+ it("passes for equivalent arrays from different vm contexts", function() {
238
+ if (isNotRunningInNode()) {
239
+ return;
240
+ }
241
+ var vm = require('vm');
242
+ var sandbox = {
243
+ arr: null
244
+ };
245
+ vm.runInNewContext('arr = [1, 2]', sandbox);
246
+
247
+ expect(jasmineUnderTest.matchersUtil.equals(sandbox.arr, [1, 2])).toBe(true);
248
+ });
199
249
  });
200
250
 
201
251
  it("passes when Any is used", function() {
202
252
  var number = 3,
203
- anyNumber = new j$.Any(Number);
253
+ anyNumber = new jasmineUnderTest.Any(Number);
204
254
 
205
- expect(j$.matchersUtil.equals(number, anyNumber)).toBe(true);
206
- expect(j$.matchersUtil.equals(anyNumber, number)).toBe(true);
255
+ expect(jasmineUnderTest.matchersUtil.equals(number, anyNumber)).toBe(true);
256
+ expect(jasmineUnderTest.matchersUtil.equals(anyNumber, number)).toBe(true);
207
257
  });
208
258
 
209
259
  it("fails when Any is compared to something unexpected", function() {
210
260
  var number = 3,
211
- anyString = new j$.Any(String);
261
+ anyString = new jasmineUnderTest.Any(String);
212
262
 
213
- expect(j$.matchersUtil.equals(number, anyString)).toBe(false);
214
- expect(j$.matchersUtil.equals(anyString, number)).toBe(false);
263
+ expect(jasmineUnderTest.matchersUtil.equals(number, anyString)).toBe(false);
264
+ expect(jasmineUnderTest.matchersUtil.equals(anyString, number)).toBe(false);
215
265
  });
216
266
 
217
267
  it("passes when ObjectContaining is used", function() {
@@ -219,69 +269,69 @@ describe("matchersUtil", function() {
219
269
  foo: 3,
220
270
  bar: 7
221
271
  },
222
- containing = new j$.ObjectContaining({foo: 3});
272
+ containing = new jasmineUnderTest.ObjectContaining({foo: 3});
223
273
 
224
- expect(j$.matchersUtil.equals(obj, containing)).toBe(true);
225
- expect(j$.matchersUtil.equals(containing, obj)).toBe(true);
274
+ expect(jasmineUnderTest.matchersUtil.equals(obj, containing)).toBe(true);
275
+ expect(jasmineUnderTest.matchersUtil.equals(containing, obj)).toBe(true);
226
276
  });
227
277
 
228
278
  it("passes when an asymmetric equality tester returns true", function() {
229
279
  var tester = { asymmetricMatch: function(other) { return true; } };
230
280
 
231
- expect(j$.matchersUtil.equals(false, tester)).toBe(true);
232
- expect(j$.matchersUtil.equals(tester, false)).toBe(true);
281
+ expect(jasmineUnderTest.matchersUtil.equals(false, tester)).toBe(true);
282
+ expect(jasmineUnderTest.matchersUtil.equals(tester, false)).toBe(true);
233
283
  });
234
284
 
235
285
  it("fails when an asymmetric equality tester returns false", function() {
236
286
  var tester = { asymmetricMatch: function(other) { return false; } };
237
287
 
238
- expect(j$.matchersUtil.equals(true, tester)).toBe(false);
239
- expect(j$.matchersUtil.equals(tester, true)).toBe(false);
288
+ expect(jasmineUnderTest.matchersUtil.equals(true, tester)).toBe(false);
289
+ expect(jasmineUnderTest.matchersUtil.equals(tester, true)).toBe(false);
240
290
  });
241
291
 
242
292
  it("passes when ArrayContaining is used", function() {
243
293
  var arr = ["foo", "bar"];
244
294
 
245
- expect(j$.matchersUtil.equals(arr, new j$.ArrayContaining(["bar"]))).toBe(true);
295
+ expect(jasmineUnderTest.matchersUtil.equals(arr, new jasmineUnderTest.ArrayContaining(["bar"]))).toBe(true);
246
296
  });
247
297
 
248
298
  it("passes when a custom equality matcher returns true", function() {
249
299
  var tester = function(a, b) { return true; };
250
300
 
251
- expect(j$.matchersUtil.equals(1, 2, [tester])).toBe(true);
301
+ expect(jasmineUnderTest.matchersUtil.equals(1, 2, [tester])).toBe(true);
252
302
  });
253
303
 
254
304
  it("passes for two empty Objects", function () {
255
- expect(j$.matchersUtil.equals({}, {})).toBe(true);
305
+ expect(jasmineUnderTest.matchersUtil.equals({}, {})).toBe(true);
256
306
  });
257
307
 
258
308
  describe("when a custom equality matcher is installed that returns 'undefined'", function () {
259
309
  var tester = function(a, b) { return jasmine.undefined; };
260
310
 
261
311
  it("passes for two empty Objects", function () {
262
- expect(j$.matchersUtil.equals({}, {}, [tester])).toBe(true);
312
+ expect(jasmineUnderTest.matchersUtil.equals({}, {}, [tester])).toBe(true);
263
313
  });
264
314
  });
265
315
 
266
316
  it("fails for equivalents when a custom equality matcher returns false", function() {
267
317
  var tester = function(a, b) { return false; };
268
318
 
269
- expect(j$.matchersUtil.equals(1, 1, [tester])).toBe(false);
319
+ expect(jasmineUnderTest.matchersUtil.equals(1, 1, [tester])).toBe(false);
270
320
  });
271
321
 
272
322
  it("passes for an asymmetric equality tester that returns true when a custom equality tester return false", function() {
273
323
  var asymmetricTester = { asymmetricMatch: function(other) { return true; } },
274
324
  symmetricTester = function(a, b) { return false; };
275
325
 
276
- expect(j$.matchersUtil.equals(asymmetricTester, true, [symmetricTester])).toBe(true);
277
- expect(j$.matchersUtil.equals(true, asymmetricTester, [symmetricTester])).toBe(true);
326
+ expect(jasmineUnderTest.matchersUtil.equals(asymmetricTester, true, [symmetricTester])).toBe(true);
327
+ expect(jasmineUnderTest.matchersUtil.equals(true, asymmetricTester, [symmetricTester])).toBe(true);
278
328
  });
279
329
 
280
330
  it("passes when an Any is compared to an Any that checks for the same type", function() {
281
- var any1 = new j$.Any(Function),
282
- any2 = new j$.Any(Function);
331
+ var any1 = new jasmineUnderTest.Any(Function),
332
+ any2 = new jasmineUnderTest.Any(Function);
283
333
 
284
- expect(j$.matchersUtil.equals(any1, any2)).toBe(true);
334
+ expect(jasmineUnderTest.matchersUtil.equals(any1, any2)).toBe(true);
285
335
  });
286
336
 
287
337
  it("passes for null prototype objects with same properties", function () {
@@ -293,7 +343,7 @@ describe("matchersUtil", function() {
293
343
  objA.name = 'test';
294
344
  objB.name = 'test';
295
345
 
296
- expect(j$.matchersUtil.equals(objA, objB)).toBe(true);
346
+ expect(jasmineUnderTest.matchersUtil.equals(objA, objB)).toBe(true);
297
347
  });
298
348
 
299
349
  it("fails for null prototype objects with different properties", function () {
@@ -305,44 +355,44 @@ describe("matchersUtil", function() {
305
355
  objA.name = 'test';
306
356
  objB.test = 'name';
307
357
 
308
- expect(j$.matchersUtil.equals(objA, objB)).toBe(false);
358
+ expect(jasmineUnderTest.matchersUtil.equals(objA, objB)).toBe(false);
309
359
  });
310
360
  });
311
361
 
312
362
  describe("contains", function() {
313
363
  it("passes when expected is a substring of actual", function() {
314
- expect(j$.matchersUtil.contains("ABC", "BC")).toBe(true);
364
+ expect(jasmineUnderTest.matchersUtil.contains("ABC", "BC")).toBe(true);
315
365
  });
316
366
 
317
367
  it("fails when expected is a not substring of actual", function() {
318
- expect(j$.matchersUtil.contains("ABC", "X")).toBe(false);
368
+ expect(jasmineUnderTest.matchersUtil.contains("ABC", "X")).toBe(false);
319
369
  });
320
370
 
321
371
  it("passes when expected is an element in an actual array", function() {
322
- expect(j$.matchersUtil.contains(['foo', 'bar'], 'foo')).toBe(true);
372
+ expect(jasmineUnderTest.matchersUtil.contains(['foo', 'bar'], 'foo')).toBe(true);
323
373
  });
324
374
 
325
375
  it("fails when expected is not an element in an actual array", function() {
326
- expect(j$.matchersUtil.contains(['foo', 'bar'], 'baz')).toBe(false);
376
+ expect(jasmineUnderTest.matchersUtil.contains(['foo', 'bar'], 'baz')).toBe(false);
327
377
  });
328
378
 
329
379
  it("passes with mixed-element arrays", function() {
330
- expect(j$.matchersUtil.contains(["foo", {some: "bar"}], "foo")).toBe(true);
331
- expect(j$.matchersUtil.contains(["foo", {some: "bar"}], {some: "bar"})).toBe(true);
380
+ expect(jasmineUnderTest.matchersUtil.contains(["foo", {some: "bar"}], "foo")).toBe(true);
381
+ expect(jasmineUnderTest.matchersUtil.contains(["foo", {some: "bar"}], {some: "bar"})).toBe(true);
332
382
  });
333
383
 
334
384
  it("uses custom equality testers if passed in and actual is an Array", function() {
335
385
  var customTester = function(a, b) {return true;};
336
386
 
337
- expect(j$.matchersUtil.contains([1, 2], 2, [customTester])).toBe(true);
387
+ expect(jasmineUnderTest.matchersUtil.contains([1, 2], 2, [customTester])).toBe(true);
338
388
  });
339
389
 
340
390
  it("fails when actual is undefined", function() {
341
- expect(j$.matchersUtil.contains(undefined, 'A')).toBe(false);
391
+ expect(jasmineUnderTest.matchersUtil.contains(undefined, 'A')).toBe(false);
342
392
  });
343
393
 
344
394
  it("fails when actual is null", function() {
345
- expect(j$.matchersUtil.contains(null, 'A')).toBe(false);
395
+ expect(jasmineUnderTest.matchersUtil.contains(null, 'A')).toBe(false);
346
396
  });
347
397
 
348
398
  it("passes with array-like objects", function() {
@@ -351,7 +401,7 @@ describe("matchersUtil", function() {
351
401
  capturedArgs = arguments;
352
402
  }
353
403
  testFunction('foo', 'bar');
354
- expect(j$.matchersUtil.contains(capturedArgs, 'bar')).toBe(true);
404
+ expect(jasmineUnderTest.matchersUtil.contains(capturedArgs, 'bar')).toBe(true);
355
405
  });
356
406
  });
357
407
 
@@ -360,7 +410,7 @@ describe("matchersUtil", function() {
360
410
  it("builds an English sentence for a failure case", function() {
361
411
  var actual = "foo",
362
412
  name = "toBar",
363
- message = j$.matchersUtil.buildFailureMessage(name, false, actual);
413
+ message = jasmineUnderTest.matchersUtil.buildFailureMessage(name, false, actual);
364
414
 
365
415
  expect(message).toEqual("Expected 'foo' to bar.");
366
416
  });
@@ -369,7 +419,7 @@ describe("matchersUtil", function() {
369
419
  var actual = "foo",
370
420
  name = "toBar",
371
421
  isNot = true,
372
- message = message = j$.matchersUtil.buildFailureMessage(name, isNot, actual);
422
+ message = message = jasmineUnderTest.matchersUtil.buildFailureMessage(name, isNot, actual);
373
423
 
374
424
  expect(message).toEqual("Expected 'foo' not to bar.");
375
425
  });
@@ -377,7 +427,7 @@ describe("matchersUtil", function() {
377
427
  it("builds an English sentence for an arbitrary array of expected arguments", function() {
378
428
  var actual = "foo",
379
429
  name = "toBar",
380
- message = j$.matchersUtil.buildFailureMessage(name, false, actual, "quux", "corge");
430
+ message = jasmineUnderTest.matchersUtil.buildFailureMessage(name, false, actual, "quux", "corge");
381
431
 
382
432
  expect(message).toEqual("Expected 'foo' to bar 'quux', 'corge'.");
383
433
  });