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