assert 2.18.2 → 2.18.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +7 -6
  3. data/assert.gemspec +1 -1
  4. data/lib/assert/actual_value.rb +127 -0
  5. data/lib/assert/assertions.rb +11 -20
  6. data/lib/assert/context.rb +13 -5
  7. data/lib/assert/context/let_dsl.rb +13 -0
  8. data/lib/assert/context/method_missing.rb +19 -0
  9. data/lib/assert/macros/methods.rb +4 -4
  10. data/lib/assert/stub.rb +4 -0
  11. data/lib/assert/version.rb +1 -1
  12. data/test/helper.rb +23 -25
  13. data/test/support/factory.rb +15 -0
  14. data/test/system/stub_tests.rb +348 -333
  15. data/test/system/test_tests.rb +111 -109
  16. data/test/unit/actual_value_tests.rb +335 -0
  17. data/test/unit/assert_tests.rb +84 -59
  18. data/test/unit/assertions/assert_block_tests.rb +32 -31
  19. data/test/unit/assertions/assert_empty_tests.rb +35 -32
  20. data/test/unit/assertions/assert_equal_tests.rb +81 -75
  21. data/test/unit/assertions/assert_file_exists_tests.rb +34 -33
  22. data/test/unit/assertions/assert_includes_tests.rb +40 -37
  23. data/test/unit/assertions/assert_instance_of_tests.rb +36 -33
  24. data/test/unit/assertions/assert_kind_of_tests.rb +36 -33
  25. data/test/unit/assertions/assert_match_tests.rb +36 -33
  26. data/test/unit/assertions/assert_nil_tests.rb +32 -31
  27. data/test/unit/assertions/assert_raises_tests.rb +55 -55
  28. data/test/unit/assertions/assert_respond_to_tests.rb +38 -35
  29. data/test/unit/assertions/assert_same_tests.rb +91 -80
  30. data/test/unit/assertions/assert_true_false_tests.rb +64 -60
  31. data/test/unit/assertions_tests.rb +15 -13
  32. data/test/unit/config_helpers_tests.rb +36 -35
  33. data/test/unit/config_tests.rb +33 -34
  34. data/test/unit/context/let_dsl_tests.rb +10 -0
  35. data/test/unit/context/setup_dsl_tests.rb +70 -81
  36. data/test/unit/context/subject_dsl_tests.rb +16 -43
  37. data/test/unit/context/suite_dsl_tests.rb +16 -16
  38. data/test/unit/context/test_dsl_tests.rb +50 -54
  39. data/test/unit/context_info_tests.rb +16 -15
  40. data/test/unit/context_tests.rb +170 -157
  41. data/test/unit/default_runner_tests.rb +2 -5
  42. data/test/unit/default_suite_tests.rb +51 -53
  43. data/test/unit/factory_tests.rb +3 -3
  44. data/test/unit/file_line_tests.rb +31 -33
  45. data/test/unit/macro_tests.rb +9 -10
  46. data/test/unit/result_tests.rb +150 -163
  47. data/test/unit/runner_tests.rb +63 -63
  48. data/test/unit/suite_tests.rb +57 -54
  49. data/test/unit/test_tests.rb +134 -126
  50. data/test/unit/utils_tests.rb +41 -45
  51. data/test/unit/view_helpers_tests.rb +55 -52
  52. data/test/unit/view_tests.rb +20 -22
  53. metadata +11 -4
@@ -8,676 +8,691 @@ class Assert::Stub
8
8
 
9
9
  class InstanceTests < SystemTests
10
10
  desc "for instance methods"
11
+ subject { instance1 }
12
+
11
13
  setup do
12
- @instance = TestClass.new
13
- Assert.stub(@instance, :noargs){ "default" }
14
- Assert.stub(@instance, :noargs).with{ "none" }
14
+ Assert.stub(instance1, :noargs){ "default" }
15
+ Assert.stub(instance1, :noargs).with{ "none" }
15
16
 
16
- Assert.stub(@instance, :withargs){ "default" }
17
- Assert.stub(@instance, :withargs).with(1){ "one" }
17
+ Assert.stub(instance1, :withargs){ "default" }
18
+ Assert.stub(instance1, :withargs).with(1){ "one" }
18
19
 
19
- Assert.stub(@instance, :anyargs){ "default" }
20
- Assert.stub(@instance, :anyargs).with(1, 2){ "one-two" }
20
+ Assert.stub(instance1, :anyargs){ "default" }
21
+ Assert.stub(instance1, :anyargs).with(1, 2){ "one-two" }
21
22
 
22
- Assert.stub(@instance, :minargs){ "default" }
23
- Assert.stub(@instance, :minargs).with(1, 2){ "one-two" }
24
- Assert.stub(@instance, :minargs).with(1, 2, 3){ "one-two-three" }
23
+ Assert.stub(instance1, :minargs){ "default" }
24
+ Assert.stub(instance1, :minargs).with(1, 2){ "one-two" }
25
+ Assert.stub(instance1, :minargs).with(1, 2, 3){ "one-two-three" }
25
26
 
26
- Assert.stub(@instance, :withblock){ "default" }
27
+ Assert.stub(instance1, :withblock){ "default" }
27
28
  end
28
- subject{ @instance }
29
+
30
+ let(:instance1) { TestClass.new }
29
31
 
30
32
  should "allow stubbing a method that doesn't take args" do
31
- assert_equal "none", subject.noargs
33
+ assert_that(subject.noargs).equals("none")
32
34
  end
33
35
 
34
36
  should "allow stubbing a method that takes args" do
35
- assert_equal "one", subject.withargs(1)
36
- assert_equal "default", subject.withargs(2)
37
+ assert_that(subject.withargs(2)).equals("default")
37
38
  end
38
39
 
39
40
  should "allow stubbing a method that takes any args" do
40
- assert_equal "default", subject.anyargs
41
- assert_equal "default", subject.anyargs(1)
42
- assert_equal "one-two", subject.anyargs(1, 2)
41
+ assert_that(subject.anyargs).equals("default")
42
+ assert_that(subject.anyargs(1)).equals("default")
43
+ assert_that(subject.anyargs(1, 2)).equals("one-two")
43
44
  end
44
45
 
45
46
  should "allow stubbing a method that takes a minimum number of args" do
46
- assert_equal "one-two", subject.minargs(1, 2)
47
- assert_equal "one-two-three", subject.minargs(1, 2, 3)
48
- assert_equal "default", subject.minargs(1, 2, 4)
49
- assert_equal "default", subject.minargs(1, 2, 3, 4)
47
+ assert_that(subject.minargs(1, 2)).equals("one-two")
48
+ assert_that(subject.minargs(1, 2, 3)).equals("one-two-three")
49
+ assert_that(subject.minargs(1, 2, 4)).equals("default")
50
+ assert_that(subject.minargs(1, 2, 3, 4)).equals("default")
50
51
  end
51
52
 
52
53
  should "allow stubbing a method that takes a block" do
53
- assert_equal "default", subject.withblock
54
- assert_equal "default", subject.withblock{ "my-block" }
54
+ assert_that(subject.withblock).equals("default")
55
+ assert_that(subject.withblock{ "my-block" }).equals("default")
55
56
  end
