Merge pull request #1330 from reitermarkus/spec-helper
Refactor `spec_helper`.
This commit is contained in:
commit
2b049006fa
@ -1,2 +0,0 @@
|
||||
--color
|
||||
--require spec_helper
|
||||
@ -25,6 +25,8 @@ repo_root.cd do
|
||||
|
||||
if rspec
|
||||
run_tests "parallel_rspec", Dir["spec/**/*_spec.rb"], %w[
|
||||
--color
|
||||
--require spec_helper
|
||||
--format progress
|
||||
--format ParallelTests::RSpec::RuntimeLogger
|
||||
--out tmp/parallel_runtime_rspec.log
|
||||
|
||||
@ -1,5 +1,3 @@
|
||||
require "spec_helper"
|
||||
|
||||
describe Hbc::Artifact::Binary do
|
||||
let(:cask) {
|
||||
Hbc.load("with-binary").tap do |cask|
|
||||
|
||||
@ -1,5 +1,3 @@
|
||||
require "spec_helper"
|
||||
|
||||
describe Hbc::Audit do
|
||||
include AuditMatchers
|
||||
include Sha256Helper
|
||||
@ -296,8 +294,8 @@ describe Hbc::Audit do
|
||||
|
||||
context "when download and verification succeed" do
|
||||
before do
|
||||
download.expects(:perform)
|
||||
verify.expects(:all)
|
||||
expect(download).to receive(:perform)
|
||||
expect(verify).to receive(:all)
|
||||
end
|
||||
|
||||
it { should_not fail_with(%r{#{error_msg}}) }
|
||||
@ -305,7 +303,7 @@ describe Hbc::Audit do
|
||||
|
||||
context "when download fails" do
|
||||
before do
|
||||
download.expects(:perform).raises(StandardError.new(error_msg))
|
||||
expect(download).to receive(:perform).and_raise(StandardError.new(error_msg))
|
||||
end
|
||||
|
||||
it { is_expected.to fail_with(%r{#{error_msg}}) }
|
||||
@ -313,8 +311,8 @@ describe Hbc::Audit do
|
||||
|
||||
context "when verification fails" do
|
||||
before do
|
||||
download.expects(:perform)
|
||||
verify.expects(:all).raises(StandardError.new(error_msg))
|
||||
expect(download).to receive(:perform)
|
||||
expect(verify).to receive(:all).and_raise(StandardError.new(error_msg))
|
||||
end
|
||||
|
||||
it { is_expected.to fail_with(%r{#{error_msg}}) }
|
||||
@ -324,7 +322,7 @@ describe Hbc::Audit do
|
||||
context "when an exception is raised" do
|
||||
let(:cask) { instance_double(Hbc::Cask) }
|
||||
before do
|
||||
cask.expects(:version).raises(StandardError.new)
|
||||
expect(cask).to receive(:version).and_raise(StandardError.new)
|
||||
end
|
||||
|
||||
it { is_expected.to fail_with(%r{exception while auditing}) }
|
||||
|
||||
@ -1,5 +1,3 @@
|
||||
require "spec_helper"
|
||||
|
||||
describe Hbc::Cask do
|
||||
let(:cask) { described_class.new("versioned-cask") }
|
||||
|
||||
|
||||
@ -1,5 +1,3 @@
|
||||
require "spec_helper"
|
||||
|
||||
describe Hbc::CLI::Cleanup do
|
||||
let(:cache_location) { Pathname.new(Dir.mktmpdir).realpath }
|
||||
let(:cleanup_outdated) { false }
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
require "spec_helper"
|
||||
require "hbc/version"
|
||||
|
||||
describe Hbc::CLI::Doctor do
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
require "English"
|
||||
require "spec_helper"
|
||||
|
||||
describe Hbc::CLI::Style do
|
||||
let(:args) { [] }
|
||||
|
||||
@ -1,5 +1,3 @@
|
||||
require "spec_helper"
|
||||
|
||||
describe Hbc::CLI do
|
||||
it "lists the taps for Casks that show up in two taps" do
|
||||
listing = Hbc::CLI.nice_listing(%w[
|
||||
|
||||
@ -1,5 +1,3 @@
|
||||
require "spec_helper"
|
||||
|
||||
describe "download strategies" do
|
||||
let(:url) { "http://example.com/cask.dmg" }
|
||||
let(:url_options) { Hash.new }
|
||||
|
||||
@ -1,5 +1,3 @@
|
||||
require "spec_helper"
|
||||
|
||||
describe Hbc::DSL::Version do
|
||||
include ExpectationsHashHelper
|
||||
|
||||
|
||||
@ -1,5 +1,3 @@
|
||||
require "spec_helper"
|
||||
|
||||
describe MacOS do
|
||||
it "says '/' is undeletable" do
|
||||
expect(MacOS).to be_undeletable(
|
||||
|
||||
@ -1,5 +1,3 @@
|
||||
require "spec_helper"
|
||||
|
||||
describe Hbc::Scopes do
|
||||
describe "installed" do
|
||||
let(:fake_caskroom) { Pathname(Dir.mktmpdir) }
|
||||
|
||||
@ -1,5 +1,3 @@
|
||||
require "spec_helper"
|
||||
|
||||
describe Hbc::SystemCommand::Result do
|
||||
describe "::_parse_plist" do
|
||||
let(:command) { Hbc::SystemCommand.new("/usr/bin/true", {}) }
|
||||
|
||||
@ -1,5 +1,3 @@
|
||||
require "spec_helper"
|
||||
|
||||
describe Hbc::SystemCommand do
|
||||
describe "when the exit code is 0" do
|
||||
describe "its result" do
|
||||
|
||||
@ -1,5 +1,3 @@
|
||||
require "spec_helper"
|
||||
|
||||
describe Hbc::UnderscoreSupportingURI do
|
||||
describe "parse" do
|
||||
it "works like normal on normal URLs" do
|
||||
|
||||
@ -1,5 +1,3 @@
|
||||
require "spec_helper"
|
||||
|
||||
describe Hbc::Verify::Checksum do
|
||||
include Sha256Helper
|
||||
|
||||
|
||||
@ -1,5 +1,3 @@
|
||||
require "spec_helper"
|
||||
|
||||
describe Hbc::Verify do
|
||||
let(:cask) { double("cask") }
|
||||
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
require "spec_helper"
|
||||
require "utils/formatter"
|
||||
require "utils/tty"
|
||||
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
require "spec_helper"
|
||||
require "locale"
|
||||
|
||||
describe Locale do
|
||||
|
||||
@ -6,23 +6,19 @@ if ENV["HOMEBREW_TESTS_COVERAGE"]
|
||||
require "simplecov"
|
||||
end
|
||||
|
||||
project_root = Pathname.new(File.expand_path("../..", __FILE__))
|
||||
|
||||
# add Homebrew to load path
|
||||
$LOAD_PATH.unshift(File.expand_path("#{ENV["HOMEBREW_REPOSITORY"]}/Library/Homebrew"))
|
||||
$LOAD_PATH.unshift(File.expand_path("#{ENV["HOMEBREW_REPOSITORY"]}/Library/Homebrew/test/lib"))
|
||||
|
||||
require "global"
|
||||
|
||||
# add Homebrew-Cask to load path
|
||||
$LOAD_PATH.push(project_root.join("lib").to_s)
|
||||
$LOAD_PATH.push(HOMEBREW_LIBRARY_PATH.join("cask", "lib").to_s)
|
||||
|
||||
require "test/helper/env"
|
||||
require "test/helper/shutup"
|
||||
|
||||
Dir["#{project_root}/spec/support/*.rb"].each(&method(:require))
|
||||
|
||||
# from Homebrew. Provides expects method.
|
||||
require "mocha/api"
|
||||
Pathname.glob(HOMEBREW_LIBRARY_PATH.join("cask", "spec", "support", "*.rb")).each(&method(:require))
|
||||
|
||||
require "hbc"
|
||||
|
||||
@ -30,35 +26,15 @@ module Hbc
|
||||
class TestCask < Cask; end
|
||||
end
|
||||
|
||||
TEST_TMPDIR = Dir.mktmpdir("homebrew_cask_tests")
|
||||
at_exit do
|
||||
FileUtils.remove_entry(TEST_TMPDIR)
|
||||
end
|
||||
|
||||
# override Homebrew locations
|
||||
Hbc.homebrew_prefix = Pathname.new(TEST_TMPDIR).join("prefix")
|
||||
Hbc.homebrew_repository = Hbc.homebrew_prefix
|
||||
Hbc.binarydir = Hbc.homebrew_prefix.join("binarydir", "bin")
|
||||
Hbc.appdir = Pathname.new(TEST_TMPDIR).join("appdir")
|
||||
|
||||
# Override Tap::TAP_DIRECTORY to use our test Tap directory.
|
||||
class Tap
|
||||
send(:remove_const, :TAP_DIRECTORY)
|
||||
TAP_DIRECTORY = Hbc.homebrew_repository.join("Library", "Taps")
|
||||
end
|
||||
|
||||
Hbc.default_tap = Tap.fetch("caskroom", "speccasks")
|
||||
Hbc.default_tap.path.dirname.mkpath
|
||||
|
||||
# also jack in some test Casks
|
||||
FileUtils.ln_s project_root.join("spec", "support"), Tap::TAP_DIRECTORY.join("caskroom", "homebrew-speccasks")
|
||||
|
||||
# create cache directory
|
||||
Hbc.homebrew_cache = Pathname.new(TEST_TMPDIR).join("cache")
|
||||
# create and override default directories
|
||||
Hbc.appdir = Pathname.new(TEST_TMPDIR).join("Applications").tap(&:mkpath)
|
||||
Hbc.cache.mkpath
|
||||
Hbc.caskroom.mkpath
|
||||
Hbc.default_tap = Tap.fetch("caskroom", "spec").tap do |tap|
|
||||
tap.path.dirname.mkpath
|
||||
end
|
||||
|
||||
# our own testy caskroom
|
||||
Hbc.caskroom = Hbc.homebrew_prefix.join("TestCaskroom")
|
||||
FileUtils.ln_s Pathname.new(__FILE__).dirname.join("support"), Hbc.default_tap.path
|
||||
|
||||
RSpec.configure do |config|
|
||||
config.order = :random
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user