1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
|
Description: Restore Mockery @instances after deliberately nil'ing it
The MockeryNeverSetupTest deliberately sets @instances to nil to check
that teardown raises NotInitializedError. When the Minitest integration
is loaded (giving us per-test verification), its before_teardown hook
runs after the test method and crashes on the nil @instances.
.
Restore the original value after the assertion so the hook can run
cleanly (defaulting to [] for an empty mockery if it was nil).
Author: Simon Quigley <tsimonq2@debian.org>
Origin: vendor
Last-Update: 2026-02-10
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
--- a/test/unit/mockery_test.rb
+++ b/test/unit/mockery_test.rb
@@ -10,10 +10,12 @@ class MockeryNeverSetupTest < Mocha::Tes
include Mocha
def test_should_raise_not_initialized_error
+ original_instances = Mockery.instance_variable_get(:@instances)
Mockery.instance_variable_set(:@instances, nil)
assert_raises(NotInitializedError) do
Mockery.teardown
end
+ Mockery.instance_variable_set(:@instances, original_instances || [])
end
end
|