56
57
 
57
58
  should "not allow stubbing methods with invalid arity" do
58
- assert_raises{ Assert.stub(subject, :noargs).with(1){ } }
59
+ assert_that(-> { Assert.stub(subject, :noargs).with(1){ } }).raises
59
60
 
60
- assert_raises{ Assert.stub(subject, :withargs).with{ } }
61
- assert_raises{ Assert.stub(subject, :withargs).with(1, 2){ } }
61
+ assert_that(-> { Assert.stub(subject, :withargs).with{ } }).raises
62
+ assert_that(-> { Assert.stub(subject, :withargs).with(1, 2){ } }).raises
62
63
 
63
- assert_raises{ Assert.stub(subject, :minargs).with{ } }
64
- assert_raises{ Assert.stub(subject, :minargs).with(1){ } }
64
+ assert_that(-> { Assert.stub(subject, :minargs).with{ } }).raises
65
+ assert_that(-> { Assert.stub(subject, :minargs).with(1){ } }).raises
65
66
 
66
- assert_raises{ Assert.stub(subject, :withblock).with(1){ } }
67
+ assert_that(-> { Assert.stub(subject, :withblock).with(1){ } }).raises
67
68
  end
68
69
 
69
70
  should "not allow calling methods with invalid arity" do
70
- assert_raises{ subject.noargs(1) }
71
+ assert_that(-> { subject.noargs(1) }).raises
71
72
 
72
- assert_raises{ subject.withargs }
73
- assert_raises{ subject.withargs(1, 2) }
73
+ assert_that(-> { subject.withargs }).raises
74
+ assert_that(-> { subject.withargs(1, 2) }).raises
74
75
 
75
- assert_raises{ subject.minargs }
76
- assert_raises{ subject.minargs(1) }
76
+ assert_that(-> { subject.minargs }).raises
77
+ assert_that(-> { subject.minargs(1) }).raises
77
78
 
78
- assert_raises{ subject.withblock(1) }
79
+ assert_that(-> { subject.withblock(1) }).raises
79
80
  end
80
81
  end
81
82
 
82
83
  class ClassTests < SystemTests
83
84
  desc "for singleton methods on a class"
85
+ subject { class1 }
86
+
84
87
  setup do
85
- @class = TestClass
86
- Assert.stub(@class, :noargs){ "default" }
87
- Assert.stub(@class, :noargs).with{ "none" }
88
+ Assert.stub(class1, :noargs){ "default" }
89
+ Assert.stub(class1, :noargs).with{ "none" }
88
90
 
89
- Assert.stub(@class, :withargs){ "default" }
90
- Assert.stub(@class, :withargs).with(1){ "one" }
91
+ Assert.stub(class1, :withargs){ "default" }
92
+ Assert.stub(class1, :withargs).with(1){ "one" }
91
93
 
92
- Assert.stub(@class, :anyargs){ "default" }
93
- Assert.stub(@class, :anyargs).with(1, 2){ "one-two" }
94
+ Assert.stub(class1, :anyargs){ "default" }
95
+ Assert.stub(class1, :anyargs).with(1, 2){ "one-two" }
94
96
 
95
- Assert.stub(@class, :minargs){ "default" }
96
- Assert.stub(@class, :minargs).with(1, 2){ "one-two" }
97
- Assert.stub(@class, :minargs).with(1, 2, 3){ "one-two-three" }
97
+ Assert.stub(class1, :minargs){ "default" }
98
+ Assert.stub(class1, :minargs).with(1, 2){ "one-two" }
99
+ Assert.stub(class1, :minargs).with(1, 2, 3){ "one-two-three" }
98
100
 
99
- Assert.stub(@class, :withblock){ "default" }
101
+ Assert.stub(class1, :withblock){ "default" }
100
102
  end
101
- subject{ @class }
103
+
104
+ let(:class1) { TestClass }
102
105
 
103
106
  should "allow stubbing a method that doesn't take args" do
104
- assert_equal "none", subject.noargs
107
+ assert_that(subject.noargs).equals("none")
105
108
  end
106
109
 
107
110
  should "allow stubbing a method that takes args" do
108
- assert_equal "one", subject.withargs(1)
109
- assert_equal "default", subject.withargs(2)
111
+ assert_that(subject.withargs(1)).equals("one")
112
+ assert_that(subject.withargs(2)).equals("default")
110
113
  end
111
114
 
112
115
  should "allow stubbing a method that takes any args" do
113
- assert_equal "default", subject.anyargs
114
- assert_equal "default", subject.anyargs(1)
115
- assert_equal "one-two", subject.anyargs(1, 2)
116
+ assert_that(subject.anyargs).equals("default")
117
+ assert_that(subject.anyargs(1)).equals("default")
118
+ assert_that(subject.anyargs(1, 2)).equals("one-two")
116
119
  end
117
120
 
118
121
  should "allow stubbing a method that takes a minimum number of args" do
119
- assert_equal "one-two", subject.minargs(1, 2)
120
- assert_equal "one-two-three", subject.minargs(1, 2, 3)
121
- assert_equal "default", subject.minargs(1, 2, 4)
122
- assert_equal "default", subject.minargs(1, 2, 3, 4)
122
+ assert_that(subject.minargs(1, 2)).equals("one-two")
123
+ assert_that(subject.minargs(1, 2, 3)).equals("one-two-three")
124
+ assert_that(subject.minargs(1, 2, 4)).equals("default")
125
+ assert_that(subject.minargs(1, 2, 3, 4)).equals("default")
123
126
  end
124
127
 
125
128
  should "allow stubbing a method that takes a block" do
126
- assert_equal "default", subject.withblock
127
- assert_equal "default", subject.withblock{ "my-block" }
129
+ assert_that(subject.withblock).equals("default")
130
+ assert_that(subject.withblock{ "my-block" }).equals("default")
128
131
  end
129
132
 
130
133
  should "not allow stubbing methods with invalid arity" do
131
- assert_raises{ Assert.stub(subject, :noargs).with(1){ } }
134
+ assert_that(-> { Assert.stub(subject, :noargs).with(1){ } }).raises
132
135
 
133
- assert_raises{ Assert.stub(subject, :withargs).with{ } }
134
- assert_raises{ Assert.stub(subject, :withargs).with(1, 2){ } }
136
+ assert_that(-> { Assert.stub(subject, :withargs).with{ } }).raises
137
+ assert_that(-> { Assert.stub(subject, :withargs).with(1, 2){ } }).raises
135
138
 
136
- assert_raises{ Assert.stub(subject, :minargs).with{ } }
137
- assert_raises{ Assert.stub(subject, :minargs).with(1){ } }
139
+ assert_that(-> { Assert.stub(subject, :minargs).with{ } }).raises
140
+ assert_that(-> { Assert.stub(subject, :minargs).with(1){ } }).raises
138
141
 
139
- assert_raises{ Assert.stub(subject, :withblock).with(1){ } }
142
+ assert_that(-> { Assert.stub(subject, :withblock).with(1){ } }).raises
140
143
  end
141
144
 
142
145
  should "not allow calling methods with invalid arity" do
143
- assert_raises{ subject.noargs(1) }
146
+ assert_that(-> { subject.noargs(1) }).raises
144
147
 
