Use scoped RSpec matchers.
This commit is contained in:
parent
ea8be174f6
commit
3cdf8f938a
@ -22,13 +22,13 @@ class BuildEnvironment
|
|||||||
def userpaths?
|
def userpaths?
|
||||||
@settings.include? :userpaths
|
@settings.include? :userpaths
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
module BuildEnvironmentDSL
|
module DSL
|
||||||
def env(*settings)
|
def env(*settings)
|
||||||
@env ||= BuildEnvironment.new
|
@env ||= BuildEnvironment.new
|
||||||
@env.merge(settings)
|
@env.merge(settings)
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
module Homebrew
|
module Homebrew
|
||||||
|
@ -1997,7 +1997,7 @@ class Formula
|
|||||||
|
|
||||||
# The methods below define the formula DSL.
|
# The methods below define the formula DSL.
|
||||||
class << self
|
class << self
|
||||||
include BuildEnvironmentDSL
|
include BuildEnvironment::DSL
|
||||||
|
|
||||||
# The reason for why this software is not linked (by default) to
|
# The reason for why this software is not linked (by default) to
|
||||||
# {::HOMEBREW_PREFIX}.
|
# {::HOMEBREW_PREFIX}.
|
||||||
|
@ -159,7 +159,7 @@ class Requirement
|
|||||||
end
|
end
|
||||||
|
|
||||||
class << self
|
class << self
|
||||||
include BuildEnvironmentDSL
|
include BuildEnvironment::DSL
|
||||||
|
|
||||||
attr_reader :env_proc, :build
|
attr_reader :env_proc, :build
|
||||||
attr_rw :fatal, :default_formula
|
attr_rw :fatal, :default_formula
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
require "open3"
|
require "open3"
|
||||||
|
|
||||||
RSpec::Matchers.define :have_valid_bash_syntax do
|
describe "Bash" do
|
||||||
|
matcher :have_valid_bash_syntax do
|
||||||
match do |file|
|
match do |file|
|
||||||
stdout, stderr, status = Open3.capture3("/bin/bash", "-n", file)
|
stdout, stderr, status = Open3.capture3("/bin/bash", "-n", file)
|
||||||
|
|
||||||
@ -12,9 +13,8 @@ RSpec::Matchers.define :have_valid_bash_syntax do
|
|||||||
failure_message do |(file, stderr)|
|
failure_message do |(file, stderr)|
|
||||||
"expected that #{file} is a valid Bash file:\n#{stderr}"
|
"expected that #{file} is a valid Bash file:\n#{stderr}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "Bash" do
|
|
||||||
context "brew" do
|
context "brew" do
|
||||||
subject { HOMEBREW_LIBRARY_PATH.parent.parent/"bin/brew" }
|
subject { HOMEBREW_LIBRARY_PATH.parent.parent/"bin/brew" }
|
||||||
it { is_expected.to have_valid_bash_syntax }
|
it { is_expected.to have_valid_bash_syntax }
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
require "formula_installer"
|
require "formula_installer"
|
||||||
require "hooks/bottles"
|
require "hooks/bottles"
|
||||||
|
|
||||||
RSpec::Matchers.alias_matcher :pour_bottle, :be_pour_bottle
|
|
||||||
|
|
||||||
describe Homebrew::Hooks::Bottles do
|
describe Homebrew::Hooks::Bottles do
|
||||||
|
alias_matcher :pour_bottle, :be_pour_bottle
|
||||||
|
|
||||||
subject { FormulaInstaller.new formula }
|
subject { FormulaInstaller.new formula }
|
||||||
|
|
||||||
let(:formula) do
|
let(:formula) do
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
require "build_environment"
|
require "build_environment"
|
||||||
|
|
||||||
RSpec::Matchers.alias_matcher :use_userpaths, :be_userpaths
|
|
||||||
|
|
||||||
describe BuildEnvironment do
|
describe BuildEnvironment do
|
||||||
|
alias_matcher :use_userpaths, :be_userpaths
|
||||||
|
|
||||||
let(:env) { described_class.new }
|
let(:env) { described_class.new }
|
||||||
|
|
||||||
describe "#<<" do
|
describe "#<<" do
|
||||||
@ -38,9 +38,8 @@ describe BuildEnvironment do
|
|||||||
expect(env).not_to use_userpaths
|
expect(env).not_to use_userpaths
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
describe BuildEnvironmentDSL do
|
describe BuildEnvironment::DSL do
|
||||||
subject { double.extend(described_class) }
|
subject { double.extend(described_class) }
|
||||||
|
|
||||||
context "single argument" do
|
context "single argument" do
|
||||||
@ -63,4 +62,5 @@ describe BuildEnvironmentDSL do
|
|||||||
its(:env) { is_expected.to be_std }
|
its(:env) { is_expected.to be_std }
|
||||||
its(:env) { is_expected.to use_userpaths }
|
its(:env) { is_expected.to use_userpaths }
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
require "build_options"
|
require "build_options"
|
||||||
require "options"
|
require "options"
|
||||||
|
|
||||||
RSpec::Matchers.alias_matcher :be_built_with, :be_with
|
|
||||||
RSpec::Matchers.alias_matcher :be_built_without, :be_without
|
|
||||||
|
|
||||||
describe BuildOptions do
|
describe BuildOptions do
|
||||||
|
alias_matcher :be_built_with, :be_with
|
||||||
|
alias_matcher :be_built_without, :be_without
|
||||||
|
|
||||||
subject { described_class.new(args, opts) }
|
subject { described_class.new(args, opts) }
|
||||||
let(:bad_build) { described_class.new(bad_args, opts) }
|
let(:bad_build) { described_class.new(bad_args, opts) }
|
||||||
let(:args) { Options.create(%w[--with-foo --with-bar --without-qux]) }
|
let(:args) { Options.create(%w[--with-foo --with-bar --without-qux]) }
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
require "compilers"
|
require "compilers"
|
||||||
|
|
||||||
RSpec::Matchers.alias_matcher :fail_with, :be_fails_with
|
|
||||||
|
|
||||||
describe CompilerFailure do
|
describe CompilerFailure do
|
||||||
|
alias_matcher :fail_with, :be_fails_with
|
||||||
|
|
||||||
describe "::create" do
|
describe "::create" do
|
||||||
it "creates a failure when given a symbol" do
|
it "creates a failure when given a symbol" do
|
||||||
failure = described_class.create(:clang)
|
failure = described_class.create(:clang)
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
require "dependable"
|
require "dependable"
|
||||||
|
|
||||||
RSpec::Matchers.alias_matcher :be_a_build_dependency, :be_build
|
|
||||||
|
|
||||||
describe Dependable do
|
describe Dependable do
|
||||||
|
alias_matcher :be_a_build_dependency, :be_build
|
||||||
|
|
||||||
subject { double(tags: tags).extend(described_class) }
|
subject { double(tags: tags).extend(described_class) }
|
||||||
let(:tags) { ["foo", "bar", :build] }
|
let(:tags) { ["foo", "bar", :build] }
|
||||||
|
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
require "dependency_collector"
|
require "dependency_collector"
|
||||||
|
|
||||||
RSpec::Matchers.alias_matcher :be_a_build_requirement, :be_build
|
|
||||||
|
|
||||||
describe DependencyCollector do
|
describe DependencyCollector do
|
||||||
|
alias_matcher :be_a_build_requirement, :be_build
|
||||||
|
|
||||||
def find_dependency(name)
|
def find_dependency(name)
|
||||||
subject.deps.find { |dep| dep.name == name }
|
subject.deps.find { |dep| dep.name == name }
|
||||||
end
|
end
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
require "dependency"
|
require "dependency"
|
||||||
|
|
||||||
RSpec::Matchers.alias_matcher :be_a_build_dependency, :be_build
|
|
||||||
RSpec::Matchers.alias_matcher :be_a_runtime_dependency, :be_run
|
|
||||||
|
|
||||||
describe Dependency do
|
describe Dependency do
|
||||||
|
alias_matcher :be_a_build_dependency, :be_build
|
||||||
|
alias_matcher :be_a_runtime_dependency, :be_run
|
||||||
|
|
||||||
describe "::new" do
|
describe "::new" do
|
||||||
it "accepts a single tag" do
|
it "accepts a single tag" do
|
||||||
dep = described_class.new("foo", %w[bar])
|
dep = described_class.new("foo", %w[bar])
|
||||||
|
@ -1,10 +1,6 @@
|
|||||||
require "dev-cmd/audit"
|
require "dev-cmd/audit"
|
||||||
require "formulary"
|
require "formulary"
|
||||||
|
|
||||||
RSpec::Matchers.alias_matcher :have_data, :be_data
|
|
||||||
RSpec::Matchers.alias_matcher :have_end, :be_end
|
|
||||||
RSpec::Matchers.alias_matcher :have_trailing_newline, :be_trailing_newline
|
|
||||||
|
|
||||||
module Count
|
module Count
|
||||||
def self.increment
|
def self.increment
|
||||||
@count ||= 0
|
@count ||= 0
|
||||||
@ -13,6 +9,10 @@ module Count
|
|||||||
end
|
end
|
||||||
|
|
||||||
describe FormulaText do
|
describe FormulaText do
|
||||||
|
alias_matcher :have_data, :be_data
|
||||||
|
alias_matcher :have_end, :be_end
|
||||||
|
alias_matcher :have_trailing_newline, :be_trailing_newline
|
||||||
|
|
||||||
let(:dir) { mktmpdir }
|
let(:dir) { mktmpdir }
|
||||||
|
|
||||||
def formula_text(name, body = nil, options = {})
|
def formula_text(name, body = nil, options = {})
|
||||||
|
@ -5,9 +5,9 @@ require "tab"
|
|||||||
require "test/support/fixtures/testball"
|
require "test/support/fixtures/testball"
|
||||||
require "test/support/fixtures/testball_bottle"
|
require "test/support/fixtures/testball_bottle"
|
||||||
|
|
||||||
RSpec::Matchers.alias_matcher :pour_bottle, :be_pour_bottle
|
|
||||||
|
|
||||||
describe FormulaInstaller do
|
describe FormulaInstaller do
|
||||||
|
alias_matcher :pour_bottle, :be_pour_bottle
|
||||||
|
|
||||||
matcher :be_poured_from_bottle do
|
matcher :be_poured_from_bottle do
|
||||||
match(&:poured_from_bottle)
|
match(&:poured_from_bottle)
|
||||||
end
|
end
|
||||||
|
@ -5,10 +5,10 @@ require "tab"
|
|||||||
require "test/support/fixtures/testball"
|
require "test/support/fixtures/testball"
|
||||||
require "test/support/fixtures/testball_bottle"
|
require "test/support/fixtures/testball_bottle"
|
||||||
|
|
||||||
RSpec::Matchers.define_negated_matcher :need_bottle, :be_bottle_unneeded
|
|
||||||
RSpec::Matchers.alias_matcher :have_disabled_bottle, :be_bottle_disabled
|
|
||||||
|
|
||||||
describe FormulaInstaller do
|
describe FormulaInstaller do
|
||||||
|
define_negated_matcher :need_bottle, :be_bottle_unneeded
|
||||||
|
alias_matcher :have_disabled_bottle, :be_bottle_disabled
|
||||||
|
|
||||||
matcher :be_poured_from_bottle do
|
matcher :be_poured_from_bottle do
|
||||||
match(&:poured_from_bottle)
|
match(&:poured_from_bottle)
|
||||||
end
|
end
|
||||||
|
@ -1,19 +1,19 @@
|
|||||||
require "test/support/fixtures/testball"
|
require "test/support/fixtures/testball"
|
||||||
require "formula"
|
require "formula"
|
||||||
|
|
||||||
RSpec::Matchers.alias_matcher :follow_installed_alias, :be_follow_installed_alias
|
|
||||||
RSpec::Matchers.alias_matcher :have_any_version_installed, :be_any_version_installed
|
|
||||||
RSpec::Matchers.alias_matcher :need_migration, :be_migration_needed
|
|
||||||
|
|
||||||
RSpec::Matchers.alias_matcher :have_changed_installed_alias_target, :be_installed_alias_target_changed
|
|
||||||
RSpec::Matchers.alias_matcher :supersede_an_installed_formula, :be_supersedes_an_installed_formula
|
|
||||||
RSpec::Matchers.alias_matcher :have_changed_alias, :be_alias_changed
|
|
||||||
|
|
||||||
RSpec::Matchers.alias_matcher :have_option_defined, :be_option_defined
|
|
||||||
RSpec::Matchers.alias_matcher :have_test_defined, :be_test_defined
|
|
||||||
RSpec::Matchers.alias_matcher :pour_bottle, :be_pour_bottle
|
|
||||||
|
|
||||||
describe Formula do
|
describe Formula do
|
||||||
|
alias_matcher :follow_installed_alias, :be_follow_installed_alias
|
||||||
|
alias_matcher :have_any_version_installed, :be_any_version_installed
|
||||||
|
alias_matcher :need_migration, :be_migration_needed
|
||||||
|
|
||||||
|
alias_matcher :have_changed_installed_alias_target, :be_installed_alias_target_changed
|
||||||
|
alias_matcher :supersede_an_installed_formula, :be_supersedes_an_installed_formula
|
||||||
|
alias_matcher :have_changed_alias, :be_alias_changed
|
||||||
|
|
||||||
|
alias_matcher :have_option_defined, :be_option_defined
|
||||||
|
alias_matcher :have_test_defined, :be_test_defined
|
||||||
|
alias_matcher :pour_bottle, :be_pour_bottle
|
||||||
|
|
||||||
describe "::new" do
|
describe "::new" do
|
||||||
let(:klass) do
|
let(:klass) do
|
||||||
Class.new(described_class) do
|
Class.new(described_class) do
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
require "dependency_collector"
|
require "dependency_collector"
|
||||||
|
|
||||||
RSpec::Matchers.alias_matcher :need_tar_xz_dependency, :be_tar_needs_xz_dependency
|
|
||||||
|
|
||||||
describe DependencyCollector do
|
describe DependencyCollector do
|
||||||
|
alias_matcher :need_tar_xz_dependency, :be_tar_needs_xz_dependency
|
||||||
|
|
||||||
after(:each) do
|
after(:each) do
|
||||||
described_class.clear_cache
|
described_class.clear_cache
|
||||||
end
|
end
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
require "extend/ENV"
|
require "extend/ENV"
|
||||||
require "requirement"
|
require "requirement"
|
||||||
|
|
||||||
RSpec::Matchers.alias_matcher :have_a_default_formula, :be_a_default_formula
|
|
||||||
RSpec::Matchers.alias_matcher :be_a_build_requirement, :be_a_build
|
|
||||||
|
|
||||||
describe Requirement do
|
describe Requirement do
|
||||||
|
alias_matcher :have_a_default_formula, :be_a_default_formula
|
||||||
|
alias_matcher :be_a_build_requirement, :be_a_build
|
||||||
|
|
||||||
subject { klass.new }
|
subject { klass.new }
|
||||||
|
|
||||||
let(:klass) { Class.new(described_class) }
|
let(:klass) { Class.new(described_class) }
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
require "sandbox"
|
require "sandbox"
|
||||||
|
|
||||||
RSpec::Matchers.define_negated_matcher :not_matching, :matching
|
|
||||||
|
|
||||||
describe Sandbox do
|
describe Sandbox do
|
||||||
|
define_negated_matcher :not_matching, :matching
|
||||||
|
|
||||||
let(:dir) { mktmpdir }
|
let(:dir) { mktmpdir }
|
||||||
let(:file) { dir/"foo" }
|
let(:file) { dir/"foo" }
|
||||||
|
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
require "software_spec"
|
require "software_spec"
|
||||||
|
|
||||||
RSpec::Matchers.alias_matcher :have_defined_resource, :be_resource_defined
|
|
||||||
RSpec::Matchers.alias_matcher :have_defined_option, :be_option_defined
|
|
||||||
|
|
||||||
describe SoftwareSpec do
|
describe SoftwareSpec do
|
||||||
|
alias_matcher :have_defined_resource, :be_resource_defined
|
||||||
|
alias_matcher :have_defined_option, :be_option_defined
|
||||||
|
|
||||||
let(:owner) { double(name: "some_name", full_name: "some_name", tap: "homebrew/core") }
|
let(:owner) { double(name: "some_name", full_name: "some_name", tap: "homebrew/core") }
|
||||||
|
|
||||||
describe "#resource" do
|
describe "#resource" do
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
require "tab"
|
require "tab"
|
||||||
require "formula"
|
require "formula"
|
||||||
|
|
||||||
RSpec::Matchers.alias_matcher :be_built_with, :be_with
|
|
||||||
|
|
||||||
describe Tab do
|
describe Tab do
|
||||||
|
alias_matcher :be_built_with, :be_with
|
||||||
|
|
||||||
matcher :be_poured_from_bottle do
|
matcher :be_poured_from_bottle do
|
||||||
match do |actual|
|
match do |actual|
|
||||||
actual.poured_from_bottle == true
|
actual.poured_from_bottle == true
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
RSpec::Matchers.alias_matcher :have_formula_file, :be_formula_file
|
|
||||||
RSpec::Matchers.alias_matcher :have_custom_remote, :be_custom_remote
|
|
||||||
|
|
||||||
describe Tap do
|
describe Tap do
|
||||||
include FileUtils
|
include FileUtils
|
||||||
|
|
||||||
|
alias_matcher :have_formula_file, :be_formula_file
|
||||||
|
alias_matcher :have_custom_remote, :be_custom_remote
|
||||||
|
|
||||||
subject { described_class.new("Homebrew", "foo") }
|
subject { described_class.new("Homebrew", "foo") }
|
||||||
let(:path) { Tap::TAP_DIRECTORY/"homebrew/homebrew-foo" }
|
let(:path) { Tap::TAP_DIRECTORY/"homebrew/homebrew-foo" }
|
||||||
let(:formula_file) { path/"Formula/foo.rb" }
|
let(:formula_file) { path/"Formula/foo.rb" }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user