screw_server 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (65) hide show
  1. data/Gemfile.run +3 -0
  2. data/Gemfile.run.lock +41 -0
  3. data/assets/screw-jslint.js +69 -0
  4. data/assets/screw-server.js +120 -0
  5. data/assets/screw.css +70 -0
  6. data/assets/vendor/fulljslint.js +5699 -0
  7. data/assets/vendor/screw-unit/CHANGES +7 -0
  8. data/assets/vendor/screw-unit/EXAMPLE.html +68 -0
  9. data/assets/vendor/screw-unit/LICENSE +22 -0
  10. data/assets/vendor/screw-unit/README.markdown +307 -0
  11. data/assets/vendor/screw-unit/example/models/cat.js +5 -0
  12. data/assets/vendor/screw-unit/example/models/man.js +17 -0
  13. data/assets/vendor/screw-unit/example/spec/matchers/have.js +8 -0
  14. data/assets/vendor/screw-unit/example/spec/models/cat_spec.js +31 -0
  15. data/assets/vendor/screw-unit/example/spec/models/man_spec.js +34 -0
  16. data/assets/vendor/screw-unit/example/spec/spec_helper.js +5 -0
  17. data/assets/vendor/screw-unit/example/spec/suite.html +25 -0
  18. data/assets/vendor/screw-unit/lib/jquery-1.2.6.js +3549 -0
  19. data/assets/vendor/screw-unit/lib/jquery.fn.js +29 -0
  20. data/assets/vendor/screw-unit/lib/jquery.print.js +109 -0
  21. data/assets/vendor/screw-unit/lib/screw.behaviors.js +101 -0
  22. data/assets/vendor/screw-unit/lib/screw.builder.js +90 -0
  23. data/assets/vendor/screw-unit/lib/screw.css +90 -0
  24. data/assets/vendor/screw-unit/lib/screw.events.js +45 -0
  25. data/assets/vendor/screw-unit/lib/screw.matchers.js +203 -0
  26. data/assets/vendor/screw-unit/spec/behaviors_spec.js +188 -0
  27. data/assets/vendor/screw-unit/spec/matchers_spec.js +391 -0
  28. data/assets/vendor/screw-unit/spec/print_spec.js +158 -0
  29. data/assets/vendor/screw-unit/spec/spec_helper.js +0 -0
  30. data/assets/vendor/screw-unit/spec/suite.html +18 -0
  31. data/assets/vendor/smoke/LICENSE +22 -0
  32. data/assets/vendor/smoke/README.markdown +68 -0
  33. data/assets/vendor/smoke/lib/smoke.core.js +49 -0
  34. data/assets/vendor/smoke/lib/smoke.mock.js +219 -0
  35. data/assets/vendor/smoke/lib/smoke.stub.js +29 -0
  36. data/assets/vendor/smoke/plugins/screw.mocking.js +26 -0
  37. data/assets/vendor/smoke/spec/core_spec.js +115 -0
  38. data/assets/vendor/smoke/spec/mock_spec.js +431 -0
  39. data/assets/vendor/smoke/spec/screw_integration_spec.js +17 -0
  40. data/assets/vendor/smoke/spec/spec_helper.js +0 -0
  41. data/assets/vendor/smoke/spec/stub_spec.js +17 -0
  42. data/assets/vendor/smoke/spec/su/jquery-1.2.3.js +3408 -0
  43. data/assets/vendor/smoke/spec/su/jquery.fn.js +29 -0
  44. data/assets/vendor/smoke/spec/su/jquery.print.js +108 -0
  45. data/assets/vendor/smoke/spec/su/screw.behaviors.js +91 -0
  46. data/assets/vendor/smoke/spec/su/screw.builder.js +80 -0
  47. data/assets/vendor/smoke/spec/su/screw.css +74 -0
  48. data/assets/vendor/smoke/spec/su/screw.events.js +38 -0
  49. data/assets/vendor/smoke/spec/su/screw.matchers.js +65 -0
  50. data/assets/vendor/smoke/spec/suite.html +29 -0
  51. data/bin/screw_server +43 -0
  52. data/lib/screw_server/app.rb +197 -0
  53. data/lib/screw_server/base.rb +21 -0
  54. data/lib/screw_server/fixture_file.rb +17 -0
  55. data/lib/screw_server/jslint_suite.rb +51 -0
  56. data/lib/screw_server/spec_file.rb +76 -0
  57. data/lib/screw_server.rb +2 -0
  58. data/screw_server.gemspec +28 -0
  59. data/views/index.haml +13 -0
  60. data/views/missing_spec_helper.haml +12 -0
  61. data/views/no_specs.haml +11 -0
  62. data/views/run_spec.haml +30 -0
  63. data/views/sample_spec.js +7 -0
  64. data/views/sample_spec_helper.js +2 -0
  65. metadata +257 -0
