rspec-mocks 2.12.1 → 2.12.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Changelog.md +17 -0
- data/lib/rspec/mocks.rb +8 -0
- data/lib/rspec/mocks/message_expectation.rb +6 -11
- data/lib/rspec/mocks/method_double.rb +19 -2
- data/lib/rspec/mocks/mutate_const.rb +1 -1
- data/lib/rspec/mocks/proxy.rb +1 -1
- data/lib/rspec/mocks/version.rb +1 -1
- data/lib/spec/mocks.rb +4 -0
- data/spec/rspec/mocks/and_call_original_spec.rb +22 -0
- data/spec/rspec/mocks/and_yield_spec.rb +7 -7
- data/spec/rspec/mocks/any_instance/message_chains_spec.rb +6 -6
- data/spec/rspec/mocks/any_instance_spec.rb +94 -94
- data/spec/rspec/mocks/any_number_of_times_spec.rb +2 -2
- data/spec/rspec/mocks/argument_expectation_spec.rb +3 -3
- data/spec/rspec/mocks/at_least_spec.rb +15 -15
- data/spec/rspec/mocks/at_most_spec.rb +7 -7
- data/spec/rspec/mocks/block_return_value_spec.rb +6 -6
- data/spec/rspec/mocks/bug_report_10260_spec.rb +1 -1
- data/spec/rspec/mocks/bug_report_10263_spec.rb +6 -4
- data/spec/rspec/mocks/bug_report_11545_spec.rb +1 -1
- data/spec/rspec/mocks/bug_report_600_spec.rb +1 -1
- data/spec/rspec/mocks/bug_report_7611_spec.rb +1 -1
- data/spec/rspec/mocks/bug_report_8165_spec.rb +4 -4
- data/spec/rspec/mocks/bug_report_830_spec.rb +2 -2
- data/spec/rspec/mocks/bug_report_957_spec.rb +2 -2
- data/spec/rspec/mocks/configuration_spec.rb +4 -4
- data/spec/rspec/mocks/double_spec.rb +1 -1
- data/spec/rspec/mocks/failing_argument_matchers_spec.rb +1 -1
- data/spec/rspec/mocks/hash_excluding_matcher_spec.rb +13 -13
- data/spec/rspec/mocks/hash_including_matcher_spec.rb +30 -30
- data/spec/rspec/mocks/mock_ordering_spec.rb +8 -8
- data/spec/rspec/mocks/mock_space_spec.rb +4 -4
- data/spec/rspec/mocks/mock_spec.rb +94 -90
- data/spec/rspec/mocks/multiple_return_value_spec.rb +21 -21
- data/spec/rspec/mocks/mutate_const_spec.rb +112 -102
- data/spec/rspec/mocks/nil_expectation_warning_spec.rb +6 -12
- data/spec/rspec/mocks/null_object_mock_spec.rb +12 -12
- data/spec/rspec/mocks/once_counts_spec.rb +7 -7
- data/spec/rspec/mocks/options_hash_spec.rb +6 -6
- data/spec/rspec/mocks/partial_mock_spec.rb +15 -15
- data/spec/rspec/mocks/partial_mock_using_mocks_directly_spec.rb +17 -17
- data/spec/rspec/mocks/passing_argument_matchers_spec.rb +6 -6
- data/spec/rspec/mocks/precise_counts_spec.rb +7 -7
- data/spec/rspec/mocks/record_messages_spec.rb +4 -4
- data/spec/rspec/mocks/serialization_spec.rb +3 -3
- data/spec/rspec/mocks/stash_spec.rb +1 -1
- data/spec/rspec/mocks/stub_chain_spec.rb +22 -22
- data/spec/rspec/mocks/stub_implementation_spec.rb +10 -10
- data/spec/rspec/mocks/stub_spec.rb +50 -31
- data/spec/rspec/mocks/stubbed_message_expectations_spec.rb +3 -3
- data/spec/rspec/mocks/test_double_spec.rb +3 -3
- data/spec/rspec/mocks/to_ary_spec.rb +7 -7
- data/spec/rspec/mocks/twice_counts_spec.rb +8 -8
- data/spec/rspec/mocks_spec.rb +13 -4
- data/spec/spec_helper.rb +4 -0
- metadata +5 -5
@@ -10,18 +10,18 @@ module RSpec
|
|
10
10
|
end
|
11
11
|
|
12
12
|
it "returns values in order" do
|
13
|
-
@double.do_something.
|
14
|
-
@double.do_something.
|
15
|
-
@double.do_something.
|
13
|
+
expect(@double.do_something).to eq @return_values[0]
|
14
|
+
expect(@double.do_something).to eq @return_values[1]
|
15
|
+
expect(@double.do_something).to eq @return_values[2]
|
16
16
|
@double.rspec_verify
|
17
17
|
end
|
18
18
|
|
19
19
|
it "falls back to a previously stubbed value" do
|
20
20
|
@double.stub :do_something => :stub_result
|
21
|
-
@double.do_something.
|
22
|
-
@double.do_something.
|
23
|
-
@double.do_something.
|
24
|
-
@double.do_something.
|
21
|
+
expect(@double.do_something).to eq @return_values[0]
|
22
|
+
expect(@double.do_something).to eq @return_values[1]
|
23
|
+
expect(@double.do_something).to eq @return_values[2]
|
24
|
+
expect(@double.do_something).to eq :stub_result
|
25
25
|
end
|
26
26
|
|
27
27
|
it "fails when there are too few calls (if there is no stub)" do
|
@@ -47,9 +47,9 @@ module RSpec
|
|
47
47
|
end
|
48
48
|
|
49
49
|
it "returns values in order to consecutive calls" do
|
50
|
-
@double.do_something.
|
51
|
-
@double.do_something.
|
52
|
-
@double.do_something.
|
50
|
+
expect(@double.do_something).to eq @return_values[0]
|
51
|
+
expect(@double.do_something).to eq @return_values[1]
|
52
|
+
expect(@double.do_something).to eq @return_values[2]
|
53
53
|
@double.rspec_verify
|
54
54
|
end
|
55
55
|
end
|
@@ -61,14 +61,14 @@ module RSpec
|
|
61
61
|
end
|
62
62
|
|
63
63
|
it "uses the last return value for subsequent calls" do
|
64
|
-
@double.do_something.
|
65
|
-
@double.do_something.
|
66
|
-
@double.do_something.
|
64
|
+
expect(@double.do_something).to equal(11)
|
65
|
+
expect(@double.do_something).to equal(22)
|
66
|
+
expect(@double.do_something).to equal(22)
|
67
67
|
@double.rspec_verify
|
68
68
|
end
|
69
69
|
|
70
70
|
it "fails when called less than the specified number" do
|
71
|
-
@double.do_something.
|
71
|
+
expect(@double.do_something).to equal(11)
|
72
72
|
expect { @double.rspec_verify }.to raise_error(RSpec::Mocks::MockExpectationError)
|
73
73
|
end
|
74
74
|
|
@@ -76,14 +76,14 @@ module RSpec
|
|
76
76
|
before { @double.stub(:do_something).and_return :stub_result }
|
77
77
|
|
78
78
|
it "uses the last value for subsequent calls" do
|
79
|
-
@double.do_something.
|
80
|
-
@double.do_something.
|
81
|
-
@double.do_something.
|
79
|
+
expect(@double.do_something).to equal(11)
|
80
|
+
expect(@double.do_something).to equal(22)
|
81
|
+
expect(@double.do_something).to equal(22)
|
82
82
|
@double.rspec_verify
|
83
83
|
end
|
84
84
|
|
85
85
|
it "fails when called less than the specified number" do
|
86
|
-
@double.do_something.
|
86
|
+
expect(@double.do_something).to equal(11)
|
87
87
|
expect { @double.rspec_verify }.to raise_error(RSpec::Mocks::MockExpectationError)
|
88
88
|
end
|
89
89
|
end
|
@@ -96,9 +96,9 @@ module RSpec
|
|
96
96
|
end
|
97
97
|
|
98
98
|
it "uses the last return value for subsequent calls" do
|
99
|
-
@double.do_something.
|
100
|
-
@double.do_something.
|
101
|
-
@double.do_something.
|
99
|
+
expect(@double.do_something).to equal(11)
|
100
|
+
expect(@double.do_something).to equal(22)
|
101
|
+
expect(@double.do_something).to equal(22)
|
102
102
|
@double.rspec_verify
|
103
103
|
end
|
104
104
|
|
@@ -51,88 +51,94 @@ module RSpec
|
|
51
51
|
end
|
52
52
|
|
53
53
|
it 'allows it to be stubbed' do
|
54
|
-
const.
|
54
|
+
expect(const).not_to eq(7)
|
55
55
|
stub_const(const_name, 7)
|
56
|
-
const.
|
56
|
+
expect(const).to eq(7)
|
57
57
|
end
|
58
58
|
|
59
59
|
it 'resets it to its original value when rspec clears its mocks' do
|
60
60
|
original_value = const
|
61
|
-
original_value.
|
61
|
+
expect(original_value).not_to eq(:a)
|
62
62
|
stub_const(const_name, :a)
|
63
63
|
reset_rspec_mocks
|
64
|
-
const.
|
64
|
+
expect(const).to be(original_value)
|
65
65
|
end
|
66
66
|
|
67
67
|
it 'returns the stubbed value' do
|
68
|
-
stub_const(const_name, 7).
|
68
|
+
expect(stub_const(const_name, 7)).to eq(7)
|
69
69
|
end
|
70
70
|
end
|
71
71
|
|
72
72
|
shared_examples_for "loaded constant hiding" do |const_name|
|
73
|
-
before
|
73
|
+
before do
|
74
|
+
expect(recursive_const_defined?(const_name)).to be_true
|
75
|
+
end
|
74
76
|
|
75
77
|
it 'allows it to be hidden' do
|
76
78
|
hide_const(const_name)
|
77
|
-
recursive_const_defined?(const_name).
|
79
|
+
expect(recursive_const_defined?(const_name)).to be_false
|
78
80
|
end
|
79
81
|
|
80
82
|
it 'resets the constant when rspec clear its mocks' do
|
81
83
|
hide_const(const_name)
|
82
84
|
reset_rspec_mocks
|
83
|
-
recursive_const_defined?(const_name).
|
85
|
+
expect(recursive_const_defined?(const_name)).to be_true
|
84
86
|
end
|
85
87
|
|
86
88
|
it 'returns nil' do
|
87
|
-
hide_const(const_name).
|
89
|
+
expect(hide_const(const_name)).to be_nil
|
88
90
|
end
|
89
91
|
end
|
90
92
|
|
91
93
|
shared_examples_for "unloaded constant stubbing" do |const_name|
|
92
94
|
include_context "constant example methods", const_name
|
93
95
|
|
94
|
-
before
|
96
|
+
before do
|
97
|
+
expect(recursive_const_defined?(const_name)).to be_false
|
98
|
+
end
|
95
99
|
|
96
100
|
it 'allows it to be stubbed' do
|
97
101
|
stub_const(const_name, 7)
|
98
|
-
const.
|
102
|
+
expect(const).to eq(7)
|
99
103
|
end
|
100
104
|
|
101
105
|
it 'removes the constant when rspec clears its mocks' do
|
102
106
|
stub_const(const_name, 7)
|
103
107
|
reset_rspec_mocks
|
104
|
-
recursive_const_defined?(const_name).
|
108
|
+
expect(recursive_const_defined?(const_name)).to be_false
|
105
109
|
end
|
106
110
|
|
107
111
|
it 'returns the stubbed value' do
|
108
|
-
stub_const(const_name, 7).
|
112
|
+
expect(stub_const(const_name, 7)).to eq(7)
|
109
113
|
end
|
110
114
|
|
111
115
|
it 'ignores the :transfer_nested_constants option if passed' do
|
112
116
|
stub = Module.new
|
113
117
|
stub_const(const_name, stub, :transfer_nested_constants => true)
|
114
|
-
stub.constants.
|
118
|
+
expect(stub.constants).to eq([])
|
115
119
|
end
|
116
120
|
end
|
117
121
|
|
118
122
|
shared_examples_for "unloaded constant hiding" do |const_name|
|
119
123
|
include_context "constant example methods", const_name
|
120
124
|
|
121
|
-
before
|
125
|
+
before do
|
126
|
+
expect(recursive_const_defined?(const_name)).to be_false
|
127
|
+
end
|
122
128
|
|
123
129
|
it 'allows it to be hidden, though the operation has no effect' do
|
124
130
|
hide_const(const_name)
|
125
|
-
recursive_const_defined?(const_name).
|
131
|
+
expect(recursive_const_defined?(const_name)).to be_false
|
126
132
|
end
|
127
133
|
|
128
134
|
it 'remains undefined after rspec clears its mocks' do
|
129
135
|
hide_const(const_name)
|
130
136
|
reset_rspec_mocks
|
131
|
-
recursive_const_defined?(const_name).
|
137
|
+
expect(recursive_const_defined?(const_name)).to be_false
|
132
138
|
end
|
133
139
|
|
134
140
|
it 'returns nil' do
|
135
|
-
hide_const(const_name).
|
141
|
+
expect(hide_const(const_name)).to be_nil
|
136
142
|
end
|
137
143
|
end
|
138
144
|
|
@@ -141,7 +147,7 @@ module RSpec
|
|
141
147
|
it_behaves_like "loaded constant hiding", "TestClass::Nested"
|
142
148
|
end
|
143
149
|
|
144
|
-
context 'for a loaded
|
150
|
+
context 'for a loaded constant prefixed with ::' do
|
145
151
|
it_behaves_like 'loaded constant hiding', "::TestClass"
|
146
152
|
end
|
147
153
|
|
@@ -181,20 +187,20 @@ module RSpec
|
|
181
187
|
hide_const("TestClass")
|
182
188
|
|
183
189
|
reset_rspec_mocks
|
184
|
-
TestClass.
|
190
|
+
expect(TestClass).to be(orig_value)
|
185
191
|
end
|
186
192
|
|
187
193
|
it 'allows a constant to be hidden, then stubbed, restoring it to its original value properly' do
|
188
194
|
orig_value = TOP_LEVEL_VALUE_CONST
|
189
195
|
|
190
196
|
hide_const("TOP_LEVEL_VALUE_CONST")
|
191
|
-
recursive_const_defined?("TOP_LEVEL_VALUE_CONST").
|
197
|
+
expect(recursive_const_defined?("TOP_LEVEL_VALUE_CONST")).to be_false
|
192
198
|
|
193
199
|
stub_const("TOP_LEVEL_VALUE_CONST", 12345)
|
194
|
-
TOP_LEVEL_VALUE_CONST.
|
200
|
+
expect(TOP_LEVEL_VALUE_CONST).to eq 12345
|
195
201
|
|
196
202
|
reset_rspec_mocks
|
197
|
-
TOP_LEVEL_VALUE_CONST.
|
203
|
+
expect(TOP_LEVEL_VALUE_CONST).to eq orig_value
|
198
204
|
end
|
199
205
|
end
|
200
206
|
|
@@ -209,24 +215,24 @@ module RSpec
|
|
209
215
|
stub_const("TestClass", stub2)
|
210
216
|
|
211
217
|
reset_rspec_mocks
|
212
|
-
TestClass.
|
218
|
+
expect(TestClass).to be(orig_value)
|
213
219
|
end
|
214
220
|
|
215
221
|
it 'allows nested constants to be transferred to a stub module' do
|
216
222
|
tc_nested = TestClass::Nested
|
217
223
|
stub = Module.new
|
218
224
|
stub_const("TestClass", stub, :transfer_nested_constants => true)
|
219
|
-
stub::M.
|
220
|
-
stub::N.
|
221
|
-
stub::Nested.
|
225
|
+
expect(stub::M).to eq(:m)
|
226
|
+
expect(stub::N).to eq(:n)
|
227
|
+
expect(stub::Nested).to be(tc_nested)
|
222
228
|
end
|
223
229
|
|
224
230
|
it 'does not transfer nested constants that are inherited from a superclass' do
|
225
231
|
stub = Module.new
|
226
232
|
stub_const("TestSubClass", stub, :transfer_nested_constants => true)
|
227
|
-
stub::P.
|
228
|
-
defined?(stub::M).
|
229
|
-
defined?(stub::N).
|
233
|
+
expect(stub::P).to eq(:p)
|
234
|
+
expect(defined?(stub::M)).to be_false
|
235
|
+
expect(defined?(stub::N)).to be_false
|
230
236
|
end
|
231
237
|
|
232
238
|
it 'raises an error when asked to transfer a nested inherited constant' do
|
@@ -236,15 +242,15 @@ module RSpec
|
|
236
242
|
stub_const("TestSubClass", Module.new, :transfer_nested_constants => [:M])
|
237
243
|
}.to raise_error(ArgumentError)
|
238
244
|
|
239
|
-
TestSubClass.
|
245
|
+
expect(TestSubClass).to be(original_tsc)
|
240
246
|
end
|
241
247
|
|
242
248
|
it 'allows nested constants to be selectively transferred to a stub module' do
|
243
249
|
stub = Module.new
|
244
250
|
stub_const("TestClass", stub, :transfer_nested_constants => [:M, :N])
|
245
|
-
stub::M.
|
246
|
-
stub::N.
|
247
|
-
defined?(stub::Nested).
|
251
|
+
expect(stub::M).to eq(:m)
|
252
|
+
expect(stub::N).to eq(:n)
|
253
|
+
expect(defined?(stub::Nested)).to be_false
|
248
254
|
end
|
249
255
|
|
250
256
|
it 'raises an error if asked to transfer nested constants but given an object that does not support them' do
|
@@ -254,13 +260,13 @@ module RSpec
|
|
254
260
|
stub_const("TestClass", stub, :transfer_nested_constants => true)
|
255
261
|
}.to raise_error(ArgumentError)
|
256
262
|
|
257
|
-
TestClass.
|
263
|
+
expect(TestClass).to be(original_tc)
|
258
264
|
|
259
265
|
expect {
|
260
266
|
stub_const("TestClass", stub, :transfer_nested_constants => [:M])
|
261
267
|
}.to raise_error(ArgumentError)
|
262
268
|
|
263
|
-
TestClass.
|
269
|
+
expect(TestClass).to be(original_tc)
|
264
270
|
end
|
265
271
|
|
266
272
|
it 'raises an error if asked to transfer nested constants on a constant that does not support nested constants' do
|
@@ -269,25 +275,25 @@ module RSpec
|
|
269
275
|
stub_const("TOP_LEVEL_VALUE_CONST", stub, :transfer_nested_constants => true)
|
270
276
|
}.to raise_error(ArgumentError)
|
271
277
|
|
272
|
-
TOP_LEVEL_VALUE_CONST.
|
278
|
+
expect(TOP_LEVEL_VALUE_CONST).to eq(7)
|
273
279
|
|
274
280
|
expect {
|
275
281
|
stub_const("TOP_LEVEL_VALUE_CONST", stub, :transfer_nested_constants => [:M])
|
276
282
|
}.to raise_error(ArgumentError)
|
277
283
|
|
278
|
-
TOP_LEVEL_VALUE_CONST.
|
284
|
+
expect(TOP_LEVEL_VALUE_CONST).to eq(7)
|
279
285
|
end
|
280
286
|
|
281
287
|
it 'raises an error if asked to transfer a nested constant that is not defined' do
|
282
288
|
original_tc = TestClass
|
283
|
-
defined?(TestClass::V).
|
289
|
+
expect(defined?(TestClass::V)).to be_false
|
284
290
|
stub = Module.new
|
285
291
|
|
286
292
|
expect {
|
287
293
|
stub_const("TestClass", stub, :transfer_nested_constants => [:V])
|
288
294
|
}.to raise_error(/cannot transfer nested constant.*V/i)
|
289
295
|
|
290
|
-
TestClass.
|
296
|
+
expect(TestClass).to be(original_tc)
|
291
297
|
end
|
292
298
|
end
|
293
299
|
|
@@ -295,10 +301,14 @@ module RSpec
|
|
295
301
|
it_behaves_like "loaded constant stubbing", "TestClass::Nested"
|
296
302
|
end
|
297
303
|
|
298
|
-
context 'for a loaded
|
304
|
+
context 'for a loaded constant prefixed with ::' do
|
299
305
|
it_behaves_like 'loaded constant stubbing', "::TestClass"
|
300
306
|
end
|
301
307
|
|
308
|
+
context 'for an unloaded constant prefixed with ::' do
|
309
|
+
it_behaves_like 'unloaded constant stubbing', "::SomeUndefinedConst"
|
310
|
+
end
|
311
|
+
|
302
312
|
context 'for an unloaded constant with nested name that matches a top-level constant' do
|
303
313
|
it_behaves_like "unloaded constant stubbing", "TestClass::Hash"
|
304
314
|
end
|
@@ -315,10 +325,10 @@ module RSpec
|
|
315
325
|
it_behaves_like "unloaded constant stubbing", "X::Y"
|
316
326
|
|
317
327
|
it 'removes the root constant when rspec clears its mocks' do
|
318
|
-
defined?(X).
|
328
|
+
expect(defined?(X)).to be_false
|
319
329
|
stub_const("X::Y", 7)
|
320
330
|
reset_rspec_mocks
|
321
|
-
defined?(X).
|
331
|
+
expect(defined?(X)).to be_false
|
322
332
|
end
|
323
333
|
end
|
324
334
|
|
@@ -326,10 +336,10 @@ module RSpec
|
|
326
336
|
it_behaves_like "unloaded constant stubbing", "X::Y::Z"
|
327
337
|
|
328
338
|
it 'removes the root constant when rspec clears its mocks' do
|
329
|
-
defined?(X).
|
339
|
+
expect(defined?(X)).to be_false
|
330
340
|
stub_const("X::Y::Z", 7)
|
331
341
|
reset_rspec_mocks
|
332
|
-
defined?(X).
|
342
|
+
expect(defined?(X)).to be_false
|
333
343
|
end
|
334
344
|
end
|
335
345
|
|
@@ -337,16 +347,16 @@ module RSpec
|
|
337
347
|
it_behaves_like "unloaded constant stubbing", "TestClass::X"
|
338
348
|
|
339
349
|
it 'removes the unloaded constant but leaves the loaded constant when rspec resets its mocks' do
|
340
|
-
defined?(TestClass).
|
341
|
-
defined?(TestClass::X).
|
350
|
+
expect(defined?(TestClass)).to be_true
|
351
|
+
expect(defined?(TestClass::X)).to be_false
|
342
352
|
stub_const("TestClass::X", 7)
|
343
353
|
reset_rspec_mocks
|
344
|
-
defined?(TestClass).
|
345
|
-
defined?(TestClass::X).
|
354
|
+
expect(defined?(TestClass)).to be_true
|
355
|
+
expect(defined?(TestClass::X)).to be_false
|
346
356
|
end
|
347
357
|
|
348
358
|
it 'raises a helpful error if it cannot be stubbed due to an intermediary constant that is not a module' do
|
349
|
-
TestClass::M.
|
359
|
+
expect(TestClass::M).to be_a(Symbol)
|
350
360
|
expect { stub_const("TestClass::M::X", 5) }.to raise_error(/cannot stub/i)
|
351
361
|
end
|
352
362
|
end
|
@@ -355,12 +365,12 @@ module RSpec
|
|
355
365
|
it_behaves_like "unloaded constant stubbing", "TestClass::Nested::NestedEvenMore::X::Y::Z"
|
356
366
|
|
357
367
|
it 'removes the first unloaded constant but leaves the loaded nested constant when rspec resets its mocks' do
|
358
|
-
defined?(TestClass::Nested::NestedEvenMore).
|
359
|
-
defined?(TestClass::Nested::NestedEvenMore::X).
|
368
|
+
expect(defined?(TestClass::Nested::NestedEvenMore)).to be_true
|
369
|
+
expect(defined?(TestClass::Nested::NestedEvenMore::X)).to be_false
|
360
370
|
stub_const("TestClass::Nested::NestedEvenMore::X::Y::Z", 7)
|
361
371
|
reset_rspec_mocks
|
362
|
-
defined?(TestClass::Nested::NestedEvenMore).
|
363
|
-
defined?(TestClass::Nested::NestedEvenMore::X).
|
372
|
+
expect(defined?(TestClass::Nested::NestedEvenMore)).to be_true
|
373
|
+
expect(defined?(TestClass::Nested::NestedEvenMore::X)).to be_false
|
364
374
|
end
|
365
375
|
end
|
366
376
|
end
|
@@ -371,47 +381,47 @@ module RSpec
|
|
371
381
|
context 'for a previously defined unstubbed constant' do
|
372
382
|
let(:const) { Constant.original("TestClass::M") }
|
373
383
|
|
374
|
-
it("exposes its name") { const.name.
|
375
|
-
it("indicates it was previously defined") { const.
|
376
|
-
it("indicates it has not been mutated") { const.
|
377
|
-
it("indicates it has not been stubbed") { const.
|
378
|
-
it("indicates it has not been hidden") { const.
|
379
|
-
it("exposes its original value") { const.original_value.
|
384
|
+
it("exposes its name") { expect(const.name).to eq("TestClass::M") }
|
385
|
+
it("indicates it was previously defined") { expect(const).to be_previously_defined }
|
386
|
+
it("indicates it has not been mutated") { expect(const).not_to be_mutated }
|
387
|
+
it("indicates it has not been stubbed") { expect(const).not_to be_stubbed }
|
388
|
+
it("indicates it has not been hidden") { expect(const).not_to be_hidden }
|
389
|
+
it("exposes its original value") { expect(const.original_value).to eq(:m) }
|
380
390
|
end
|
381
391
|
|
382
392
|
context 'for a previously defined stubbed constant' do
|
383
393
|
before { stub_const("TestClass::M", :other) }
|
384
394
|
let(:const) { Constant.original("TestClass::M") }
|
385
395
|
|
386
|
-
it("exposes its name") { const.name.
|
387
|
-
it("indicates it was previously defined") { const.
|
388
|
-
it("indicates it has been mutated") { const.
|
389
|
-
it("indicates it has been stubbed") { const.
|
390
|
-
it("indicates it has not been hidden") { const.
|
391
|
-
it("exposes its original value") { const.original_value.
|
396
|
+
it("exposes its name") { expect(const.name).to eq("TestClass::M") }
|
397
|
+
it("indicates it was previously defined") { expect(const).to be_previously_defined }
|
398
|
+
it("indicates it has been mutated") { expect(const).to be_mutated }
|
399
|
+
it("indicates it has been stubbed") { expect(const).to be_stubbed }
|
400
|
+
it("indicates it has not been hidden") { expect(const).not_to be_hidden }
|
401
|
+
it("exposes its original value") { expect(const.original_value).to eq(:m) }
|
392
402
|
end
|
393
403
|
|
394
404
|
context 'for a previously undefined stubbed constant' do
|
395
405
|
before { stub_const("TestClass::Undefined", :other) }
|
396
406
|
let(:const) { Constant.original("TestClass::Undefined") }
|
397
407
|
|
398
|
-
it("exposes its name") { const.name.
|
399
|
-
it("indicates it was not previously defined") { const.
|
400
|
-
it("indicates it has been mutated") { const.
|
401
|
-
it("indicates it has been stubbed") { const.
|
402
|
-
it("indicates it has not been hidden") { const.
|
403
|
-
it("returns nil for the original value") { const.original_value.
|
408
|
+
it("exposes its name") { expect(const.name).to eq("TestClass::Undefined") }
|
409
|
+
it("indicates it was not previously defined") { expect(const).not_to be_previously_defined }
|
410
|
+
it("indicates it has been mutated") { expect(const).to be_mutated }
|
411
|
+
it("indicates it has been stubbed") { expect(const).to be_stubbed }
|
412
|
+
it("indicates it has not been hidden") { expect(const).not_to be_hidden }
|
413
|
+
it("returns nil for the original value") { expect(const.original_value).to be_nil }
|
404
414
|
end
|
405
415
|
|
406
416
|
context 'for a previously undefined unstubbed constant' do
|
407
417
|
let(:const) { Constant.original("TestClass::Undefined") }
|
408
418
|
|
409
|
-
it("exposes its name") { const.name.
|
410
|
-
it("indicates it was not previously defined") { const.
|
411
|
-
it("indicates it has not been mutated") { const.
|
412
|
-
it("indicates it has not been stubbed") { const.
|
413
|
-
it("indicates it has not been hidden") { const.
|
414
|
-
it("returns nil for the original value") { const.original_value.
|
419
|
+
it("exposes its name") { expect(const.name).to eq("TestClass::Undefined") }
|
420
|
+
it("indicates it was not previously defined") { expect(const).not_to be_previously_defined }
|
421
|
+
it("indicates it has not been mutated") { expect(const).not_to be_mutated }
|
422
|
+
it("indicates it has not been stubbed") { expect(const).not_to be_stubbed }
|
423
|
+
it("indicates it has not been hidden") { expect(const).not_to be_hidden }
|
424
|
+
it("returns nil for the original value") { expect(const.original_value).to be_nil }
|
415
425
|
end
|
416
426
|
|
417
427
|
context 'for a previously defined constant that has been stubbed twice' do
|
@@ -419,12 +429,12 @@ module RSpec
|
|
419
429
|
before { stub_const("TestClass::M", 2) }
|
420
430
|
let(:const) { Constant.original("TestClass::M") }
|
421
431
|
|
422
|
-
it("exposes its name") { const.name.
|
423
|
-
it("indicates it was previously defined") { const.
|
424
|
-
it("indicates it has been mutated") { const.
|
425
|
-
it("indicates it has been stubbed") { const.
|
426
|
-
it("indicates it has not been hidden") { const.
|
427
|
-
it("exposes its original value") { const.original_value.
|
432
|
+
it("exposes its name") { expect(const.name).to eq("TestClass::M") }
|
433
|
+
it("indicates it was previously defined") { expect(const).to be_previously_defined }
|
434
|
+
it("indicates it has been mutated") { expect(const).to be_mutated }
|
435
|
+
it("indicates it has been stubbed") { expect(const).to be_stubbed }
|
436
|
+
it("indicates it has not been hidden") { expect(const).not_to be_hidden }
|
437
|
+
it("exposes its original value") { expect(const.original_value).to eq(:m) }
|
428
438
|
end
|
429
439
|
|
430
440
|
context 'for a previously undefined constant that has been stubbed twice' do
|
@@ -432,24 +442,24 @@ module RSpec
|
|
432
442
|
before { stub_const("TestClass::Undefined", 2) }
|
433
443
|
let(:const) { Constant.original("TestClass::Undefined") }
|
434
444
|
|
435
|
-
it("exposes its name") { const.name.
|
436
|
-
it("indicates it was not previously defined") { const.
|
437
|
-
it("indicates it has been mutated") { const.
|
438
|
-
it("indicates it has been stubbed") { const.
|
439
|
-
it("indicates it has not been hidden") { const.
|
440
|
-
it("returns nil for the original value") { const.original_value.
|
445
|
+
it("exposes its name") { expect(const.name).to eq("TestClass::Undefined") }
|
446
|
+
it("indicates it was not previously defined") { expect(const).not_to be_previously_defined }
|
447
|
+
it("indicates it has been mutated") { expect(const).to be_mutated }
|
448
|
+
it("indicates it has been stubbed") { expect(const).to be_stubbed }
|
449
|
+
it("indicates it has not been hidden") { expect(const).not_to be_hidden }
|
450
|
+
it("returns nil for the original value") { expect(const.original_value).to be_nil }
|
441
451
|
end
|
442
452
|
|
443
453
|
context 'for a previously defined hidden constant' do
|
444
454
|
before { hide_const("TestClass::M") }
|
445
455
|
let(:const) { Constant.original("TestClass::M") }
|
446
456
|
|
447
|
-
it("exposes its name") { const.name.
|
448
|
-
it("indicates it was previously defined") { const.
|
449
|
-
it("indicates it has been mutated") { const.
|
450
|
-
it("indicates it has not been stubbed") { const.
|
451
|
-
it("indicates it has been hidden") { const.
|
452
|
-
it("exposes its original value") { const.original_value.
|
457
|
+
it("exposes its name") { expect(const.name).to eq("TestClass::M") }
|
458
|
+
it("indicates it was previously defined") { expect(const).to be_previously_defined }
|
459
|
+
it("indicates it has been mutated") { expect(const).to be_mutated }
|
460
|
+
it("indicates it has not been stubbed") { expect(const).not_to be_stubbed }
|
461
|
+
it("indicates it has been hidden") { expect(const).to be_hidden }
|
462
|
+
it("exposes its original value") { expect(const.original_value).to eq(:m) }
|
453
463
|
end
|
454
464
|
|
455
465
|
context 'for a previously defined constant that has been hidden twice' do
|
@@ -457,12 +467,12 @@ module RSpec
|
|
457
467
|
before { hide_const("TestClass::M") }
|
458
468
|
let(:const) { Constant.original("TestClass::M") }
|
459
469
|
|
460
|
-
it("exposes its name") { const.name.
|
461
|
-
it("indicates it was previously defined") { const.
|
462
|
-
it("indicates it has been mutated") { const.
|
463
|
-
it("indicates it has not been stubbed") { const.
|
464
|
-
it("indicates it has been hidden") { const.
|
465
|
-
it("exposes its original value") { const.original_value.
|
470
|
+
it("exposes its name") { expect(const.name).to eq("TestClass::M") }
|
471
|
+
it("indicates it was previously defined") { expect(const).to be_previously_defined }
|
472
|
+
it("indicates it has been mutated") { expect(const).to be_mutated }
|
473
|
+
it("indicates it has not been stubbed") { expect(const).not_to be_stubbed }
|
474
|
+
it("indicates it has been hidden") { expect(const).to be_hidden }
|
475
|
+
it("exposes its original value") { expect(const.original_value).to eq(:m) }
|
466
476
|
end
|
467
477
|
end
|
468
478
|
end
|