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