@@ -0,0 +1,188 @@
1
+ Screw.Unit(function() {
2
+ var global_before_invoked = false, global_after_invoked = false;
3
+ before(function() { global_before_invoked = true });
4
+ after(function() { global_after_invoked = true });
5
+
6
+ describe('Behaviors', function() {
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
+
18
+ describe("a simple [describe]", function() {
19
+ it("invokes the global [before] before an [it]", function() {
20
+ expect(global_before_invoked).to(equal, true);
21
+ global_before_invoked = false;
22
+ });
23
+
24
+ it("invokes the global [before] before each [it]", function() {
25
+ expect(global_before_invoked).to(equal, true);
26
+ global_after_invoked = false;
27
+ });
28
+
29
+ it("invokes the global [after] after an [it]", function() {
30
+ expect(global_after_invoked).to(equal, true);
31
+ });
32
+ });
33
+
34
+ describe("a [describe] with a [before] and [after] block", function() {
35
+ var before_invoked = false, after_invoked = false;
36
+ before(function() { before_invoked = true });
37
+ after(function() { after_invoked = true });
38
+
39
+ describe('[after] blocks', function() {
40
+ it("does not invoke the [after] until after the first [it]", function() {
41
+ expect(after_invoked).to(equal, false);
42
+ });
43
+
44
+ it("invokes the [after] after the first [it]", function() {
45
+ expect(after_invoked).to(equal, true);
46
+ after_invoked = false;
47
+ });
48
+
49
+ it("invokes the [after] after each [it]", function() {
50
+ expect(after_invoked).to(equal, true);
51
+ });
52
+ });
53
+
54
+ describe('[before] blocks', function() {
55
+ it("invokes the [before] before an it", function() {
56
+ expect(before_invoked).to(equal, true);
57
+ before_invoked = false;
58
+ });
59
+
60
+ it("invokes the [before] before each it", function() {
61
+ expect(before_invoked).to(equal, true);
62
+ });
63
+ });
64
+ });
65
+
66
+ describe("A [describe] with two [before] and two [after] blocks", function() {
67
+ var before_invocations = [], after_invocations = [];
68
+ before(function() { before_invocations.push('before 1') });
69
+ before(function() { before_invocations.push('before 2') });
70
+
71
+ after(function() { after_invocations.push('after 1') });
72
+ after(function() { after_invocations.push('after 2') });
73
+
74
+ it("invokes the [before]s in lexical order before each [it]", function() {
75
+ expect(before_invocations).to(equal, ['before 1', 'before 2']);
76
+ });
77
+
78
+ it("invokes the [afters]s in lexical order after each [it]", function() {
79
+ expect(after_invocations).to(equal, ['after 1', 'after 2']);
80
+ });
81
+ });
82
+
83
+ describe("A describe with a nested describe", function() {
84
+ var before_invocations = [], after_invocations = [];
85
+ before(function() {
86
+ before_invocations = [];
87
+ before_invocations.push("outermost before");
88
+ });
89
+
90
+ after(function() {
91
+ after_invocations = [];
92
+ after_invocations.push("outermost after");
93
+ });
94
+
95
+ it("outside a nested [describe], does not invoke any of the nested's [before]s", function() {
96
+ expect(before_invocations).to(equal, ["outermost before"]);
97
+ });
98
+
99
+ it("outside a nested [describe], does not invoke any of the nested's [after]s", function() {
100
+ expect(after_invocations).to(equal, ["outermost after"]);
101
+ });
102
+
103
+ describe("a nested [describe]", function() {
104
+ before(function() {
105
+ before_invocations.push("inner before");
106
+ });
107
+
108
+ after(function() {
109
+ after_invocations.push("inner after");
110
+ });
111
+
112
+ it("runs [before]s in the parent [describe] before each [it]", function() {
113
+ expect(before_invocations).to(equal, ["outermost before", "inner before"]);
114
+ });
115
+
116
+ it("runs [after]s in the parent [describe] after each [it]", function() {
117
+ expect(after_invocations).to(equal, ["outermost after", "inner after"]);
118
+ });
119
+
120
+ describe("a doubly nested [describe]", function() {
121
+ before(function() {
122
+ before_invocations.push('innermost before');
123
+ });
124
+
125
+ after(function() {
126
+ after_invocations.push('innermost after');
127
+ });
128
+
129
+ describe('[before] blocks', function() {
130
+ it("runs [before]s in all ancestors before an [it]", function() {
131
+ expect(before_invocations).to(equal, ["outermost before", "inner before", "innermost before"]);
132
+ });
133
+
134
+ it("runs [before]s in all ancestors before each [it]", function() {
135
+ expect(before_invocations).to(equal, ["outermost before", "inner before", "innermost before"]);
136
+ });
137
+ });
138
+
139
+ describe('[after] blocks', function() {
140
+ it("runs [after]s in all ancestors after an [it]", function() {
141
+ expect(after_invocations).to(equal, ["outermost after", "inner after", "innermost after"]);
142
+ });
143
+
144
+ it("runs [after]s in all ancestors after each [it]", function() {
145
+ expect(after_invocations).to(equal, ["outermost after", "inner after", "innermost after"]);
146
+ });
147
+ });
148
+ });
149
+ });
150
+ });
151
+
152
+ describe("A describe block with exceptions", function() {
153
+ var after_invoked = false;
154
+ after(function() {
155
+ after_invoked = true;
156
+ });
157
+
158
+ describe("an exception in a test", function() {
159
+ it("fails because it throws an exception", function() {
160
+ throw('an exception');
161
+ });
162
+
163
+ it("invokes [after]s even if the previous [it] raised an exception", function() {
164
+ expect(after_invoked).to(equal, true);
165
+ });
166
+ });
167
+ });
168
+ });
169
+
170
+ describe("#selector", function() {
171
+ describe('a [describe]', function() {
172
+ it('manufactures a CSS selector that uniquely locates the [describe]', function() {
173
+ $('.describe').each(function() {
174
+ expect($($(this).fn('selector')).get(0)).to(equal, $(this).get(0))
175
+ });
176
+ });
177
+ });
178
+
179
+ describe('an [it]', function() {
180
+ it('manufactures a CSS selector that uniquely locates the [it]', function() {
181
+ $('.it').each(function() {
182
+ expect($($(this).fn('selector')).get(0)).to(equal, $(this).get(0))
183
+ });
184
+ });
185
+ });
186
+ });
187
+ });
188
+ });
@@ -0,0 +1,391 @@
1
+ Screw.Unit(function() {
2
+ describe("Matchers", function() {
3
+ describe('#equal', function() {
4
+ it("invokes the provided matcher on a call to expect", function() {
5
+ expect(true).to(equal, true);
6
+ expect(true).to_not(equal, false);
7
+ });
8
+
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
+ });
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
+ });
41
+ });
42
+
43
+ describe('when actual is an array', function() {
44
+ it("matches Arrays with the same elements", function() {
45
+ expect([1, 2, 4]).to(equal, [1, 2, 4]);
46
+ expect([1, 2, 3]).to_not(equal, [3, 2, 1]);
47
+ });
48
+
49
+ it("recursively applies equality to complex elements", function() {
50
+ expect([{a: 'b'}, {c: 'd'}]).to(equal, [{a: 'b'}, {c: 'd'}]);
51
+ expect([{a: 'b'}, {c: 'd'}]).to_not(equal, [{a: 'b'}, {c: 'E'}]);
52
+ });
53
+ });
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
+
69
+ describe(".failure_message", function() {
70
+ it('prints "expected [expected] to (not) be equal [actual]"', function() {
71
+ var message = null;
72
+ try { expect(1).to(equal, 2) } catch(e) { message = e }
73
+ expect(message).to(equal, 'expected 1 to equal 2');
74
+
75
+ try { expect(1).to_not(equal, 1) } catch(e) { message = e }
76
+ expect(message).to(equal, 'expected 1 to not equal 1');
77
+ });
78
+ });
79
+ });
80
+
81
+ describe('#match', function() {
82
+ describe('when actual is a regular expression', function() {
83
+ it("matches Strings produced by the grammar", function() {
84
+ expect("The wheels of the bus").to(match, /bus/);
85
+ expect("The wheels of the bus").to_not(match, /boat/);
86
+ });
87
+ });
88
+
89
+ describe('when actual is a string', function() {
90
+ it("matches [expected]s containing [actual]s", function() {
91
+ expect("The wheels of the bus").to(match, "wheels");
92
+ expect("The wheels of the bus").to_not(match, "oars");
93
+ });
94
+ });
95
+
96
+ describe('when actual is an integer', function() {
97
+ it("matches [expected]s containing [actual]s", function() {
98
+ expect("1 time").to(match, 1);
99
+ expect("2 times").to_not(match, 3);
100
+ });
101
+ });
102
+
103
+ describe(".failure_message", function() {
104
+ it('prints "expected [actual] to (not) match [expected]', function() {
105
+ var message = null;
106
+ try { expect("hello").to(match, "schmello") } catch(e) { message = e }
107
+ expect(message).to(equal, 'expected "hello" to match "schmello"');
108
+
109
+ try { expect("hello").to_not(match, "ello") } catch(e) { message = e }
110
+ expect(message).to(equal, 'expected "hello" to not match "ello"');
111
+ });
112
+ });
113
+ });
114
+
115
+ describe('#be_empty', function() {
116
+ it("matches Arrays with no elements", function() {
117
+ expect([]).to(be_empty);
118
+ expect([1]).to_not(be_empty);
119
+ });
120
+
121
+ describe(".failure_message", function() {
122
+ it("prints 'expected [actual] to (not) be empty", function() {
123
+ var message = null;
124
+ try { expect([1]).to(be_empty) } catch(e) { message = e }
125
+ expect(message).to(equal, 'expected [ 1 ] to be empty');
126
+
127
+ try { expect([]).to_not(be_empty) } catch(e) { message = e }
128
+ expect(message).to(equal, 'expected [] to not be empty');
129
+ });
130
+ });
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
+ });
371
+
372
+ describe('#throw_exception', function() {
373
+ it('should match functions that throw exceptions', function() {
374
+ expect(function() { throw "foo" }).to(throw_exception);
375
+ expect(function() { }).to_not(throw_exception);
376
+ });
377
+
378
+ describe(".failure_message", function() {
379
+ it('prints "expected function to throw an exception"', function() {
380
+ var message = null;
381
+ try { expect(function() { var dummy = "dummy"; } ).to(throw_exception) } catch(e) { message = e }
382
+ expect(message).to(equal, 'expected \n var dummy = \"dummy\";\n to throw an exception');
383
+
384
+ try { expect(function() { throw "foo" }).to_not(throw_exception) } catch(e) { message = e }
385
+ expect(message).to(equal, 'expected \n throw \"foo\";\n not to throw an exception');
386
+ });
387
+ });
388
+ });
389
+
390
+ });
391
+ });