screw-unit-server 0.3.0 → 0.5.3

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 (124) hide show
  1. data/CHANGES +23 -1
  2. data/README.markdown +10 -3
  3. data/Rakefile +27 -55
  4. data/VERSION.yml +4 -0
  5. data/bin/screw_unit_server +14 -4
  6. data/core/CHANGES +10 -0
  7. data/core/EXAMPLE.html +4 -4
  8. data/core/README.markdown +7 -7
  9. data/core/example/models/man.js +2 -2
  10. data/core/example/spec/suite.html +1 -1
  11. data/core/lib/jquery-1.3.2.js +4376 -0
  12. data/core/lib/jquery.fn.js +2 -1
  13. data/core/lib/jquery.print.js +13 -12
  14. data/core/lib/screw.behaviors.js +11 -9
  15. data/core/lib/screw.builder.js +26 -11
  16. data/core/lib/screw.css +2 -2
  17. data/core/lib/screw.events.js +11 -4
  18. data/core/lib/screw.matchers.js +192 -13
  19. data/core/spec/behaviors_spec.js +11 -1
  20. data/core/spec/matchers_spec.js +288 -9
  21. data/core/spec/print_spec.js +47 -8
  22. data/core/spec/suite.html +2 -1
  23. data/core/spec/with_screw_context_spec.js +9 -0
  24. data/lib/screw_unit.rb +13 -16
  25. data/lib/screw_unit/representations.rb +2 -0
  26. data/lib/screw_unit/representations/spec.html.rb +117 -0
  27. data/spec/functional/functional_spec.rb +14 -3
  28. data/spec/functional/functional_spec_helper.rb +22 -34
  29. data/spec/functional/functional_spec_server_starter.rb +68 -0
  30. data/spec/unit/js_test_core/specs/spec_file_spec.rb +45 -20
  31. data/spec/unit/unit_spec_helper.rb +24 -93
  32. data/vendor/js-test-core/CHANGES +19 -0
  33. data/vendor/js-test-core/Rakefile +2 -1
  34. data/vendor/js-test-core/lib/js_test_core.rb +26 -10
  35. data/vendor/js-test-core/lib/js_test_core/app.rb +12 -0
  36. data/vendor/js-test-core/lib/js_test_core/client.rb +97 -18
  37. data/vendor/js-test-core/lib/js_test_core/configuration.rb +35 -0
  38. data/vendor/js-test-core/lib/js_test_core/extensions.rb +3 -0
  39. data/vendor/js-test-core/lib/js_test_core/extensions/selenium/client/driver.rb +7 -0
  40. data/vendor/js-test-core/lib/js_test_core/extensions/time.rb +6 -0
  41. data/vendor/js-test-core/lib/js_test_core/models.rb +8 -0
  42. data/vendor/js-test-core/lib/js_test_core/models/selenium_session.rb +80 -0
  43. data/vendor/js-test-core/lib/js_test_core/representations.rb +11 -0
  44. data/vendor/js-test-core/lib/js_test_core/representations/dir.html.rb +24 -0
  45. data/vendor/js-test-core/lib/js_test_core/representations/not_found.html.rb +15 -0
  46. data/vendor/js-test-core/lib/js_test_core/representations/page.html.rb +41 -0
  47. data/vendor/js-test-core/lib/js_test_core/representations/spec.html.rb +24 -0
  48. data/vendor/js-test-core/lib/js_test_core/resources.rb +13 -8
  49. data/vendor/js-test-core/lib/js_test_core/resources/core_file.rb +19 -0
  50. data/vendor/js-test-core/lib/js_test_core/resources/file.rb +44 -14
  51. data/vendor/js-test-core/lib/js_test_core/resources/implementations_deprecation.rb +12 -0
  52. data/vendor/js-test-core/lib/js_test_core/resources/not_found.rb +35 -0
  53. data/vendor/js-test-core/lib/js_test_core/resources/resource.rb +16 -0
  54. data/vendor/js-test-core/lib/js_test_core/resources/selenium_session.rb +104 -0
  55. data/vendor/js-test-core/lib/js_test_core/resources/spec_file.rb +63 -0
  56. data/vendor/js-test-core/lib/js_test_core/resources/web_root.rb +5 -56
  57. data/vendor/js-test-core/lib/js_test_core/selenium_server_configuration.rb +48 -0
  58. data/vendor/js-test-core/spec/example_core/subdir/SubDirFile.js +0 -0
  59. data/vendor/js-test-core/spec/example_public/javascripts/large_file.js +59 -0
  60. data/vendor/js-test-core/spec/example_public/javascripts/subdir/bar.js +1 -0
  61. data/vendor/js-test-core/spec/example_specs/custom_dir_and_suite/passing_spec.js +6 -0
  62. data/vendor/js-test-core/spec/example_specs/custom_suite.html +8 -0
  63. data/vendor/js-test-core/spec/example_specs/foo/failing_spec.js +1 -1
  64. data/vendor/js-test-core/spec/example_specs/foo/passing_spec.js +1 -1
  65. data/vendor/js-test-core/spec/spec_helpers/be_http.rb +32 -0
  66. data/vendor/js-test-core/spec/spec_helpers/example_group.rb +36 -0
  67. data/vendor/js-test-core/spec/spec_helpers/fake_selenium_driver.rb +27 -0
  68. data/vendor/js-test-core/spec/spec_helpers/show_test_exceptions.rb +22 -0
  69. data/vendor/js-test-core/spec/unit/js_test_core/client_spec.rb +140 -85
  70. data/vendor/js-test-core/spec/unit/js_test_core/configuration_spec.rb +44 -0
  71. data/vendor/js-test-core/spec/unit/js_test_core/models/selenium_session_spec.rb +85 -0
  72. data/vendor/js-test-core/spec/unit/js_test_core/resources/core_file_spec.rb +60 -0
  73. data/vendor/js-test-core/spec/unit/js_test_core/resources/file_spec.rb +61 -68
  74. data/vendor/js-test-core/spec/unit/js_test_core/resources/implementations_deprecation_spec.rb +18 -0
  75. data/vendor/js-test-core/spec/unit/js_test_core/resources/not_found_spec.rb +51 -0
  76. data/vendor/js-test-core/spec/unit/js_test_core/resources/selenium_session_spec.rb +362 -0
  77. data/vendor/js-test-core/spec/unit/js_test_core/resources/spec_file_spec.rb +120 -0
  78. data/vendor/js-test-core/spec/unit/js_test_core/resources/web_root_spec.rb +14 -89
  79. data/vendor/js-test-core/spec/unit/js_test_core/selenium_server_configuration_spec.rb +49 -0
  80. data/vendor/js-test-core/spec/unit/unit_spec_helper.rb +16 -113
  81. data/vendor/js-test-core/vendor/lucky-luciano/README.markdown +7 -0
  82. data/vendor/js-test-core/vendor/lucky-luciano/lib/lucky_luciano.rb +4 -0
  83. data/vendor/js-test-core/vendor/lucky-luciano/lib/lucky_luciano/resource.rb +135 -0
  84. data/vendor/js-test-core/vendor/lucky-luciano/lib/lucky_luciano/rspec.rb +4 -0
  85. data/vendor/js-test-core/vendor/lucky-luciano/lib/lucky_luciano/rspec/be_http.rb +32 -0
  86. data/vendor/js-test-core/vendor/lucky-luciano/spec/lucky_luciano/resource_spec.rb +231 -0
  87. data/vendor/js-test-core/vendor/lucky-luciano/spec/spec_helper.rb +48 -0
  88. data/vendor/js-test-core/vendor/lucky-luciano/spec/spec_suite.rb +4 -0
  89. metadata +143 -129
  90. data/core/TODO +0 -2
  91. data/core/lib/jquery-1.2.3.js +0 -3408
  92. data/core/lib/screw.assets.js +0 -36
  93. data/core/lib/screw.server.js +0 -21
  94. data/lib/screw_unit/resources.rb +0 -2
  95. data/lib/screw_unit/resources/spec.rb +0 -37
  96. data/spec/unit/js_test_core/specs/spec_dir_spec.rb +0 -43
  97. data/vendor/js-test-core/lib/js_test_core/rack.rb +0 -2
  98. data/vendor/js-test-core/lib/js_test_core/rack/commonlogger.rb +0 -5
  99. data/vendor/js-test-core/lib/js_test_core/rails_server.rb +0 -22
  100. data/vendor/js-test-core/lib/js_test_core/resources/dir.rb +0 -52
  101. data/vendor/js-test-core/lib/js_test_core/resources/file_not_found.rb +0 -15
  102. data/vendor/js-test-core/lib/js_test_core/resources/runners.rb +0 -15
  103. data/vendor/js-test-core/lib/js_test_core/resources/runners/firefox_runner.rb +0 -75
  104. data/vendor/js-test-core/lib/js_test_core/resources/specs/spec_dir.rb +0 -50
  105. data/vendor/js-test-core/lib/js_test_core/resources/specs/spec_file.rb +0 -17
  106. data/vendor/js-test-core/lib/js_test_core/resources/suite.rb +0 -24
  107. data/vendor/js-test-core/lib/js_test_core/resources/suite_finish.rb +0 -19
  108. data/vendor/js-test-core/lib/js_test_core/selenium.rb +0 -2
  109. data/vendor/js-test-core/lib/js_test_core/selenium/selenium_driver.rb +0 -5
  110. data/vendor/js-test-core/lib/js_test_core/server.rb +0 -111
  111. data/vendor/js-test-core/lib/js_test_core/thin.rb +0 -3
  112. data/vendor/js-test-core/lib/js_test_core/thin/backends/js_test_core_server.rb +0 -9
  113. data/vendor/js-test-core/lib/js_test_core/thin/js_test_core_connection.rb +0 -42
  114. data/vendor/js-test-core/spec/unit/js_test_core/rails_server_spec.rb +0 -45
  115. data/vendor/js-test-core/spec/unit/js_test_core/resources/dir_spec.rb +0 -42
  116. data/vendor/js-test-core/spec/unit/js_test_core/resources/file_not_found_spec.rb +0 -26
  117. data/vendor/js-test-core/spec/unit/js_test_core/resources/runner_spec.rb +0 -24
  118. data/vendor/js-test-core/spec/unit/js_test_core/resources/runners/firefox_runner_spec.rb +0 -197
  119. data/vendor/js-test-core/spec/unit/js_test_core/resources/specs/spec_dir_spec.rb +0 -79
  120. data/vendor/js-test-core/spec/unit/js_test_core/resources/specs/spec_file_spec.rb +0 -42
  121. data/vendor/js-test-core/spec/unit/js_test_core/resources/suite_finish_spec.rb +0 -94
  122. data/vendor/js-test-core/spec/unit/js_test_core/resources/suite_spec.rb +0 -44
  123. data/vendor/js-test-core/spec/unit/js_test_core/server_spec.rb +0 -131
  124. data/vendor/js-test-core/spec/unit/thin/js_test_core_connection_spec.rb +0 -92
