Handle Homebrew.failed in spec_helper.

This commit is contained in:
Markus Reiter 2017-02-18 16:52:36 +01:00
parent 05a98f24c4
commit 44d2617030
2 changed files with 10 additions and 10 deletions

View File

@ -33,6 +33,8 @@ RSpec.configure do |config|
begin begin
TEST_DIRECTORIES.each(&:mkpath) TEST_DIRECTORIES.each(&:mkpath)
@__homebrew_failed = Homebrew.failed?
@__files_before_test = Find.find(TEST_TMPDIR).map { |f| f.sub(TEST_TMPDIR, "") } @__files_before_test = Find.find(TEST_TMPDIR).map { |f| f.sub(TEST_TMPDIR, "") }
@__argv = ARGV.dup @__argv = ARGV.dup
@ -72,6 +74,10 @@ RSpec.configure do |config|
file leak detected: file leak detected:
#{diff.map { |f| " #{f}" }.join("\n")} #{diff.map { |f| " #{f}" }.join("\n")}
EOS EOS
Homebrew.failed = @__homebrew_failed
end end
end end
end end
RSpec::Matchers.alias_matcher :have_failed, :be_failed

View File

@ -1,7 +1,5 @@
require "utils" require "utils"
RSpec::Matchers.alias_matcher :have_failed, :be_failed
describe "globally-scoped helper methods" do describe "globally-scoped helper methods" do
let(:dir) { @dir = Pathname.new(Dir.mktmpdir) } let(:dir) { @dir = Pathname.new(Dir.mktmpdir) }
@ -13,15 +11,11 @@ describe "globally-scoped helper methods" do
describe "#ofail" do describe "#ofail" do
it "sets Homebrew.failed to true" do it "sets Homebrew.failed to true" do
begin expect {
shutup do ofail "foo"
ofail "foo" }.to output("Error: foo\n").to_stderr
end
expect(Homebrew).to have_failed expect(Homebrew).to have_failed
ensure
Homebrew.failed = false
end
end end
end end