145
- assert_raises{ subject.withargs }
146
- assert_raises{ subject.withargs(1, 2) }
148
+ assert_that(-> { subject.withargs }).raises
149
+ assert_that(-> { subject.withargs(1, 2) }).raises
147
150
 
148
- assert_raises{ subject.minargs }
149
- assert_raises{ subject.minargs(1) }
151
+ assert_that(-> { subject.minargs }).raises
152
+ assert_that(-> { subject.minargs(1) }).raises
150
153
 
151
- assert_raises{ subject.withblock(1) }
154
+ assert_that(-> { subject.withblock(1) }).raises
152
155
  end
153
156
  end
154
157
 
155
158
  class ModuleTests < SystemTests
156
159
  desc "for singleton methods on a module"
160
+ subject { module1 }
161
+
157
162
  setup do
158
- @module = TestModule
159
- Assert.stub(@module, :noargs){ "default" }
160
- Assert.stub(@module, :noargs).with{ "none" }
163
+ Assert.stub(module1, :noargs){ "default" }
164
+ Assert.stub(module1, :noargs).with{ "none" }
161
165
 
162
- Assert.stub(@module, :withargs){ "default" }
163
- Assert.stub(@module, :withargs).with(1){ "one" }
166
+ Assert.stub(module1, :withargs){ "default" }
167
+ Assert.stub(module1, :withargs).with(1){ "one" }
164
168
 
165
- Assert.stub(@module, :anyargs){ "default" }
166
- Assert.stub(@module, :anyargs).with(1, 2){ "one-two" }
169
+ Assert.stub(module1, :anyargs){ "default" }
170
+ Assert.stub(module1, :anyargs).with(1, 2){ "one-two" }
167
171
 
168
- Assert.stub(@module, :minargs){ "default" }
169
- Assert.stub(@module, :minargs).with(1, 2){ "one-two" }
170
- Assert.stub(@module, :minargs).with(1, 2, 3){ "one-two-three" }
172
+ Assert.stub(module1, :minargs){ "default" }
173
+ Assert.stub(module1, :minargs).with(1, 2){ "one-two" }
174
+ Assert.stub(module1, :minargs).with(1, 2, 3){ "one-two-three" }
171
175
 
172
- Assert.stub(@module, :withblock){ "default" }
176
+ Assert.stub(module1, :withblock){ "default" }
173
177
  end
174
- subject{ @module }
178
+
179
+ let(:module1) { TestModule }
175
180
 
176
181
  should "allow stubbing a method that doesn't take args" do
177
- assert_equal "none", subject.noargs
182
+ assert_that(subject.noargs).equals("none")
178
183
  end
179
184
 
180
185
  should "allow stubbing a method that takes args" do
181
- assert_equal "one", subject.withargs(1)
182
- assert_equal "default", subject.withargs(2)
186
+ assert_that(subject.withargs(1)).equals("one")
187
+ assert_that(subject.withargs(2)).equals("default")
183
188
  end
184
189
 
185
190
  should "allow stubbing a method that takes any args" do
186
- assert_equal "default", subject.anyargs
187
- assert_equal "default", subject.anyargs(1)
188
- assert_equal "one-two", subject.anyargs(1, 2)
191
+ assert_that(subject.anyargs).equals("default")
192
+ assert_that(subject.anyargs(1)).equals("default")
193
+ assert_that(subject.anyargs(1, 2)).equals("one-two")
189
194
  end
190
195
 
191
196
  should "allow stubbing a method that takes a minimum number of args" do
192
- assert_equal "one-two", subject.minargs(1, 2)
193
- assert_equal "one-two-three", subject.minargs(1, 2, 3)
194
- assert_equal "default", subject.minargs(1, 2, 4)
195
- assert_equal "default", subject.minargs(1, 2, 3, 4)
197
+ assert_that(subject.minargs(1, 2)).equals("one-two")
198
+ assert_that(subject.minargs(1, 2, 3)).equals("one-two-three")
199
+ assert_that(subject.minargs(1, 2, 4)).equals("default")
200
+ assert_that(subject.minargs(1, 2, 3, 4)).equals("default")
196
201
  end
197
202
 
198
203
  should "allow stubbing a method that takes a block" do
199
- assert_equal "default", subject.withblock
200
- assert_equal "default", subject.withblock{ "my-block" }
204
+ assert_that(subject.withblock).equals("default")
205
+ assert_that(subject.withblock{ "my-block" }).equals("default")
201
206
  end
202
207
 
203
208
  should "not allow stubbing methods with invalid arity" do
204
- assert_raises{ Assert.stub(subject, :noargs).with(1){ } }
209
+ assert_that(-> { Assert.stub(subject, :noargs).with(1){ } }).raises
205
210
 
206
- assert_raises{ Assert.stub(subject, :withargs).with{ } }
207
- assert_raises{ Assert.stub(subject, :withargs).with(1, 2){ } }
211
+ assert_that(-> { Assert.stub(subject, :withargs).with{ } }).raises
212
+ assert_that(-> { Assert.stub(subject, :withargs).with(1, 2){ } }).raises
208
213
 
209
- assert_raises{ Assert.stub(subject, :minargs).with{ } }
210
- assert_raises{ Assert.stub(subject, :minargs).with(1){ } }
214
+ assert_that(-> { Assert.stub(subject, :minargs).with{ } }).raises
215
+ assert_that(-> { Assert.stub(subject, :minargs).with(1){ } }).raises
211
216
 
212
- assert_raises{ Assert.stub(subject, :withblock).with(1){ } }
217
+ assert_that(-> { Assert.stub(subject, :withblock).with(1){ } }).raises
213
218
  end
214
219
 
215
220
  should "not allow calling methods with invalid arity" do
216
- assert_raises{ subject.noargs(1) }
221
+ assert_that(-> { subject.noargs(1) }).raises
217
222
 
218
- assert_raises{ subject.withargs }
219
- assert_raises{ subject.withargs(1, 2) }
223
+ assert_that(-> { subject.withargs }).raises
224
+ assert_that(-> { subject.withargs(1, 2) }).raises
220
225
 
221
- assert_raises{ subject.minargs }
222
- assert_raises{ subject.minargs(1) }
226
+ assert_that(-> { subject.minargs }).raises
227
+ assert_that(-> { subject.minargs(1) }).raises
223
228
 
224
- assert_raises{ subject.withblock(1) }
229
+ assert_that(-> { subject.withblock(1) }).raises
225
230
  end
226
231
  end
227
232
 
228
233
  class ExtendedTests < SystemTests
229
234
  desc "for extended methods"
235
+ subject { class1 }
236
+
230
237
  setup do
231
- @class = Class.new{ extend TestMixin }
232
- Assert.stub(@class, :noargs){ "default" }
233
- Assert.stub(@class, :noargs).with{ "none" }
238
+ Assert.stub(class1, :noargs){ "default" }
239
+ Assert.stub(class1, :noargs).with{ "none" }
234
240
 
235
- Assert.stub(@class, :withargs){ "default" }
236
- Assert.stub(@class, :withargs).with(1){ "one" }
241
+ Assert.stub(class1, :withargs){ "default" }
242
+ Assert.stub(class1, :withargs).with(1){ "one" }
237
243
 
