mirror of
https://github.com/Homebrew/brew.git
synced 2026-10-28 09:34:42 +08:00
Stop bundle specs leaking Tap and Cask doubles
- `Homebrew::Bundle::Tap.taps` and `Homebrew::Bundle::Cask.casks` memoise whatever `Tap.select` and `Cask::Caskroom.casks` return, so the `instance_double`s stubbed in `tap_spec` and `dumper_spec` survived into later examples. - `npm_spec`'s `Installer.install!` example then hit rspec-mocks' "leaked into another example" error whenever a dumper example ran first in the same process, failing random test orders. Signed-off-by: Patrick Linnane <patrick@linnane.io>
This commit is contained in:
2 files changed
+11
No files matched your search
@@ -47,6 +47,12 @@ RSpec.describe Homebrew::Bundle::Dumper do
|
||||
allow(Tap).to receive(:select).and_return([])
|
||||
end
|
||||
|
||||
# `Tap.taps` and `Cask.casks` memoise the stubbed doubles, which must not outlive the example.
|
||||
after do
|
||||
Homebrew::Bundle::Tap.reset!
|
||||
Homebrew::Bundle::Cask.reset!
|
||||
end
|
||||
|
||||
it "generates output" do
|
||||
expect(dumper.build_brewfile(
|
||||
describe: false, no_restart: false, formulae: true, taps: true, casks: true,
|
||||
|
||||
@@ -6,6 +6,11 @@ require "bundle/skipper"
|
||||
require "bundle/tap"
|
||||
|
||||
RSpec.describe Homebrew::Bundle::Tap do
|
||||
# `taps` memoises the stubbed `Tap` doubles, which must not outlive the example.
|
||||
after do
|
||||
described_class.reset!
|
||||
end
|
||||
|
||||
describe "dumping" do
|
||||
subject(:dumper) { described_class }
|
||||
|
||||
|
||||
Reference in new issue
Block a user