aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorMarkus Reiter2017-02-16 01:02:42 +0100
committerGitHub2017-02-16 01:02:42 +0100
commit5a2a0638028ee49991e404c1bd6397c10659474b (patch)
tree3b2892ea372be9ff21a789b123f8100be5f69eeb /Library
parent01f90b0d3300349486b58101fd53c99200ba444d (diff)
parentcfed07734c3eae46afc69d572fe2cc8bc68f0945 (diff)
downloadbrew-5a2a0638028ee49991e404c1bd6397c10659474b.tar.bz2
Merge pull request #1987 from reitermarkus/test-to-spec
Convert Homebrew::Hooks::Bottles test to spec.
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/test/bottle_hooks_spec.rb50
-rw-r--r--Library/Homebrew/test/bottle_hooks_test.rb49
2 files changed, 50 insertions, 49 deletions
diff --git a/Library/Homebrew/test/bottle_hooks_spec.rb b/Library/Homebrew/test/bottle_hooks_spec.rb
new file mode 100644
index 000000000..05c6ea7f0
--- /dev/null
+++ b/Library/Homebrew/test/bottle_hooks_spec.rb
@@ -0,0 +1,50 @@
+require "formula_installer"
+require "hooks/bottles"
+
+RSpec::Matchers.alias_matcher :pour_bottle, :be_pour_bottle
+
+describe Homebrew::Hooks::Bottles do
+ subject { FormulaInstaller.new formula }
+
+ let(:formula) do
+ double(
+ bottle: nil,
+ local_bottle_path: nil,
+ bottle_disabled?: false,
+ some_random_method: true,
+ )
+ end
+
+ after(:each) do
+ described_class.reset_hooks
+ end
+
+ describe "#setup_formula_has_bottle" do
+ context "given a block which evaluates to true" do
+ before(:each) do
+ described_class.setup_formula_has_bottle(&:some_random_method)
+ end
+
+ it { is_expected.to pour_bottle }
+ end
+
+ context "given a block which evaluates to false" do
+ before(:each) do
+ described_class.setup_formula_has_bottle { |f| !f.some_random_method }
+ end
+
+ it { is_expected.not_to pour_bottle }
+ end
+ end
+
+ describe "#setup_pour_formula_bottle" do
+ before(:each) do
+ described_class.setup_formula_has_bottle { true }
+ described_class.setup_pour_formula_bottle(&:some_random_method)
+ end
+
+ it "does not raise an error" do
+ expect { subject.pour }.not_to raise_error
+ end
+ end
+end
diff --git a/Library/Homebrew/test/bottle_hooks_test.rb b/Library/Homebrew/test/bottle_hooks_test.rb
deleted file mode 100644
index fd890192f..000000000
--- a/Library/Homebrew/test/bottle_hooks_test.rb
+++ /dev/null
@@ -1,49 +0,0 @@
-require "testing_env"
-require "formula_installer"
-require "hooks/bottles"
-
-class BottleHookTests < Homebrew::TestCase
- class FormulaDouble
- def bottle; end
- def local_bottle_path; end
-
- def bottle_disabled?
- false
- end
-
- def some_random_method
- true
- end
- end
-
- def setup
- super
- @fi = FormulaInstaller.new FormulaDouble.new
- end
-
- def test_has_bottle
- Homebrew::Hooks::Bottles.setup_formula_has_bottle(&:some_random_method)
- assert_predicate @fi, :pour_bottle?
- end
-
- def test_has_no_bottle
- Homebrew::Hooks::Bottles.setup_formula_has_bottle do |f|
- !f.some_random_method
- end
- refute_predicate @fi, :pour_bottle?
- end
-
- def test_pour_formula_bottle
- Homebrew::Hooks::Bottles.setup_formula_has_bottle do |_f|
- true
- end
-
- Homebrew::Hooks::Bottles.setup_pour_formula_bottle(&:some_random_method)
- @fi.pour
- end
-
- def teardown
- Homebrew::Hooks::Bottles.reset_hooks
- super
- end
-end