238
- Assert.stub(@class, :anyargs){ "default" }
239
- Assert.stub(@class, :anyargs).with(1, 2){ "one-two" }
244
+ Assert.stub(class1, :anyargs){ "default" }
245
+ Assert.stub(class1, :anyargs).with(1, 2){ "one-two" }
240
246
 
241
- Assert.stub(@class, :minargs){ "default" }
242
- Assert.stub(@class, :minargs).with(1, 2){ "one-two" }
243
- Assert.stub(@class, :minargs).with(1, 2, 3){ "one-two-three" }
247
+ Assert.stub(class1, :minargs){ "default" }
248
+ Assert.stub(class1, :minargs).with(1, 2){ "one-two" }
249
+ Assert.stub(class1, :minargs).with(1, 2, 3){ "one-two-three" }
244
250
 
245
- Assert.stub(@class, :withblock){ "default" }
251
+ Assert.stub(class1, :withblock){ "default" }
246
252
  end
247
- subject{ @class }
253
+
254
+ let(:class1) { Class.new{ extend TestMixin } }
248
255
 
249
256
  should "allow stubbing a method that doesn't take args" do
250
- assert_equal "none", subject.noargs
257
+ assert_that(subject.noargs).equals("none")
251
258
  end
252
259
 
253
260
  should "allow stubbing a method that takes args" do
254
- assert_equal "one", subject.withargs(1)
255
- assert_equal "default", subject.withargs(2)
261
+ assert_that(subject.withargs(1)).equals("one")
262
+ assert_that(subject.withargs(2)).equals("default")
256
263
  end
257
264
 
258
265
  should "allow stubbing a method that takes any args" do
259
- assert_equal "default", subject.anyargs
260
- assert_equal "default", subject.anyargs(1)
261
- assert_equal "one-two", subject.anyargs(1, 2)
266
+ assert_that(subject.anyargs).equals("default")
267
+ assert_that(subject.anyargs(1)).equals("default")
268
+ assert_that(subject.anyargs(1, 2)).equals("one-two")
262
269
  end
263
270
 
264
271
  should "allow stubbing a method that takes a minimum number of args" do
265
- assert_equal "one-two", subject.minargs(1, 2)
266
- assert_equal "one-two-three", subject.minargs(1, 2, 3)
267
- assert_equal "default", subject.minargs(1, 2, 4)
268
- assert_equal "default", subject.minargs(1, 2, 3, 4)
272
+ assert_that(subject.minargs(1, 2)).equals("one-two")
273
+ assert_that(subject.minargs(1, 2, 3)).equals("one-two-three")
274
+ assert_that(subject.minargs(1, 2, 4)).equals("default")
275
+ assert_that(subject.minargs(1, 2, 3, 4)).equals("default")
269
276
  end
270
277
 
271
278
  should "allow stubbing a method that takes a block" do
272
- assert_equal "default", subject.withblock
273
- assert_equal "default", subject.withblock{ "my-block" }
279
+ assert_that(subject.withblock).equals("default")
280
+ assert_that(subject.withblock{ "my-block" }).equals("default")
274
281
  end
275
282
 
276
283
  should "not allow stubbing methods with invalid arity" do
277
- assert_raises{ Assert.stub(subject, :noargs).with(1){ } }
284
+ assert_that(-> { Assert.stub(subject, :noargs).with(1){ } }).raises
278
285
 
279
- assert_raises{ Assert.stub(subject, :withargs).with{ } }
280
- assert_raises{ Assert.stub(subject, :withargs).with(1, 2){ } }
286
+ assert_that(-> { Assert.stub(subject, :withargs).with{ } }).raises
287
+ assert_that(-> { Assert.stub(subject, :withargs).with(1, 2){ } }).raises
281
288
 
282
- assert_raises{ Assert.stub(subject, :minargs).with{ } }
283
- assert_raises{ Assert.stub(subject, :minargs).with(1){ } }
289
+ assert_that(-> { Assert.stub(subject, :minargs).with{ } }).raises
290
+ assert_that(-> { Assert.stub(subject, :minargs).with(1){ } }).raises
284
291
 
285
- assert_raises{ Assert.stub(subject, :withblock).with(1){ } }
292
+ assert_that(-> { Assert.stub(subject, :withblock).with(1){ } }).raises
286
293
  end
287
294
 
288
295
  should "not allow calling methods with invalid arity" do
289
- assert_raises{ subject.noargs(1) }
296
+ assert_that(-> { subject.noargs(1) }).raises
290
297
 
291
- assert_raises{ subject.withargs }
292
- assert_raises{ subject.withargs(1, 2) }
298
+ assert_that(-> { subject.withargs }).raises
299
+ assert_that(-> { subject.withargs(1, 2) }).raises
293
300
 
294
- assert_raises{ subject.minargs }
295
- assert_raises{ subject.minargs(1) }
301
+ assert_that(-> { subject.minargs }).raises
302
+ assert_that(-> { subject.minargs(1) }).raises
296
303
 
297
- assert_raises{ subject.withblock(1) }
304
+ assert_that(-> { subject.withblock(1) }).raises
298
305
  end
299
306
  end
300
307
 
301
308
  class IncludedTests < SystemTests
302
309
  desc "for an included method"
310
+ subject { instance1 }
311
+
303
312
  setup do
304
- @class = Class.new{ include TestMixin }
305
- @instance = @class.new
306
- Assert.stub(@instance, :noargs){ "default" }
307
- Assert.stub(@instance, :noargs).with{ "none" }
313
+ Assert.stub(instance1, :noargs){ "default" }
314
+ Assert.stub(instance1, :noargs).with{ "none" }
308
315
 
309
- Assert.stub(@instance, :withargs){ "default" }
310
- Assert.stub(@instance, :withargs).with(1){ "one" }
316
+ Assert.stub(instance1, :withargs){ "default" }
317
+ Assert.stub(instance1, :withargs).with(1){ "one" }
311
318
 
312
- Assert.stub(@instance, :anyargs){ "default" }
313
- Assert.stub(@instance, :anyargs).with(1, 2){ "one-two" }
319
+ Assert.stub(instance1, :anyargs){ "default" }
320
+ Assert.stub(instance1, :anyargs).with(1, 2){ "one-two" }
314
321
 
315
- Assert.stub(@instance, :minargs){ "default" }
316
- Assert.stub(@instance, :minargs).with(1, 2){ "one-two" }
317
- Assert.stub(@instance, :minargs).with(1, 2, 3){ "one-two-three" }
322
+ Assert.stub(instance1, :minargs){ "default" }
323
+ Assert.stub(instance1, :minargs).with(1, 2){ "one-two" }
324
+ Assert.stub(instance1, :minargs).with(1, 2, 3){ "one-two-three" }
318
325
 
319
- Assert.stub(@instance, :withblock){ "default" }
326
+ Assert.stub(instance1, :withblock){ "default" }
320
327
  end
321
- subject{ @instance }
328
+
329
+ let(:instance1) { Class.new { include TestMixin }.new }
322
330
 
323
331
  should "allow stubbing a method that doesn't take args" do
324
- assert_equal "none", subject.noargs
332
+ assert_that(subject.noargs).equals("none")
325
333
  end
