Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't fail erroneously on unstub_const when not stubbed
It's possible to call `unstub_const` without having called `stub_const`, or while having already called `unstub_const`. This can happen when there is an exception while setting up the model itself in the before block, and `stub_const` is never called, but the after block still tries to cleanup by calling `unstub_const`.
- Loading branch information
Showing
2 changed files
with
24 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'spec_helper' | ||
|
||
module WithModel | ||
describe ConstantStubber do | ||
it 'allows calling unstub_const multiple times' do | ||
stubber = described_class.new('Foo') | ||
stubber.stub_const(1) | ||
stubber.unstub_const | ||
stubber.unstub_const | ||
end | ||
|
||
it 'allows calling unstub_const without stub_const' do | ||
stubber = described_class.new('Foo') | ||
stubber.unstub_const | ||
end | ||
end | ||
end |