@@ -2,9 +2,19 @@ Screw.Unit(function() {
2
2
  var global_before_invoked = false, global_after_invoked = false;
3
3
  before(function() { global_before_invoked = true });
4
4
  after(function() { global_after_invoked = true });
5
-
5
+
6
6
  describe('Behaviors', function() {
7
7
  describe('#run', function() {
8
+ describe("elapsed time", function() {
9
+ it("displays the elapsed time after the Suite finishes", function() {
10
+ var status = $(".status");
11
+ status.fn("display");
12
+ var time_elapsed_matches = /([0-9]+\.[0-9]+) seconds/.exec(status.html());
13
+ var time_elapsed = parseFloat(time_elapsed_matches[1]);
14
+ expect(time_elapsed > 0.0).to(be_true);
15
+ });
16
+ });
17
+
8
18
  describe("a simple [describe]", function() {
9
19
  it("invokes the global [before] before an [it]", function() {
10
20
  expect(global_before_invoked).to(equal, true);
@@ -6,15 +6,41 @@ Screw.Unit(function() {
6
6
  expect(true).to_not(equal, false);
7
7
  });
8
8
 
9
- describe('when given an object', function() {
10
- it("matches Objects with the same keys and values", function() {
11
- expect({a: 'b', c: 'd'}).to(equal, {a: 'b', c: 'd'});
12
- expect({a: 'b', c: 'd', e: 'f'}).to_not(equal, {a: 'b', c: 'd', e: 'G'});
9
+ describe('when actual is an object', function() {
10
+ describe("when expected has the same keys and values", function() {
11
+ it("matches successfully", function() {
12
+ expect({a: 'b', c: 'd'}).to(equal, {a: 'b', c: 'd'});
13
+ });
13
14
  });
14
15
 
16
+ describe("when expected has different keys and values", function() {
17
+ it("does not match", function() {
18
+ expect({a: 'b', c: 'd', e: 'f'}).to_not(equal, {a: 'b', c: 'd', e: 'G'});
19
+ });
20
+ });
21
+
22
+ describe("when expected is undefined", function() {
23
+ it("does not match", function() {
24
+ expect({}).to_not(equal, undefined);
25
+ });
26
+ });
27
+ });
28
+
29
+ describe("when actual is undefined", function() {
30
+ describe("when expected is undefined", function() {
31
+ it("matches successfully", function() {
32
+ expect(undefined).to(equal, undefined);
33
+ });
34
+ });
35
+
36
+ describe("when expected is an empty object", function() {
37
+ it("does not match", function() {
38
+ expect(undefined).to_not(equal, {});
39
+ });
40
+ });
15
41
  });
16
42
 
17
- describe('when given an array', function() {
43
+ describe('when actual is an array', function() {
18
44
  it("matches Arrays with the same elements", function() {
19
45
  expect([1, 2, 4]).to(equal, [1, 2, 4]);
20
46
  expect([1, 2, 3]).to_not(equal, [3, 2, 1]);
@@ -25,7 +51,21 @@ Screw.Unit(function() {
25
51
  expect([{a: 'b'}, {c: 'd'}]).to_not(equal, [{a: 'b'}, {c: 'E'}]);
26
52
  });
27
53
  });
28
-
54
+
55
+ describe("when actual is a hash", function() {
56
+ it("matches hashes with the same key-value pairs", function() {
57
+ expect({"a":"b", "c":"d"}).to(equal, {"a":"b", "c":"d"});
58
+ expect({"a":"b", "c":"e"}).to_not(equal, {"a":"b", "c":"d"});
59
+ expect({"a":"b", "d":"d"}).to_not(equal, {"a":"b", "c":"d"});
60
+ });
61
+
62
+ it("recursively applies equality to complex hashes", function() {
63
+ expect({"a":"b", "c": {"e":"f", "g":"h"}}).to(equal, {"a":"b", "c": {"e":"f", "g":"h"}});
64
+ expect({"a":"b", "c": {"e":"f", "g":"i"}}).to_not(equal, {"a":"b", "c": {"e":"f", "g":"h"}});
65
+ expect({"a":"b", "c": {"e":"f", "h":"h"}}).to_not(equal, {"a":"b", "c": {"e":"f", "g":"h"}});
66
+ });
67
+ });
68
+
29
69
  describe(".failure_message", function() {
30
70
  it('prints "expected [expected] to (not) be equal [actual]"', function() {
31
71
  var message = null;
@@ -39,21 +79,21 @@ Screw.Unit(function() {
39
79
  });
40
80
 
41
81
  describe('#match', function() {
42
- describe('when given a regular expression', function() {
82
+ describe('when actual is a regular expression', function() {
43
83
  it("matches Strings produced by the grammar", function() {
44
84
  expect("The wheels of the bus").to(match, /bus/);
45
85
  expect("The wheels of the bus").to_not(match, /boat/);
46
86
  });
47
87
  });
48
88
 
49
- describe('when given a string', function() {
89
+ describe('when actual is a string', function() {
50
90
  it("matches [expected]s containing [actual]s", function() {
51
91
  expect("The wheels of the bus").to(match, "wheels");
52
92
  expect("The wheels of the bus").to_not(match, "oars");
53
93
  });
54
94
  });
55
95
 
56
- describe('when given an integer', function() {
96
+ describe('when actual is an integer', function() {
57
97
  it("matches [expected]s containing [actual]s", function() {
58
98
  expect("1 time").to(match, 1);
59
99
  expect("2 times").to_not(match, 3);
@@ -89,5 +129,244 @@ Screw.Unit(function() {
89
129
  });
90
130
  });
91
131
  });
132
+
133
+ describe('#have_length', function() {
134
+ it("matches Arrays of the expected length", function() {
135
+ expect([]).to(have_length, 0);
136
+ expect([1]).to(have_length, 1);
137
+ expect([1, 2, 3]).to_not(have_length, 4);
138
+ });
139
+
140
+ describe(".failure_message", function() {
141
+ it("prints 'expected [actual] to (not) have length [expected]", function() {
142
+ var message = null;
143
+ try { expect([1, 2]).to(have_length, 4) } catch(e) { message = e }
144
+ expect(message).to(equal, 'expected [ 1, 2 ] to have length 4');
145
+
146
+ try { expect([1]).to_not(have_length, 1) } catch(e) { message = e }
147
+ expect(message).to(equal, 'expected [ 1 ] to not have length 1');
148
+ });
149
+ });
150
+ });
151
+
152
+ describe('#be_null', function() {
153
+ it("matches null", function() {
154
+ expect(null).to(be_null);
155
+ expect(1).to_not(be_null);
156
+ });
157
+
158
+ describe(".failure_message", function() {
159
+ it("prints 'expected [actual] to (not) be null", function() {
160
+ var message = null;
161
+ try { expect(1).to(be_null) } catch(e) { message = e }
162
+ expect(message).to(equal, 'expected 1 to be null');
163
+
164
+ try { expect(null).to_not(be_null) } catch(e) { message = e }
165
+ expect(message).to(equal, 'expected null to not be null');
166
+ });
167
+ });
168
+ });
169
+
170
+ describe('#be_undefined', function() {
171
+ it("matches undefined", function() {
172
+ expect(undefined).to(be_undefined);
173
+ expect(1).to_not(be_undefined);
174
+ });
175
+
176
+ describe(".failure_message", function() {
177
+ it("prints 'expected [actual] to (not) be undefined", function() {
178
+ var message = undefined;
179
+ try { expect(1).to(be_undefined) } catch(e) { message = e }
180
+ expect(message).to(equal, 'expected 1 to be undefined');
181
+
182
+ try { expect(undefined).to_not(be_undefined) } catch(e) { message = e }
183
+ expect(message).to(equal, 'expected undefined to not be undefined');
184
+ });
185
+ });
186
+ });
187
+
188
+ describe('#be_true', function() {
189
+ it("matches values that are considered true conditions", function() {
190
+ expect(true).to(be_true);
191
+ expect(1).to(be_true);
192
+ expect(false).to_not(be_true);
193
+ expect(undefined).to_not(be_true);
194
+ expect(null).to_not(be_true);
195
+ });
196
+
197
+ describe(".failure_message", function() {
198
+ it("prints 'expected [actual] to (not) be true", function() {
199
+ var message = true;
200
+ try { expect(false).to(be_true) } catch(e) { message = e }
201
+ expect(message).to(equal, 'expected false to be true');
202
+
203
+ try { expect(true).to_not(be_true) } catch(e) { message = e }
204
+ expect(message).to(equal, 'expected true to not be true');
205
+ });
206
+ });
207
+ });
208
+
209
+ describe('#be_false', function() {
210
+ it("matches values that are considered false conditions", function() {
211
+ expect(false).to(be_false);
212
+ expect(undefined).to(be_false);
213
+ expect(null).to(be_false);
214
+ expect(true).to_not(be_false);
215
+ expect(1).to_not(be_false);
216
+ });
217
+
218
+ describe(".failure_message", function() {
219
+ it("prints 'expected [actual] to (not) be false", function() {
220
+ var message = false;
221
+ try { expect(true).to(be_false) } catch(e) { message = e }
222
+ expect(message).to(equal, 'expected true to be false');
223
+
224
+ try { expect(false).to_not(be_false) } catch(e) { message = e }
225
+ expect(message).to(equal, 'expected false to not be false');
226
+ });
227
+ });
228
+ });
229
+
230
+ describe('#match_selector', function() {
231
+ var elt;
232
+ before(function() {
233
+ elt = $("<div class='foo'></div>");
234
+ });
235
+
236
+ it("matches a jQuery element against the expected selector", function() {
237
+ expect(elt).to(match_selector, 'div.foo');
238
+ expect(elt).to_not(match_selector, 'div.bar');
239
+ });
240
+
241
+ describe(".failure_message", function() {
242
+ it("prints 'expected [actual] to (not) match selector [expected]", function() {
243
+ var message = false;
244
+ try { expect(elt).to(match_selector, 'div.bar') } catch(e) { message = e }
245
+ expect(message).to(equal, 'expected $([ <div class="foo"> ]) to match selector div.bar');
246
+
247
+ try { expect(elt).to_not(match_selector, 'div.foo') } catch(e) { message = e }
248
+ expect(message).to(equal, 'expected $([ <div class="foo"> ]) to not match selector div.foo');
249
+ });
250
+ });
251
+ });
252
+
253
+ describe('#contain_selector', function() {
254
+ var elt;
255
+ before(function() {
256
+ elt = $("<div><div class='foo'></div></div>");
257
+ });
258
+
259
+ it("matches a jQuery element against the expected selector", function() {
260
+ expect(elt).to(contain_selector, 'div.foo');
261
+ expect(elt).to_not(contain_selector, 'div.bar');
262
+ });
263
+
264
+ describe(".failure_message", function() {
265
+ it("prints 'expected [actual] to (not) match selector [expected]", function() {
266
+ var message = false;
267
+ try { expect(elt).to(contain_selector, 'div.bar') } catch(e) { message = e }
268
+ expect(message).to(equal, 'expected $([ <div> ]) to contain selector div.bar');
269
+
270
+ try { expect(elt).to_not(contain_selector, 'div.foo') } catch(e) { message = e }
271
+ expect(message).to(equal, 'expected $([ <div> ]) to not contain selector div.foo');
272
+ });
273
+ });
274
+ });
275
+
276
+ describe('#be_gt', function() {
277
+ it('matches integers greater than the expected value', function() {
278
+ expect(2).to(be_gt, 1);
279
+ expect(1).to(be_gt, 0);
280
+ expect(0).to(be_gt, -1);
281
+ expect(0).to_not(be_gt, 0);
282
+ expect(-1).to_not(be_gt, 0);
283
+ expect(0).to_not(be_gt, 1);
284
+ expect(1).to_not(be_gt, 5);
285
+ });
286
+
287
+ describe(".failure_message", function() {
288
+ it('prints "expected [expected] to (not) be greater than [actual]"', function() {
289
+ var message = null;
290
+ try { expect(1).to(be_gt, 2) } catch(e) { message = e }
291
+ expect(message).to(equal, 'expected 1 to be greater than 2');
292
+
293
+ try { expect(2).to_not(be_gt, 1) } catch(e) { message = e }
294
+ expect(message).to(equal, 'expected 2 to not be greater than 1');
295
+ });
296
+ });
297
+ });
298
+
299
+ describe('#be_gte', function() {
300
+ it('matches integers greater than or equal to the expected value', function() {
301
+ expect(2).to(be_gte, 1);
302
+ expect(1).to(be_gte, 0);
303
+ expect(0).to(be_gte, -1);
304
+ expect(-1).to(be_gte, -1);
305
+ expect(0).to(be_gte, 0);
306
+ expect(1).to(be_gte, 1);
307
+ expect(-1).to_not(be_gte, 0);
308
+ expect(0).to_not(be_gte, 1);
309
+ expect(1).to_not(be_gte, 5);
310
+ });
311
+
312
+ describe(".failure_message", function() {
313
+ it('prints "expected [expected] to (not) be greater than or equal to [actual]"', function() {
314
+ var message = null;
315
+ try { expect(1).to(be_gte, 2) } catch(e) { message = e }
316
+ expect(message).to(equal, 'expected 1 to be greater than or equal to 2');
317
+
318
+ try { expect(2).to_not(be_gte, 1) } catch(e) { message = e }
319
+ expect(message).to(equal, 'expected 2 to not be greater than or equal to 1');
320
+ });
321
+ });
322
+ });
323
+
324
+ describe('#be_lt', function() {
325
+ it('matches integers less than the expected value', function() {
326
+ expect(1).to(be_lt, 2);
327
+ expect(0).to(be_lt, 1);
328
+ expect(-1).to(be_lt, 0);
329
+ expect(0).to_not(be_lt, 0);
330
+ expect(0).to_not(be_lt, -1);
331
+ expect(1).to_not(be_lt, 0);
332
+ expect(5).to_not(be_lt, 1);
333
+ });
334
+
335
+ describe(".failure_message", function() {
336
+ it('prints "expected [expected] to (not) be less than [actual]"', function() {
337
+ var message = null;
338
+ try { expect(2).to(be_lt, 1) } catch(e) { message = e }
339
+ expect(message).to(equal, 'expected 2 to be less than 1');
340
+
341
+ try { expect(1).to_not(be_lt, 2) } catch(e) { message = e }
342
+ expect(message).to(equal, 'expected 1 to not be less than 2');
343
+ });
344
+ });
345
+ });
346
+
347
+ describe('#be_lte', function() {
348
+ it('matches integers less than or equal to the expected value', function() {
349
+ expect(1).to(be_lte, 2);
350
+ expect(0).to(be_lte, 1);
351
+ expect(-1).to(be_lte, 0);
352
+ expect(-1).to(be_lte, -1);
353
+ expect(0).to(be_lte, 0);
354
+ expect(1).to(be_lte, 1);
355
+ expect(0).to_not(be_lte, -1);
356
+ expect(1).to_not(be_lte, 0);
357
+ expect(5).to_not(be_lte, 1);
358
+ });
359
+
360
+ describe(".failure_message", function() {
361
+ it('prints "expected [expected] to (not) be less than or equal to [actual]"', function() {
362
+ var message = null;
363
+ try { expect(2).to(be_lte, 1) } catch(e) { message = e }
364
+ expect(message).to(equal, 'expected 2 to be less than or equal to 1');
365
+
366
+ try { expect(1).to_not(be_lte, 2) } catch(e) { message = e }
367
+ expect(message).to(equal, 'expected 1 to not be less than or equal to 2');
368
+ });
369
+ });
370
+ });
92
371
  });
93
372
  });
@@ -48,16 +48,41 @@ Screw.Unit(function() {
48
48
 
49
49
  describe('when given a function', function() {
50
50
  it("returns the function's signature", function() {
51
- expect($.print(function() {})).to(equal, 'function ()');
52
- expect($.print(function foo() {})).to(equal, 'function foo()');
53
- expect($.print(function foo(bar) {})).to(equal, 'function foo(bar)');
51
+ expect($.print(function() {})).to(match, /function\s*\(\)/);
52
+ expect($.print(function foo() {})).to(match, /function\s*foo\(\)/);
53
+ expect($.print(function foo(bar) {})).to(match, /function\s*foo\(bar\)/);
54
54
  });
55
55
  });
56
56
 
57
+ describe('when given a RegExp', function() {
58
+ it('should print the regexp', function() {
59
+ expect($.print(/abc/i)).to(equal, '/abc/i');
60
+ });
61
+ });
62
+
63
+ describe('when given NaN', function() {
64
+ it('should print the string "NaN"', function() {
65
+ expect($.print(NaN)).to(equal, 'NaN');
66
+ });
67
+ });
68
+
69
+ describe('when given 0', function() {
70
+ it('should print the string "0"', function() {
71
+ expect($.print(0)).to(equal, '0');
72
+ });
73
+ });
74
+
57
75
  describe('when given an element', function() {
58
76
  it("returns the string representation of the element", function() {
59
- expect($.print($('<div>').get(0))).to(equal, '<div>');
60
- expect($.print($('<div foo="bar">').get(0))).to(equal, '<div>');
77
+ expect($.print($('<div></div>').get(0))).to(equal, '<div>');
78
+ expect($.print($('<div foo="bar"></div>').get(0))).to(equal, '<div>');
79
+ expect($.print($('<div class="foo" id="bar"></div>').get(0))).to(equal, '<div class="foo" id="bar">');
80
+ });
81
+
82
+ describe('when the element is an img', function() {
83
+ it('prints out the img src attribute', function() {
84
+ expect($.print($('<img src="test.png"/>'))).to(match, /<img src=".+?test.png">/);
85
+ })
61
86
  });
62
87
  });
63
88
 
@@ -89,12 +114,26 @@ Screw.Unit(function() {
89
114
  });
90
115
  });
91
116
 
117
+ describe('when given arguments', function() {
118
+ it("returns the printed array of elements ", function() {
119
+ var args = null;
120
+ (function(){ args = arguments })(1,2,3);
121
+ expect($.print(args)).to(equal, '[ 1, 2, 3 ]');
122
+ });
123
+ });
124
+
92
125
  describe('when given a jQuery', function() {
93
- it("returns the printed array of elements engirthed in '$()' ", function() {
94
- expect($.print($('<div>'))).to(equal, '$([ <div> ])');
126
+ it("returns the printed array of elements engirthed in '$()'", function() {
127
+ expect($.print($('<div></div>'))).to(equal, '$([ <div> ])');
95
128
  });
96
129
  });
97
130
 
131
+ describe('when given a NodeList', function() {
132
+ it("returns the printed array of elements in the list", function() {
133
+ expect($.print(document.getElementsByTagName('body'))).to(equal, '[ <body> ]');
134
+ });
135
+ });
136
+
98
137
  describe('when given an object', function() {
99
138
  it("returns the keys and values of the object, enraptured with curly braces", function() {
100
139
  expect($.print({})).to(equal, '{}');
@@ -110,7 +149,7 @@ Screw.Unit(function() {
110
149
  it("returns elipses for circularities", function() {
111
150
  var circular = {};
112
151
  circular[0] = circular;
113
- expect($.print(circular)).to(equal, '{ 0: { 0: ... } }');
152
+ expect($.print(circular)).to(equal, '{ 0: ... }');
114
153
  });
115
154
  });
116
155
  });
@@ -1,6 +1,6 @@
1
1
  <html>
2
2
  <head>
3
- <script src="../lib/jquery-1.2.3.js"></script>
3
+ <script src="../lib/jquery-1.3.2.js"></script>
4
4
  <script src="../lib/jquery.fn.js"></script>
5
5
  <script src="../lib/jquery.print.js"></script>
6
6
  <script src="../lib/screw.builder.js"></script>
@@ -11,6 +11,7 @@
11
11
  <script src="behaviors_spec.js"></script>
12
12
  <script src="matchers_spec.js"></script>
13
13
  <script src="print_spec.js"></script>
14
+ <script src="with_screw_context_spec.js"></script>
14
15
 
15
16
  <link rel="stylesheet" href="../lib/screw.css">
16
17
  </head>