326
334
 
327
335
  should "allow stubbing a method that takes args" do
328
- assert_equal "one", subject.withargs(1)
329
- assert_equal "default", subject.withargs(2)
336
+ assert_that(subject.withargs(1)).equals("one")
337
+ assert_that(subject.withargs(2)).equals("default")
330
338
  end
331
339
 
332
340
  should "allow stubbing a method that takes any args" do
333
- assert_equal "default", subject.anyargs
334
- assert_equal "default", subject.anyargs(1)
335
- assert_equal "one-two", subject.anyargs(1, 2)
341
+ assert_that(subject.anyargs).equals("default")
342
+ assert_that(subject.anyargs(1)).equals("default")
343
+ assert_that(subject.anyargs(1, 2)).equals("one-two")
336
344
  end
337
345
 
338
346
  should "allow stubbing a method that takes a minimum number of args" do
339
- assert_equal "one-two", subject.minargs(1, 2)
340
- assert_equal "one-two-three", subject.minargs(1, 2, 3)
341
- assert_equal "default", subject.minargs(1, 2, 4)
342
- assert_equal "default", subject.minargs(1, 2, 3, 4)
347
+ assert_that(subject.minargs(1, 2)).equals("one-two")
348
+ assert_that(subject.minargs(1, 2, 3)).equals("one-two-three")
349
+ assert_that(subject.minargs(1, 2, 4)).equals("default")
350
+ assert_that(subject.minargs(1, 2, 3, 4)).equals("default")
343
351
  end
344
352
 
345
353
  should "allow stubbing a method that takes a block" do
346
- assert_equal "default", subject.withblock
347
- assert_equal "default", subject.withblock{ "my-block" }
354
+ assert_that(subject.withblock).equals("default")
355
+ assert_that(subject.withblock{ "my-block" }).equals("default")
348
356
  end
349
357
 
350
358
  should "not allow stubbing methods with invalid arity" do
351
- assert_raises{ Assert.stub(subject, :noargs).with(1){ } }
359
+ assert_that(-> { Assert.stub(subject, :noargs).with(1){ } }).raises
352
360
 
353
- assert_raises{ Assert.stub(subject, :withargs).with{ } }
354
- assert_raises{ Assert.stub(subject, :withargs).with(1, 2){ } }
361
+ assert_that(-> { Assert.stub(subject, :withargs).with{ } }).raises
362
+ assert_that(-> { Assert.stub(subject, :withargs).with(1, 2){ } }).raises
355
363
 
356
- assert_raises{ Assert.stub(subject, :minargs).with{ } }
357
- assert_raises{ Assert.stub(subject, :minargs).with(1){ } }
364
+ assert_that(-> { Assert.stub(subject, :minargs).with{ } }).raises
365
+ assert_that(-> { Assert.stub(subject, :minargs).with(1){ } }).raises
358
366
 
359
- assert_raises{ Assert.stub(subject, :withblock).with(1){ } }
367
+ assert_that(-> { Assert.stub(subject, :withblock).with(1){ } }).raises
360
368
  end
361
369
 
362
370
  should "not allow calling methods with invalid arity" do
363
- assert_raises{ subject.noargs(1) }
371
+ assert_that(-> { subject.noargs(1) }).raises
364
372
 
365
- assert_raises{ subject.withargs }
366
- assert_raises{ subject.withargs(1, 2) }
373
+ assert_that(-> { subject.withargs }).raises
374
+ assert_that(-> { subject.withargs(1, 2) }).raises
367
375
 
368
- assert_raises{ subject.minargs }
369
- assert_raises{ subject.minargs(1) }
376
+ assert_that(-> { subject.minargs }).raises
377
+ assert_that(-> { subject.minargs(1) }).raises
370
378
 
371
- assert_raises{ subject.withblock(1) }
379
+ assert_that(-> { subject.withblock(1) }).raises
372
380
  end
373
381
  end
374
382
 
375
383
  class InheritedClassTests < SystemTests
376
384
  desc "for an inherited class method"
385
+ subject { class1 }
386
+
377
387
  setup do
378
- @class = Class.new(TestClass)
379
- Assert.stub(@class, :noargs){ "default" }
380
- Assert.stub(@class, :noargs).with{ "none" }
388
+ Assert.stub(class1, :noargs){ "default" }
389
+ Assert.stub(class1, :noargs).with{ "none" }
381
390
 
382
- Assert.stub(@class, :withargs){ "default" }
383
- Assert.stub(@class, :withargs).with(1){ "one" }
391
+ Assert.stub(class1, :withargs){ "default" }
392
+ Assert.stub(class1, :withargs).with(1){ "one" }
384
393
 
385
- Assert.stub(@class, :anyargs){ "default" }
386
- Assert.stub(@class, :anyargs).with(1, 2){ "one-two" }
394
+ Assert.stub(class1, :anyargs){ "default" }
395
+ Assert.stub(class1, :anyargs).with(1, 2){ "one-two" }
387
396
 
388
- Assert.stub(@class, :minargs){ "default" }
389
- Assert.stub(@class, :minargs).with(1, 2){ "one-two" }
390
- Assert.stub(@class, :minargs).with(1, 2, 3){ "one-two-three" }
397
+ Assert.stub(class1, :minargs){ "default" }
398
+ Assert.stub(class1, :minargs).with(1, 2){ "one-two" }
399
+ Assert.stub(class1, :minargs).with(1, 2, 3){ "one-two-three" }
391
400
 
392
- Assert.stub(@class, :withblock){ "default" }
401
+ Assert.stub(class1, :withblock){ "default" }
393
402
  end
394
- subject{ @class }
403
+
404
+ let(:class1) { Class.new(TestClass) }
395
405
 
396
406
  should "allow stubbing a method that doesn't take args" do
397
- assert_equal "none", subject.noargs
407
+ assert_that(subject.noargs).equals("none")
398
408
  end
399
409
 
400
410
  should "allow stubbing a method that takes args" do
401
- assert_equal "one", subject.withargs(1)
402
- assert_equal "default", subject.withargs(2)
411
+ assert_that(subject.withargs(1)).equals("one")
412
+ assert_that(subject.withargs(2)).equals("default")
403
413
  end
404
414
 
405
415
  should "allow stubbing a method that takes any args" do
406
- assert_equal "default", subject.anyargs
407
- assert_equal "default", subject.anyargs(1)
408
- assert_equal "one-two", subject.anyargs(1, 2)
416
+ assert_that(subject.anyargs).equals("default")
417
+ assert_that(subject.anyargs(1)).equals("default")
418
+ assert_that(subject.anyargs(1, 2)).equals("one-two")
409
419
  end
410
420
 
411
421
  should "allow stubbing a method that takes a minimum number of args" do
412
- assert_equal "one-two", subject.minargs(1, 2)
413
- assert_equal "one-two-three", subject.minargs(1, 2, 3)
414
- assert_equal "default", subject.minargs(1, 2, 4)
415
- assert_equal "default", subject.minargs(1, 2, 3, 4)
422
+ assert_that(subject.minargs(1, 2)).equals("one-two")
423
+ assert_that(subject.minargs(1, 2, 3)).equals("one-two-three")
424
+ assert_that(subject.minargs(1, 2, 4)).equals("default")
425
+ assert_that(subject.minargs(1, 2, 3, 4)).equals("default")
416
426
  end
