pivotal-screw-unit 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (127) hide show
  1. data/CHANGES +21 -0
  2. data/README.markdown +354 -0
  3. data/Rakefile +39 -0
  4. data/VERSION.yml +4 -0
  5. data/bin/screw_unit +6 -0
  6. data/bin/screw_unit_server +10 -0
  7. data/core/CHANGES +10 -0
  8. data/core/EXAMPLE.html +68 -0
  9. data/core/LICENSE +22 -0
  10. data/core/README.markdown +307 -0
  11. data/core/example/models/cat.js +5 -0
  12. data/core/example/models/man.js +17 -0
  13. data/core/example/spec/matchers/have.js +8 -0
  14. data/core/example/spec/models/cat_spec.js +31 -0
  15. data/core/example/spec/models/man_spec.js +34 -0
  16. data/core/example/spec/spec_helper.js +5 -0
  17. data/core/example/spec/suite.html +25 -0
  18. data/core/lib/jquery-1.3.2.js +4376 -0
  19. data/core/lib/jquery.fn.js +30 -0
  20. data/core/lib/jquery.print.js +109 -0
  21. data/core/lib/screw.behaviors.js +93 -0
  22. data/core/lib/screw.builder.js +94 -0
  23. data/core/lib/screw.css +90 -0
  24. data/core/lib/screw.events.js +45 -0
  25. data/core/lib/screw.matchers.js +244 -0
  26. data/core/spec/behaviors_spec.js +188 -0
  27. data/core/spec/matchers_spec.js +372 -0
  28. data/core/spec/print_spec.js +158 -0
  29. data/core/spec/spec_helper.js +0 -0
  30. data/core/spec/suite.html +19 -0
  31. data/core/spec/with_screw_context_spec.js +9 -0
  32. data/init.rb +0 -0
  33. data/lib/screw_unit/representations/spec.html.rb +117 -0
  34. data/lib/screw_unit/representations.rb +2 -0
  35. data/lib/screw_unit.rb +19 -0
  36. data/spec/functional/functional_spec.rb +25 -0
  37. data/spec/functional/functional_spec_helper.rb +34 -0
  38. data/spec/functional/functional_spec_server_starter.rb +63 -0
  39. data/spec/functional_suite.rb +10 -0
  40. data/spec/spec_suite.rb +3 -0
  41. data/spec/unit/js_test_core/specs/spec_dir_spec.rb +39 -0
  42. data/spec/unit/js_test_core/specs/spec_file_spec.rb +35 -0
  43. data/spec/unit/unit_spec_helper.rb +119 -0
  44. data/spec/unit_suite.rb +10 -0
  45. data/vendor/js-test-core/CHANGES +25 -0
  46. data/vendor/js-test-core/README +12 -0
  47. data/vendor/js-test-core/Rakefile +73 -0
  48. data/vendor/js-test-core/lib/js_test_core/client.rb +129 -0
  49. data/vendor/js-test-core/lib/js_test_core/extensions/time.rb +6 -0
  50. data/vendor/js-test-core/lib/js_test_core/extensions.rb +3 -0
  51. data/vendor/js-test-core/lib/js_test_core/rack/commonlogger.rb +5 -0
  52. data/vendor/js-test-core/lib/js_test_core/rack.rb +2 -0
  53. data/vendor/js-test-core/lib/js_test_core/rails_server.rb +22 -0
  54. data/vendor/js-test-core/lib/js_test_core/representations/spec.html.rb +23 -0
  55. data/vendor/js-test-core/lib/js_test_core/representations.rb +9 -0
  56. data/vendor/js-test-core/lib/js_test_core/resources/dir.rb +67 -0
  57. data/vendor/js-test-core/lib/js_test_core/resources/file.rb +42 -0
  58. data/vendor/js-test-core/lib/js_test_core/resources/runner.rb +107 -0
  59. data/vendor/js-test-core/lib/js_test_core/resources/session.rb +44 -0
  60. data/vendor/js-test-core/lib/js_test_core/resources/session_finish.rb +17 -0
  61. data/vendor/js-test-core/lib/js_test_core/resources/specs/spec.rb +32 -0
  62. data/vendor/js-test-core/lib/js_test_core/resources/specs/spec_dir.rb +50 -0
  63. data/vendor/js-test-core/lib/js_test_core/resources/specs/spec_file.rb +21 -0
  64. data/vendor/js-test-core/lib/js_test_core/resources/web_root.rb +66 -0
  65. data/vendor/js-test-core/lib/js_test_core/resources.rb +17 -0
  66. data/vendor/js-test-core/lib/js_test_core/selenium/client/driver.rb +7 -0
  67. data/vendor/js-test-core/lib/js_test_core/selenium.rb +2 -0
  68. data/vendor/js-test-core/lib/js_test_core/selenium_server_configuration.rb +48 -0
  69. data/vendor/js-test-core/lib/js_test_core/server.rb +50 -0
  70. data/vendor/js-test-core/lib/js_test_core/thin/backends/js_test_core_server.rb +9 -0
  71. data/vendor/js-test-core/lib/js_test_core/thin/js_test_core_connection.rb +8 -0
  72. data/vendor/js-test-core/lib/js_test_core/thin.rb +3 -0
  73. data/vendor/js-test-core/lib/js_test_core.rb +41 -0
  74. data/vendor/js-test-core/spec/example_core/JsTestCore.css +0 -0
  75. data/vendor/js-test-core/spec/example_core/JsTestCore.js +0 -0
  76. data/vendor/js-test-core/spec/example_public/favicon.ico +0 -0
  77. data/vendor/js-test-core/spec/example_public/javascripts/foo.js +3 -0
  78. data/vendor/js-test-core/spec/example_public/javascripts/large_file.js +59 -0
  79. data/vendor/js-test-core/spec/example_public/javascripts/subdir/bar.js +1 -0
  80. data/vendor/js-test-core/spec/example_public/robots.txt +0 -0
  81. data/vendor/js-test-core/spec/example_public/stylesheets/example.css +3 -0
  82. data/vendor/js-test-core/spec/example_specs/custom_dir_and_suite/passing_spec.js +6 -0
  83. data/vendor/js-test-core/spec/example_specs/custom_dir_and_suite.html +9 -0
  84. data/vendor/js-test-core/spec/example_specs/custom_suite.html +8 -0
  85. data/vendor/js-test-core/spec/example_specs/failing_spec.js +5 -0
  86. data/vendor/js-test-core/spec/example_specs/foo/failing_spec.js +6 -0
  87. data/vendor/js-test-core/spec/example_specs/foo/passing_spec.js +6 -0
  88. data/vendor/js-test-core/spec/spec_suite.rb +2 -0
  89. data/vendor/js-test-core/spec/specs/failing_spec.js +0 -0
  90. data/vendor/js-test-core/spec/unit/js_test_core/client_spec.rb +192 -0
  91. data/vendor/js-test-core/spec/unit/js_test_core/rails_server_spec.rb +45 -0
  92. data/vendor/js-test-core/spec/unit/js_test_core/resources/dir_spec.rb +53 -0
  93. data/vendor/js-test-core/spec/unit/js_test_core/resources/file_not_found_spec.rb +16 -0
  94. data/vendor/js-test-core/spec/unit/js_test_core/resources/file_spec.rb +90 -0
  95. data/vendor/js-test-core/spec/unit/js_test_core/resources/runners/runner_spec.rb +303 -0
  96. data/vendor/js-test-core/spec/unit/js_test_core/resources/session_finish_spec.rb +79 -0
  97. data/vendor/js-test-core/spec/unit/js_test_core/resources/session_spec.rb +82 -0
  98. data/vendor/js-test-core/spec/unit/js_test_core/resources/specs/spec_dir_spec.rb +104 -0
  99. data/vendor/js-test-core/spec/unit/js_test_core/resources/specs/spec_file_spec.rb +41 -0
  100. data/vendor/js-test-core/spec/unit/js_test_core/resources/web_root_spec.rb +32 -0
  101. data/vendor/js-test-core/spec/unit/js_test_core/selenium_server_configuration_spec.rb +49 -0
  102. data/vendor/js-test-core/spec/unit/js_test_core/server_spec.rb +117 -0
  103. data/vendor/js-test-core/spec/unit/thin/js_test_core_connection_spec.rb +6 -0
  104. data/vendor/js-test-core/spec/unit/unit_spec_helper.rb +161 -0
  105. data/vendor/js-test-core/spec/unit_suite.rb +10 -0
  106. data/vendor/js-test-core/vendor/thin-rest/CHANGES +2 -0
  107. data/vendor/js-test-core/vendor/thin-rest/README +0 -0
  108. data/vendor/js-test-core/vendor/thin-rest/lib/thin_rest/connection.rb +117 -0
  109. data/vendor/js-test-core/vendor/thin-rest/lib/thin_rest/extensions/object.rb +21 -0
  110. data/vendor/js-test-core/vendor/thin-rest/lib/thin_rest/extensions.rb +3 -0
  111. data/vendor/js-test-core/vendor/thin-rest/lib/thin_rest/representations/internal_error.html.rb +19 -0
  112. data/vendor/js-test-core/vendor/thin-rest/lib/thin_rest/representations/page.html.rb +41 -0
  113. data/vendor/js-test-core/vendor/thin-rest/lib/thin_rest/representations/resource_not_found.html.rb +18 -0
  114. data/vendor/js-test-core/vendor/thin-rest/lib/thin_rest/representations.rb +4 -0
  115. data/vendor/js-test-core/vendor/thin-rest/lib/thin_rest/resources/internal_error.rb +11 -0
  116. data/vendor/js-test-core/vendor/thin-rest/lib/thin_rest/resources/resource.rb +105 -0
  117. data/vendor/js-test-core/vendor/thin-rest/lib/thin_rest/resources/resource_not_found.rb +19 -0
  118. data/vendor/js-test-core/vendor/thin-rest/lib/thin_rest/resources.rb +4 -0
  119. data/vendor/js-test-core/vendor/thin-rest/lib/thin_rest/routing_error.rb +5 -0
  120. data/vendor/js-test-core/vendor/thin-rest/lib/thin_rest.rb +10 -0
  121. data/vendor/js-test-core/vendor/thin-rest/spec/spec_suite.rb +5 -0
  122. data/vendor/js-test-core/vendor/thin-rest/spec/thin_rest/connection_spec.rb +205 -0
  123. data/vendor/js-test-core/vendor/thin-rest/spec/thin_rest/resources/resource_not_found_spec.rb +16 -0
  124. data/vendor/js-test-core/vendor/thin-rest/spec/thin_rest/resources/resource_spec.rb +135 -0
  125. data/vendor/js-test-core/vendor/thin-rest/spec/thin_rest/resources/root_spec.rb +16 -0
  126. data/vendor/js-test-core/vendor/thin-rest/spec/thin_rest_spec_helper.rb +133 -0
  127. metadata +184 -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,372 @@
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
+ });