aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Reiter2017-05-09 23:00:51 +0200
committerMarkus Reiter2017-05-15 17:23:40 +0200
commit3cdf8f938a7cc31e366c49f8f5134a51bdcfdc7f (patch)
tree39b61acf2a35ef536677395d47f177d35037f431
parentea8be174f6009bc9bdec67b13ca501b5b83fc4b8 (diff)
downloadbrew-3cdf8f938a7cc31e366c49f8f5134a51bdcfdc7f.tar.bz2
Use scoped RSpec matchers.
-rw-r--r--Library/Homebrew/build_environment.rb10
-rw-r--r--Library/Homebrew/formula.rb2
-rw-r--r--Library/Homebrew/requirement.rb2
-rw-r--r--Library/Homebrew/test/bash_spec.rb20
-rw-r--r--Library/Homebrew/test/bottle_hooks_spec.rb4
-rw-r--r--Library/Homebrew/test/build_environment_spec.rb38
-rw-r--r--Library/Homebrew/test/build_options_spec.rb6
-rw-r--r--Library/Homebrew/test/compiler_failure_spec.rb4
-rw-r--r--Library/Homebrew/test/dependable_spec.rb4
-rw-r--r--Library/Homebrew/test/dependency_collector_spec.rb4
-rw-r--r--Library/Homebrew/test/dependency_spec.rb6
-rw-r--r--Library/Homebrew/test/dev-cmd/audit_spec.rb8
-rw-r--r--Library/Homebrew/test/formula_installer_bottle_spec.rb4
-rw-r--r--Library/Homebrew/test/formula_installer_spec.rb6
-rw-r--r--Library/Homebrew/test/formula_spec.rb20
-rw-r--r--Library/Homebrew/test/os/mac/dependency_collector_spec.rb4
-rw-r--r--Library/Homebrew/test/requirement_spec.rb6
-rw-r--r--Library/Homebrew/test/sandbox_spec.rb4
-rw-r--r--Library/Homebrew/test/software_spec_spec.rb6
-rw-r--r--Library/Homebrew/test/tab_spec.rb4
-rw-r--r--Library/Homebrew/test/tap_spec.rb6
21 files changed, 84 insertions, 84 deletions
diff --git a/Library/Homebrew/build_environment.rb b/Library/Homebrew/build_environment.rb
index e3299fb94..dc28b2293 100644
--- a/Library/Homebrew/build_environment.rb
+++ b/Library/Homebrew/build_environment.rb
@@ -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
diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb
index 1b3b718da..720f48439 100644
--- a/Library/Homebrew/formula.rb
+++ b/Library/Homebrew/formula.rb
@@ -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}.
diff --git a/Library/Homebrew/requirement.rb b/Library/Homebrew/requirement.rb
index 6c20e7917..cac8c6232 100644
--- a/Library/Homebrew/requirement.rb
+++ b/Library/Homebrew/requirement.rb
@@ -159,7 +159,7 @@ class Requirement
end
class << self
- include BuildEnvironmentDSL
+ include BuildEnvironment::DSL
attr_reader :env_proc, :build
attr_rw :fatal, :default_formula
diff --git a/Library/Homebrew/test/bash_spec.rb b/Library/Homebrew/test/bash_spec.rb
index 1b0f15066..552607810 100644
--- a/Library/Homebrew/test/bash_spec.rb
+++ b/Library/Homebrew/test/bash_spec.rb
@@ -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)
+describe "Bash" do
+ matcher :have_valid_bash_syntax do
+ match do |file|
+ stdout, stderr, status = Open3.capture3("/bin/bash", "-n", file)
- @actual = [file, stderr]
+ @actual = [file, stderr]
- stdout.empty? && status.success?
- end
+ stdout.empty? && status.success?
+ end
- failure_message do |(file, stderr)|
- "expected that #{file} is a valid Bash file:\n#{stderr}"
+ failure_message do |(file, stderr)|
+ "expected that #{file} is a valid Bash file:\n#{stderr}"
+ end
end
-end
-describe "Bash" do
context "brew" do
subject { HOMEBREW_LIBRARY_PATH.parent.parent/"bin/brew" }
it { is_expected.to have_valid_bash_syntax }
diff --git a/Library/Homebrew/test/bottle_hooks_spec.rb b/Library/Homebrew/test/bottle_hooks_spec.rb
index 05c6ea7f0..913e3ffba 100644
--- a/Library/Homebrew/test/bottle_hooks_spec.rb
+++ b/Library/Homebrew/test/bottle_hooks_spec.rb
@@ -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
diff --git a/Library/Homebrew/test/build_environment_spec.rb b/Library/Homebrew/test/build_environment_spec.rb
index 5a3cec452..58bec6d1f 100644
--- a/Library/Homebrew/test/build_environment_spec.rb
+++ b/Library/Homebrew/test/build_environment_spec.rb
@@ -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
- 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
diff --git a/Library/Homebrew/test/build_options_spec.rb b/Library/Homebrew/test/build_options_spec.rb
index 5acc12f30..1e6c9ea35 100644
--- a/Library/Homebrew/test/build_options_spec.rb
+++ b/Library/Homebrew/test/build_options_spec.rb
@@ -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]) }
diff --git a/Library/Homebrew/test/compiler_failure_spec.rb b/Library/Homebrew/test/compiler_failure_spec.rb
index b4fab0b27..47b35d3bc 100644
--- a/Library/Homebrew/test/compiler_failure_spec.rb
+++ b/Library/Homebrew/test/compiler_failure_spec.rb
@@ -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)
diff --git a/Library/Homebrew/test/dependable_spec.rb b/Library/Homebrew/test/dependable_spec.rb
index b646b7634..172305aa0 100644
--- a/Library/Homebrew/test/dependable_spec.rb
+++ b/Library/Homebrew/test/dependable_spec.rb
@@ -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] }
diff --git a/Library/Homebrew/test/dependency_collector_spec.rb b/Library/Homebrew/test/dependency_collector_spec.rb
index 82d117939..c25ea9cf9 100644
--- a/Library/Homebrew/test/dependency_collector_spec.rb
+++ b/Library/Homebrew/test/dependency_collector_spec.rb
@@ -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
diff --git a/Library/Homebrew/test/dependency_spec.rb b/Library/Homebrew/test/dependency_spec.rb
index 4af779cc3..4f1e8d474 100644
--- a/Library/Homebrew/test/dependency_spec.rb
+++ b/Library/Homebrew/test/dependency_spec.rb
@@ -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])
diff --git a/Library/Homebrew/test/dev-cmd/audit_spec.rb b/Library/Homebrew/test/dev-cmd/audit_spec.rb
index b07ffaadc..97cc0f152 100644
--- a/Library/Homebrew/test/dev-cmd/audit_spec.rb
+++ b/Library/Homebrew/test/dev-cmd/audit_spec.rb
@@ -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 = {})
diff --git a/Library/Homebrew/test/formula_installer_bottle_spec.rb b/Library/Homebrew/test/formula_installer_bottle_spec.rb
index 8409e1ac7..824cdb36d 100644
--- a/Library/Homebrew/test/formula_installer_bottle_spec.rb
+++ b/Library/Homebrew/test/formula_installer_bottle_spec.rb
@@ -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
diff --git a/Library/Homebrew/test/formula_installer_spec.rb b/Library/Homebrew/test/formula_installer_spec.rb
index efe2bf5a2..d309a17da 100644
--- a/Library/Homebrew/test/formula_installer_spec.rb
+++ b/Library/Homebrew/test/formula_installer_spec.rb
@@ -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
diff --git a/Library/Homebrew/test/formula_spec.rb b/Library/Homebrew/test/formula_spec.rb
index 1f98ca525..5991e72d8 100644
--- a/Library/Homebrew/test/formula_spec.rb
+++ b/Library/Homebrew/test/formula_spec.rb
@@ -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
+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
-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
+ 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
-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
+ alias_matcher :have_option_defined, :be_option_defined
+ alias_matcher :have_test_defined, :be_test_defined
+ alias_matcher :pour_bottle, :be_pour_bottle
-describe Formula do
describe "::new" do
let(:klass) do
Class.new(described_class) do
diff --git a/Library/Homebrew/test/os/mac/dependency_collector_spec.rb b/Library/Homebrew/test/os/mac/dependency_collector_spec.rb
index 21b15cd99..688149021 100644
--- a/Library/Homebrew/test/os/mac/dependency_collector_spec.rb
+++ b/Library/Homebrew/test/os/mac/dependency_collector_spec.rb
@@ -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
diff --git a/Library/Homebrew/test/requirement_spec.rb b/Library/Homebrew/test/requirement_spec.rb
index 959041cf4..71372aa69 100644
--- a/Library/Homebrew/test/requirement_spec.rb
+++ b/Library/Homebrew/test/requirement_spec.rb
@@ -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) }
diff --git a/Library/Homebrew/test/sandbox_spec.rb b/Library/Homebrew/test/sandbox_spec.rb
index 0d349f6eb..eafec4dd4 100644
--- a/Library/Homebrew/test/sandbox_spec.rb
+++ b/Library/Homebrew/test/sandbox_spec.rb
@@ -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" }
diff --git a/Library/Homebrew/test/software_spec_spec.rb b/Library/Homebrew/test/software_spec_spec.rb
index 5fd4f598a..e6eaeb204 100644
--- a/Library/Homebrew/test/software_spec_spec.rb
+++ b/Library/Homebrew/test/software_spec_spec.rb
@@ -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
diff --git a/Library/Homebrew/test/tab_spec.rb b/Library/Homebrew/test/tab_spec.rb
index 1b0836c93..93ae42ce4 100644
--- a/Library/Homebrew/test/tab_spec.rb
+++ b/Library/Homebrew/test/tab_spec.rb
@@ -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
diff --git a/Library/Homebrew/test/tap_spec.rb b/Library/Homebrew/test/tap_spec.rb
index 50e4522af..27b5e0c4b 100644
--- a/Library/Homebrew/test/tap_spec.rb
+++ b/Library/Homebrew/test/tap_spec.rb
@@ -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" }