417
427
 
418
428
  should "allow stubbing a method that takes a block" do
419
- assert_equal "default", subject.withblock
420
- assert_equal "default", subject.withblock{ "my-block" }
429
+ assert_that(subject.withblock).equals("default")
430
+ assert_that(subject.withblock{ "my-block" }).equals("default")
421
431
  end
422
432
 
423
433
  should "not allow stubbing methods with invalid arity" do
424
- assert_raises{ Assert.stub(subject, :noargs).with(1){ } }
434
+ assert_that(-> { Assert.stub(subject, :noargs).with(1){ } }).raises
425
435
 
426
- assert_raises{ Assert.stub(subject, :withargs).with{ } }
427
- assert_raises{ Assert.stub(subject, :withargs).with(1, 2){ } }
436
+ assert_that(-> { Assert.stub(subject, :withargs).with{ } }).raises
437
+ assert_that(-> { Assert.stub(subject, :withargs).with(1, 2){ } }).raises
428
438
 
429
- assert_raises{ Assert.stub(subject, :minargs).with{ } }
430
- assert_raises{ Assert.stub(subject, :minargs).with(1){ } }
439
+ assert_that(-> { Assert.stub(subject, :minargs).with{ } }).raises
440
+ assert_that(-> { Assert.stub(subject, :minargs).with(1){ } }).raises
431
441
 
432
- assert_raises{ Assert.stub(subject, :withblock).with(1){ } }
442
+ assert_that(-> { Assert.stub(subject, :withblock).with(1){ } }).raises
433
443
  end
434
444
 
435
445
  should "not allow calling methods with invalid arity" do
436
- assert_raises{ subject.noargs(1) }
446
+ assert_that(-> { subject.noargs(1) }).raises
437
447
 
438
- assert_raises{ subject.withargs }
439
- assert_raises{ subject.withargs(1, 2) }
448
+ assert_that(-> { subject.withargs }).raises
449
+ assert_that(-> { subject.withargs(1, 2) }).raises
440
450
 
441
- assert_raises{ subject.minargs }
442
- assert_raises{ subject.minargs(1) }
451
+ assert_that(-> { subject.minargs }).raises
452
+ assert_that(-> { subject.minargs(1) }).raises
443
453
 
444
- assert_raises{ subject.withblock(1) }
454
+ assert_that(-> { subject.withblock(1) }).raises
445
455
  end
446
456
  end
447
457
 
448
458
  class InheritedInstanceTests < SystemTests
449
459
  desc "for an inherited instance method"
460
+ subject { instance1 }
461
+
450
462
  setup do
451
- @class = Class.new(TestClass)
452
- @instance = @class.new
453
- Assert.stub(@instance, :noargs){ "default" }
454
- Assert.stub(@instance, :noargs).with{ "none" }
463
+ Assert.stub(instance1, :noargs){ "default" }
464
+ Assert.stub(instance1, :noargs).with{ "none" }
455
465
 
456
- Assert.stub(@instance, :withargs){ "default" }
457
- Assert.stub(@instance, :withargs).with(1){ "one" }
466
+ Assert.stub(instance1, :withargs){ "default" }
467
+ Assert.stub(instance1, :withargs).with(1){ "one" }
458
468
 
459
- Assert.stub(@instance, :anyargs){ "default" }
460
- Assert.stub(@instance, :anyargs).with(1, 2){ "one-two" }
469
+ Assert.stub(instance1, :anyargs){ "default" }
470
+ Assert.stub(instance1, :anyargs).with(1, 2){ "one-two" }
461
471
 
462
- Assert.stub(@instance, :minargs){ "default" }
463
- Assert.stub(@instance, :minargs).with(1, 2){ "one-two" }
464
- Assert.stub(@instance, :minargs).with(1, 2, 3){ "one-two-three" }
472
+ Assert.stub(instance1, :minargs){ "default" }
473
+ Assert.stub(instance1, :minargs).with(1, 2){ "one-two" }
474
+ Assert.stub(instance1, :minargs).with(1, 2, 3){ "one-two-three" }
465
475
 
466
- Assert.stub(@instance, :withblock){ "default" }
476
+ Assert.stub(instance1, :withblock){ "default" }
467
477
  end
468
- subject{ @instance }
478
+
479
+ let(:instance1) { Class.new(TestClass).new }
469
480
 
470
481
  should "allow stubbing a method that doesn't take args" do
471
- assert_equal "none", subject.noargs
482
+ assert_that(subject.noargs).equals("none")
472
483
  end
473
484
 
474
485
  should "allow stubbing a method that takes args" do
475
- assert_equal "one", subject.withargs(1)
476
- assert_equal "default", subject.withargs(2)
486
+ assert_that(subject.withargs(1)).equals("one")
487
+ assert_that(subject.withargs(2)).equals("default")
477
488
  end
478
489
 
479
490
  should "allow stubbing a method that takes any args" do
480
- assert_equal "default", subject.anyargs
481
- assert_equal "default", subject.anyargs(1)
482
- assert_equal "one-two", subject.anyargs(1, 2)
491
+ assert_that(subject.anyargs).equals("default")
492
+ assert_that(subject.anyargs(1)).equals("default")
493
+ assert_that(subject.anyargs(1, 2)).equals("one-two")
483
494
  end
484
495
 
485
496
  should "allow stubbing a method that takes a minimum number of args" do
486
- assert_equal "one-two", subject.minargs(1, 2)
487
- assert_equal "one-two-three", subject.minargs(1, 2, 3)
488
- assert_equal "default", subject.minargs(1, 2, 4)
489
- assert_equal "default", subject.minargs(1, 2, 3, 4)
497
+ assert_that(subject.minargs(1, 2)).equals("one-two")
498
+ assert_that(subject.minargs(1, 2, 3)).equals("one-two-three")
499
+ assert_that(subject.minargs(1, 2, 4)).equals("default")
500
+ assert_that(subject.minargs(1, 2, 3, 4)).equals("default")
490
501
  end
491
502
 
492
503
  should "allow stubbing a method that takes a block" do
493
- assert_equal "default", subject.withblock
494
- assert_equal "default", subject.withblock{ "my-block" }
504
+ assert_that(subject.withblock).equals("default")
505
+ assert_that(subject.withblock{ "my-block" }).equals("default")
495
506
  end
496
507
 
497
508
  should "not allow stubbing methods with invalid arity" do
498
- assert_raises{ Assert.stub(subject, :noargs).with(1){ } }
509
+ assert_that(-> { Assert.stub(subject, :noargs).with(1){ } }).raises
499
510
 
500
- assert_raises{ Assert.stub(subject, :withargs).with{ } }
501
- assert_raises{ Assert.stub(subject, :withargs).with(1, 2){ } }
511
+ assert_that(-> { Assert.stub(subject, :withargs).with{ } }).raises
512
+ assert_that(-> { Assert.stub(subject, :withargs).with(1, 2){ } }).raises
502
513
 
