diff --git a/Library/Homebrew/.rubocop.yml b/Library/Homebrew/.rubocop.yml index 58b911ca9f..267641f022 100644 --- a/Library/Homebrew/.rubocop.yml +++ b/Library/Homebrew/.rubocop.yml @@ -88,3 +88,7 @@ Style/HashSyntax: # so many of these in formulae but none in here Style/TrailingBodyOnMethodDefinition: Enabled: true + +Rspec/ExpectActual: + Exclude: + - 'test/missing_formula_spec.rb' diff --git a/Library/Homebrew/cmd/info.rb b/Library/Homebrew/cmd/info.rb index a0e1cd4756..cfe8b13d87 100644 --- a/Library/Homebrew/cmd/info.rb +++ b/Library/Homebrew/cmd/info.rb @@ -60,7 +60,7 @@ module Homebrew rescue FormulaUnavailableError => e ofail e.message # No formula with this name, try a missing formula lookup - if (reason = Homebrew::MissingFormula.reason(f)) + if (reason = MissingFormula.reason(f)) $stderr.puts reason end end diff --git a/Library/Homebrew/cmd/install.rb b/Library/Homebrew/cmd/install.rb index 8fce1d60a6..21ea88193a 100644 --- a/Library/Homebrew/cmd/install.rb +++ b/Library/Homebrew/cmd/install.rb @@ -257,7 +257,7 @@ module Homebrew end ofail e.message - if (reason = Homebrew::MissingFormula.reason(e.name)) + if (reason = MissingFormula.reason(e.name)) $stderr.puts reason return end diff --git a/Library/Homebrew/cmd/search.rb b/Library/Homebrew/cmd/search.rb index c61f4576a1..0f01afa46f 100644 --- a/Library/Homebrew/cmd/search.rb +++ b/Library/Homebrew/cmd/search.rb @@ -64,7 +64,7 @@ module Homebrew count = local_results.length + tap_results.length ohai "Searching blacklisted, migrated and deleted formulae..." - if reason = Homebrew::MissingFormula.reason(query, silent: true) + if reason = MissingFormula.reason(query, silent: true) if count.positive? puts puts "If you meant #{query.inspect} specifically:" diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb index ddd07a0ecd..3fe5a80d01 100644 --- a/Library/Homebrew/dev-cmd/audit.rb +++ b/Library/Homebrew/dev-cmd/audit.rb @@ -308,7 +308,7 @@ class FormulaAuditor name = formula.name - if Homebrew::MissingFormula.blacklisted_reason(name) + if MissingFormula.blacklisted_reason(name) problem "'#{name}' is blacklisted." end diff --git a/Library/Homebrew/dev-cmd/create.rb b/Library/Homebrew/dev-cmd/create.rb index a992e5706c..d9905a39da 100644 --- a/Library/Homebrew/dev-cmd/create.rb +++ b/Library/Homebrew/dev-cmd/create.rb @@ -65,7 +65,7 @@ module Homebrew # Don't allow blacklisted formula, or names that shadow aliases, # unless --force is specified. unless ARGV.force? - if reason = Homebrew::MissingFormula.blacklisted_reason(fc.name) + if reason = MissingFormula.blacklisted_reason(fc.name) raise "#{fc.name} is blacklisted for creation.\n#{reason}\nIf you really want to create this formula use --force." end diff --git a/Library/Homebrew/test/missing_formula_spec.rb b/Library/Homebrew/test/missing_formula_spec.rb index a9d0083d09..56c4ad2c3c 100644 --- a/Library/Homebrew/test/missing_formula_spec.rb +++ b/Library/Homebrew/test/missing_formula_spec.rb @@ -1,117 +1,77 @@ require "missing_formula" describe Homebrew::MissingFormula do - context "::reason" do + describe "::reason" do subject { described_class.reason("gem") } it { is_expected.not_to be_nil } end - context "::blacklisted_reason" do - matcher(:be_blacklisted) do + describe "::blacklisted_reason" do + matcher :be_blacklisted do match do |expected| described_class.blacklisted_reason(expected) end end - context "rubygems" do - %w[gem rubygem rubygems].each do |s| - subject { s } - - it { is_expected.to be_blacklisted } - end + specify "RubyGems is blacklisted" do + expect(%w[gem rubygem rubygems]).to all be_blacklisted end - context "latex" do - %w[latex tex tex-live texlive TexLive].each do |s| - subject { s } - - it { is_expected.to be_blacklisted } - end + specify "LaTeX is blacklisted" do + expect(%w[latex tex tex-live texlive TexLive]).to all be_blacklisted end - context "pip" do - subject { "pip" } - - it { is_expected.to be_blacklisted } + specify "pip is blacklisted" do + expect("pip").to be_blacklisted end - context "pil" do - subject { "pil" } - - it { is_expected.to be_blacklisted } + specify "PIL is blacklisted" do + expect("pil").to be_blacklisted end - context "macruby" do - subject { "MacRuby" } - - it { is_expected.to be_blacklisted } + specify "MacRuby is blacklisted" do + expect("MacRuby").to be_blacklisted end - context "lzma" do - %w[lzma liblzma].each do |s| - subject { s } - - it { is_expected.to be_blacklisted } - end + specify "lzma is blacklisted" do + expect(%w[lzma liblzma]).to all be_blacklisted end - context "gtest" do - %w[gtest googletest google-test].each do |s| - subject { s } - - it { is_expected.to be_blacklisted } - end + specify "gtest is blacklisted" do + expect(%w[gtest googletest google-test]).to all be_blacklisted end - context "gmock" do - %w[gmock googlemock google-mock].each do |s| - subject { s } - - it { is_expected.to be_blacklisted } - end + specify "gmock is blacklisted" do + expect(%w[gmock googlemock google-mock]).to all be_blacklisted end - context "sshpass" do - subject { "sshpass" } - - it { is_expected.to be_blacklisted } + specify "sshpass is blacklisted" do + expect("sshpass").to be_blacklisted end - context "gsutil" do - subject { "gsutil" } - - it { is_expected.to be_blacklisted } + specify "gsutil is blacklisted" do + expect("gsutil").to be_blacklisted end - context "gfortran" do - subject { "gfortran" } - - it { is_expected.to be_blacklisted } + specify "gfortran is blacklisted" do + expect("gfortran").to be_blacklisted end - context "play" do - subject { "play" } - - it { is_expected.to be_blacklisted } + specify "play is blacklisted" do + expect("play").to be_blacklisted end - context "haskell-platform" do - subject { "haskell-platform" } - - it { is_expected.to be_blacklisted } + specify "haskell-platform is blacklisted" do + expect("haskell-platform").to be_blacklisted end - context "xcode", :needs_macos do - %w[xcode Xcode].each do |s| - subject { s } - - it { is_expected.to be_blacklisted } - end + specify "Xcode is blacklisted", :needs_macos do + expect(%w[xcode Xcode]).to all be_blacklisted end end - context "::tap_migration_reason" do + describe "::tap_migration_reason" do subject { described_class.tap_migration_reason(formula) } before do @@ -136,7 +96,7 @@ describe Homebrew::MissingFormula do end end - context "::deleted_reason" do + describe "::deleted_reason" do subject { described_class.deleted_reason(formula, silent: true) } before do