aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Reiter2017-02-18 16:52:36 +0100
committerMarkus Reiter2017-02-19 18:41:53 +0100
commit44d2617030f8407e74036decd93d94b33db881e7 (patch)
treec574033c7e7a6b669253e20a46dcb303d2ba1e99
parent05a98f24c4d21b3a3c7fcb4045e74619a4628f4c (diff)
downloadbrew-44d2617030f8407e74036decd93d94b33db881e7.tar.bz2
Handle `Homebrew.failed` in `spec_helper`.
-rw-r--r--Library/Homebrew/test/spec_helper.rb6
-rw-r--r--Library/Homebrew/test/utils_spec.rb14
2 files changed, 10 insertions, 10 deletions
diff --git a/Library/Homebrew/test/spec_helper.rb b/Library/Homebrew/test/spec_helper.rb
index 292c5786a..63ffe63fe 100644
--- a/Library/Homebrew/test/spec_helper.rb
+++ b/Library/Homebrew/test/spec_helper.rb
@@ -33,6 +33,8 @@ RSpec.configure do |config|
begin
TEST_DIRECTORIES.each(&:mkpath)
+ @__homebrew_failed = Homebrew.failed?
+
@__files_before_test = Find.find(TEST_TMPDIR).map { |f| f.sub(TEST_TMPDIR, "") }
@__argv = ARGV.dup
@@ -72,6 +74,10 @@ RSpec.configure do |config|
file leak detected:
#{diff.map { |f| " #{f}" }.join("\n")}
EOS
+
+ Homebrew.failed = @__homebrew_failed
end
end
end
+
+RSpec::Matchers.alias_matcher :have_failed, :be_failed
diff --git a/Library/Homebrew/test/utils_spec.rb b/Library/Homebrew/test/utils_spec.rb
index de6b287d2..040ad630b 100644
--- a/Library/Homebrew/test/utils_spec.rb
+++ b/Library/Homebrew/test/utils_spec.rb
@@ -1,7 +1,5 @@
require "utils"
-RSpec::Matchers.alias_matcher :have_failed, :be_failed
-
describe "globally-scoped helper methods" do
let(:dir) { @dir = Pathname.new(Dir.mktmpdir) }
@@ -13,15 +11,11 @@ describe "globally-scoped helper methods" do
describe "#ofail" do
it "sets Homebrew.failed to true" do
- begin
- shutup do
- ofail "foo"
- end
+ expect {
+ ofail "foo"
+ }.to output("Error: foo\n").to_stderr
- expect(Homebrew).to have_failed
- ensure
- Homebrew.failed = false
- end
+ expect(Homebrew).to have_failed
end
end