503
- assert_raises{ Assert.stub(subject, :minargs).with{ } }
504
- assert_raises{ Assert.stub(subject, :minargs).with(1){ } }
514
+ assert_that(-> { Assert.stub(subject, :minargs).with{ } }).raises
515
+ assert_that(-> { Assert.stub(subject, :minargs).with(1){ } }).raises
505
516
 
506
- assert_raises{ Assert.stub(subject, :withblock).with(1){ } }
517
+ assert_that(-> { Assert.stub(subject, :withblock).with(1){ } }).raises
507
518
  end
508
519
 
509
520
  should "not allow calling methods with invalid arity" do
510
- assert_raises{ subject.noargs(1) }
521
+ assert_that(-> { subject.noargs(1) }).raises
511
522
 
512
- assert_raises{ subject.withargs }
513
- assert_raises{ subject.withargs(1, 2) }
523
+ assert_that(-> { subject.withargs }).raises
524
+ assert_that(-> { subject.withargs(1, 2) }).raises
514
525
 
515
- assert_raises{ subject.minargs }
516
- assert_raises{ subject.minargs(1) }
526
+ assert_that(-> { subject.minargs }).raises
527
+ assert_that(-> { subject.minargs(1) }).raises
517
528
 
518
- assert_raises{ subject.withblock(1) }
529
+ assert_that(-> { subject.withblock(1) }).raises
519
530
  end
520
531
  end
521
532
 
522
533
  class DelegateClassTests < SystemTests
523
534
  desc "a class that delegates another object"
535
+ subject { class1 }
536
+
524
537
  setup do
525
- @class = DelegateClass
526
- Assert.stub(@class, :noargs){ "default" }
527
- Assert.stub(@class, :noargs).with{ "none" }
538
+ Assert.stub(class1, :noargs){ "default" }
539
+ Assert.stub(class1, :noargs).with{ "none" }
528
540
 
529
- Assert.stub(@class, :withargs){ "default" }
530
- Assert.stub(@class, :withargs).with(1){ "one" }
541
+ Assert.stub(class1, :withargs){ "default" }
542
+ Assert.stub(class1, :withargs).with(1){ "one" }
531
543
 
532
- Assert.stub(@class, :anyargs){ "default" }
533
- Assert.stub(@class, :anyargs).with(1, 2){ "one-two" }
544
+ Assert.stub(class1, :anyargs){ "default" }
545
+ Assert.stub(class1, :anyargs).with(1, 2){ "one-two" }
534
546
 
535
- Assert.stub(@class, :minargs){ "default" }
536
- Assert.stub(@class, :minargs).with(1, 2){ "one-two" }
537
- Assert.stub(@class, :minargs).with(1, 2, 3){ "one-two-three" }
547
+ Assert.stub(class1, :minargs){ "default" }
548
+ Assert.stub(class1, :minargs).with(1, 2){ "one-two" }
549
+ Assert.stub(class1, :minargs).with(1, 2, 3){ "one-two-three" }
538
550
 
539
- Assert.stub(@class, :withblock){ "default" }
551
+ Assert.stub(class1, :withblock){ "default" }
540
552
  end
541
- subject{ @class }
553
+
554
+ let(:class1) { DelegateClass }
542
555
 
543
556
  should "allow stubbing a method that doesn't take args" do
544
- assert_equal "none", subject.noargs
557
+ assert_that(subject.noargs).equals("none")
545
558
  end
546
559
 
547
560
  should "allow stubbing a method that takes args" do
548
- assert_equal "one", subject.withargs(1)
549
- assert_equal "default", subject.withargs(2)
561
+ assert_that(subject.withargs(1)).equals("one")
562
+ assert_that(subject.withargs(2)).equals("default")
550
563
  end
551
564
 
552
565
  should "allow stubbing a method that takes any args" do
553
- assert_equal "default", subject.anyargs
554
- assert_equal "default", subject.anyargs(1)
555
- assert_equal "one-two", subject.anyargs(1, 2)
566
+ assert_that(subject.anyargs).equals("default")
567
+ assert_that(subject.anyargs(1)).equals("default")
568
+ assert_that(subject.anyargs(1, 2)).equals("one-two")
556
569
  end
557
570
 
558
571
  should "allow stubbing a method that takes a minimum number of args" do
559
- assert_equal "one-two", subject.minargs(1, 2)
560
- assert_equal "one-two-three", subject.minargs(1, 2, 3)
561
- assert_equal "default", subject.minargs(1, 2, 4)
562
- assert_equal "default", subject.minargs(1, 2, 3, 4)
572
+ assert_that(subject.minargs(1, 2)).equals("one-two")
573
+ assert_that(subject.minargs(1, 2, 3)).equals("one-two-three")
574
+ assert_that(subject.minargs(1, 2, 4)).equals("default")
575
+ assert_that(subject.minargs(1, 2, 3, 4)).equals("default")
563
576
  end
564
577
 
565
578
  should "allow stubbing a method that takes a block" do
566
- assert_equal "default", subject.withblock
567
- assert_equal "default", subject.withblock{ "my-block" }
579
+ assert_that(subject.withblock).equals("default")
580
+ assert_that(subject.withblock{ "my-block" }).equals("default")
568
581
  end
569
582
 
570
583
  should "allow stubbing methods with invalid arity" do
571
- assert_nothing_raised{ Assert.stub(subject, :noargs).with(1){ } }
584
+ assert_that(-> { Assert.stub(subject, :noargs).with(1){ } }).does_not_raise
572
585
 
573
- assert_nothing_raised{ Assert.stub(subject, :withargs).with{ } }
574
- assert_nothing_raised{ Assert.stub(subject, :withargs).with(1, 2){ } }
586
+ assert_that(-> { Assert.stub(subject, :withargs).with{ } }).does_not_raise
587
+ assert_that(-> { Assert.stub(subject, :withargs).with(1, 2){ } }).does_not_raise
575
588
 
576
- assert_nothing_raised{ Assert.stub(subject, :minargs).with{ } }
577
- assert_nothing_raised{ Assert.stub(subject, :minargs).with(1){ } }
589
+ assert_that(-> { Assert.stub(subject, :minargs).with{ } }).does_not_raise
590
+ assert_that(-> { Assert.stub(subject, :minargs).with(1){ } }).does_not_raise
578
591
 
579
- assert_nothing_raised{ Assert.stub(subject, :withblock).with(1){ } }
592
+ assert_that(-> { Assert.stub(subject, :withblock).with(1){ } }).does_not_raise
580
593
  end
581
594
 
582
595
  should "allow calling methods with invalid arity" do
583
- assert_nothing_raised{ subject.noargs(1) }
596
+ assert_that(-> { subject.noargs(1) }).does_not_raise
584
597
 
585
- assert_nothing_raised{ subject.withargs }
586
- assert_nothing_raised{ subject.withargs(1, 2) }
598
+ assert_that(-> { subject.withargs }).does_not_raise
599
+ assert_that(-> { subject.withargs(1, 2) }).does_not_raise
587
600
 
588
- assert_nothing_raised{ subject.minargs }
589
- assert_nothing_raised{ subject.minargs(1) }
601
+ assert_that(-> { subject.minargs }).does_not_raise
602
+ assert_that(-> { subject.minargs(1) }).does_not_raise
590
603
 
591
- assert_nothing_raised{ subject.withblock(1) }
604
+ assert_that(-> { subject.withblock(1) }).does_not_raise
592
605
  end
593
606
  end
594
607
 
595
608
  class DelegateInstanceTests < SystemTests
596
609
  desc "an instance that delegates another object"
610
+ subject { instance1 }
611
+
597
612
  setup do
598
- @instance = DelegateClass.new
599
- Assert.stub(@instance, :noargs){ "default" }
600
- Assert.stub(@instance, :noargs).with{ "none" }
613
+ Assert.stub(instance1, :noargs){ "default" }
614
+ Assert.stub(instance1, :noargs).with{ "none" }
601
615
 
602
- Assert.stub(@instance, :withargs){ "default" }
603
- Assert.stub(@instance, :withargs).with(1){ "one" }
616
+ Assert.stub(instance1, :withargs){ "default" }
617
+ Assert.stub(instance1, :withargs).with(1){ "one" }
604
618
 
605
- Assert.stub(@instance, :anyargs){ "default" }
606
- Assert.stub(@instance, :anyargs).with(1, 2){ "one-two" }
619
+ Assert.stub(instance1, :anyargs){ "default" }
620
+ Assert.stub(instance1, :anyargs).with(1, 2){ "one-two" }
607
621
 
608
- Assert.stub(@instance, :minargs){ "default" }
609
- Assert.stub(@instance, :minargs).with(1, 2){ "one-two" }
610
- Assert.stub(@instance, :minargs).with(1, 2, 3){ "one-two-three" }
622
+ Assert.stub(instance1, :minargs){ "default" }
623
+ Assert.stub(instance1, :minargs).with(1, 2){ "one-two" }
624
+ Assert.stub(instance1, :minargs).with(1, 2, 3){ "one-two-three" }
611
625
 
612
- Assert.stub(@instance, :withblock){ "default" }
626
+ Assert.stub(instance1, :withblock){ "default" }
613
627
  end
614
- subject{ @instance }
628
+
629
+ let(:instance1) { DelegateClass.new }
615
630
 
616
631
  should "allow stubbing a method that doesn't take args" do
617
- assert_equal "none", subject.noargs
632
+ assert_that(subject.noargs).equals("none")
618
633
  end
619
634
 
620
635
  should "allow stubbing a method that takes args" do
621
- assert_equal "one", subject.withargs(1)
622
- assert_equal "default", subject.withargs(2)
636
+ assert_that(subject.withargs(1)).equals("one")
637
+ assert_that(subject.withargs(2)).equals("default")
623
638
  end
624
639
 
625
640
  should "allow stubbing a method that takes any args" do
626
- assert_equal "default", subject.anyargs
627
- assert_equal "default", subject.anyargs(1)
628
- assert_equal "one-two", subject.anyargs(1, 2)
641
+ assert_that(subject.anyargs).equals("default")
642
+ assert_that(subject.anyargs(1)).equals("default")
643
+ assert_that(subject.anyargs(1, 2)).equals("one-two")
629
644
  end
630
645
 
631
646
  should "allow stubbing a method that takes a minimum number of args" do
632
- assert_equal "one-two", subject.minargs(1, 2)
633
- assert_equal "one-two-three", subject.minargs(1, 2, 3)
634
- assert_equal "default", subject.minargs(1, 2, 4)
635
- assert_equal "default", subject.minargs(1, 2, 3, 4)
647
+ assert_that(subject.minargs(1, 2)).equals("one-two")
648
+ assert_that(subject.minargs(1, 2, 3)).equals("one-two-three")
649
+ assert_that(subject.minargs(1, 2, 4)).equals("default")
650
+ assert_that(subject.minargs(1, 2, 3, 4)).equals("default")
636
651
  end
637
652
 
638
653
  should "allow stubbing a method that takes a block" do
639
- assert_equal "default", subject.withblock
640
- assert_equal "default", subject.withblock{ "my-block" }
654
+ assert_that(subject.withblock).equals("default")
655
+ assert_that(subject.withblock{ "my-block" }).equals("default")
641
656
  end
642
657
 
643
658
  should "allow stubbing methods with invalid arity" do
644
- assert_nothing_raised{ Assert.stub(subject, :noargs).with(1){ } }
659
+ assert_that(-> { Assert.stub(subject, :noargs).with(1){ } }).does_not_raise
645
660
 
646
- assert_nothing_raised{ Assert.stub(subject, :withargs).with{ } }
647
- assert_nothing_raised{ Assert.stub(subject, :withargs).with(1, 2){ } }
661
+ assert_that(-> { Assert.stub(subject, :withargs).with{ } }).does_not_raise
662
+ assert_that(-> { Assert.stub(subject, :withargs).with(1, 2){ } }).does_not_raise
648
663
 
649
- assert_nothing_raised{ Assert.stub(subject, :minargs).with{ } }
650
- assert_nothing_raised{ Assert.stub(subject, :minargs).with(1){ } }
664
+ assert_that(-> { Assert.stub(subject, :minargs).with{ } }).does_not_raise
665
+ assert_that(-> { Assert.stub(subject, :minargs).with(1){ } }).does_not_raise
651
666
 
652
- assert_nothing_raised{ Assert.stub(subject, :withblock).with(1){ } }
667
+ assert_that(-> { Assert.stub(subject, :withblock).with(1){ } }).does_not_raise
653
668
  end
654
669
 
655
670
  should "allow calling methods with invalid arity" do
656
- assert_nothing_raised{ subject.noargs(1) }
671
+ assert_that(-> { subject.noargs(1) }).does_not_raise
657
672
 
658
- assert_nothing_raised{ subject.withargs }
659
- assert_nothing_raised{ subject.withargs(1, 2) }
673
+ assert_that(-> { subject.withargs }).does_not_raise
674
+ assert_that(-> { subject.withargs(1, 2) }).does_not_raise
660
675
 
661
- assert_nothing_raised{ subject.minargs }
662
- assert_nothing_raised{ subject.minargs(1) }
676
+ assert_that(-> { subject.minargs }).does_not_raise
677
+ assert_that(-> { subject.minargs(1) }).does_not_raise
663
678
 
664
- assert_nothing_raised{ subject.withblock(1) }
679
+ assert_that(-> { subject.withblock(1) }).does_not_raise
665
680
  end
666
681
  end
667
682
 
668
683
  class ParentAndChildClassTests < SystemTests
669
684
  desc "for a parent method stubbed on both the parent and child"
670
685
  setup do
671
- @parent_class = Class.new
672
- @child_class = Class.new(@parent_class)
673
-
674
- Assert.stub(@parent_class, :new){ "parent" }
675
- Assert.stub(@child_class, :new){ "child" }
686
+ Assert.stub(parent_class, :new){ "parent" }
687
+ Assert.stub(child_class, :new){ "child" }
676
688
  end
677
689
 
690
+ let(:parent_class) { Class.new }
691
+ let(:child_class) { Class.new(parent_class) }
692
+
678
693
  should "allow stubbing the methods individually" do
679
- assert_equal "parent", @parent_class.new
680
- assert_equal "child", @child_class.new
694
+ assert_that(parent_class.new).equals("parent")
695
+ assert_that(child_class.new).equals("child")
681
696
  end
682
697
  end
683
698