Remove and refactor rspec-its use

This commit is contained in:
Douglas Eichelberger 2024-03-17 22:47:37 -07:00
parent bb753a6c48
commit 820d320835
19 changed files with 118 additions and 415 deletions

2
.gitignore vendored
View File

@ -111,12 +111,10 @@
**/vendor/bundle/ruby/*/gems/rspec-core-*/
**/vendor/bundle/ruby/*/gems/rspec-expectations-*/
**/vendor/bundle/ruby/*/gems/rspec_junit_formatter-*/
**/vendor/bundle/ruby/*/gems/rspec-its-*/
**/vendor/bundle/ruby/*/gems/rspec-mocks-*/
**/vendor/bundle/ruby/*/gems/rspec-retry-*/
**/vendor/bundle/ruby/*/gems/rspec-support-*/
**/vendor/bundle/ruby/*/gems/rspec-sorbet-*/
**/vendor/bundle/ruby/*/gems/rspec-wait-*/
**/vendor/bundle/ruby/*/gems/rubocop-*/
**/vendor/bundle/ruby/*/gems/ruby-prof-*/
**/vendor/bundle/ruby/*/gems/ruby-progressbar-*/

View File

@ -52,7 +52,6 @@ group :tests, optional: true do
gem "parallel_tests", require: false
gem "rspec", require: false
gem "rspec-github", require: false
gem "rspec-its", require: false
gem "rspec_junit_formatter", require: false
gem "rspec-retry", require: false
gem "rspec-sorbet", require: false

View File

@ -68,9 +68,6 @@ GEM
rspec-support (~> 3.13.0)
rspec-github (2.4.0)
rspec-core (~> 3.0)
rspec-its (1.3.0)
rspec-core (>= 3.0.0)
rspec-expectations (>= 3.0.0)
rspec-mocks (3.13.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.13.0)
@ -183,7 +180,6 @@ DEPENDENCIES
rexml
rspec
rspec-github
rspec-its
rspec-retry
rspec-sorbet
rspec_junit_formatter

View File

@ -6510,6 +6510,9 @@ module RSpec::Core::HashImitatable
# source://rspec-core//lib/rspec/core/metadata.rb#367
def reverse_each(*args, &block); end
# source://rspec-core//lib/rspec/core/metadata.rb#367
def save_plist(*args, &block); end
# source://rspec-core//lib/rspec/core/metadata.rb#367
def select(*args, &block); end
@ -6567,6 +6570,9 @@ module RSpec::Core::HashImitatable
# source://rspec-core//lib/rspec/core/metadata.rb#367
def to_msgpack(*args, &block); end
# source://rspec-core//lib/rspec/core/metadata.rb#367
def to_plist(*args, &block); end
# source://rspec-core//lib/rspec/core/metadata.rb#367
def to_proc(*args, &block); end

View File

@ -1,197 +0,0 @@
# typed: true
# DO NOT EDIT MANUALLY
# This is an autogenerated file for types exported from the `rspec-its` gem.
# Please instead update this file by running `bin/tapioca gem rspec-its`.
# source://rspec-its//lib/rspec/its/version.rb#1
module RSpec
class << self
# source://rspec-core/3.13.0/lib/rspec/core.rb#70
def clear_examples; end
# source://rspec-core/3.13.0/lib/rspec/core.rb#85
def configuration; end
# source://rspec-core/3.13.0/lib/rspec/core.rb#49
def configuration=(_arg0); end
# source://rspec-core/3.13.0/lib/rspec/core.rb#97
def configure; end
# source://rspec-core/3.13.0/lib/rspec/core.rb#194
def const_missing(name); end
# source://rspec-core/3.13.0/lib/rspec/core/dsl.rb#42
def context(*args, &example_group_block); end
# source://rspec-core/3.13.0/lib/rspec/core.rb#122
def current_example; end
# source://rspec-core/3.13.0/lib/rspec/core.rb#128
def current_example=(example); end
# source://rspec-core/3.13.0/lib/rspec/core.rb#154
def current_scope; end
# source://rspec-core/3.13.0/lib/rspec/core.rb#134
def current_scope=(scope); end
# source://rspec-core/3.13.0/lib/rspec/core/dsl.rb#42
def describe(*args, &example_group_block); end
# source://rspec-core/3.13.0/lib/rspec/core/dsl.rb#42
def example_group(*args, &example_group_block); end
# source://rspec-core/3.13.0/lib/rspec/core/dsl.rb#42
def fcontext(*args, &example_group_block); end
# source://rspec-core/3.13.0/lib/rspec/core/dsl.rb#42
def fdescribe(*args, &example_group_block); end
# source://rspec-core/3.13.0/lib/rspec/core.rb#58
def reset; end
# source://rspec-core/3.13.0/lib/rspec/core/shared_example_group.rb#110
def shared_context(name, *args, &block); end
# source://rspec-core/3.13.0/lib/rspec/core/shared_example_group.rb#110
def shared_examples(name, *args, &block); end
# source://rspec-core/3.13.0/lib/rspec/core/shared_example_group.rb#110
def shared_examples_for(name, *args, &block); end
# source://rspec-core/3.13.0/lib/rspec/core.rb#160
def world; end
# source://rspec-core/3.13.0/lib/rspec/core.rb#49
def world=(_arg0); end
# source://rspec-core/3.13.0/lib/rspec/core/dsl.rb#42
def xcontext(*args, &example_group_block); end
# source://rspec-core/3.13.0/lib/rspec/core/dsl.rb#42
def xdescribe(*args, &example_group_block); end
end
end
module RSpec::Core::SharedContext
include ::RSpec::Its
end
# source://rspec-its//lib/rspec/its/version.rb#2
module RSpec::Its
# Creates a nested example group named by the submitted `attribute`,
# and then generates an example using the submitted block.
#
# The attribute can be a `Symbol` or a `String`. Given a `String`
# with dots, the result is as though you concatenated that `String`
# onto the subject in an expression.
#
# When the subject is a `Hash`, you can refer to the Hash keys by
# specifying a `Symbol` or `String` in an array.
#
# With an implicit subject, `is_expected` can be used as an alternative
# to `should` (e.g. for one-liner use). An `are_expected` alias is also
# supplied.
#
# With an implicit subject, `will` can be used as an alternative
# to `expect { subject.attribute }.to matcher` (e.g. for one-liner use).
#
# With an implicit subject, `will_not` can be used as an alternative
# to `expect { subject.attribute }.to_not matcher` (e.g. for one-liner use).
#
# You can pass more than one argument on the `its` block to add
# some metadata to the generated example
#
# Note that this method does not modify `subject` in any way, so if you
# refer to `subject` in `let` or `before` blocks, you're still
# referring to the outer subject.
#
# @example
#
# describe Person do
# subject { Person.new }
# before { subject.age = 25 }
# its(:age) { should eq(25) }
# end
# @example
#
# describe Person do
# subject do
# Person.new.tap do |person|
# person.phone_numbers << "555-1212"
# end
# end
#
# its("phone_numbers.first") { should eq("555-1212") }
# end
# @example
#
# describe "a configuration Hash" do
# subject do
# { :max_users => 3,
# 'admin' => :all_permissions.
# 'john_doe' => {:permissions => [:read, :write]}}
# end
#
# its([:max_users]) { should eq(3) }
# its(['admin']) { should eq(:all_permissions) }
# its(['john_doe', :permissions]) { should eq([:read, :write]) }
#
# # You can still access its regular methods this way:
# its(:keys) { should include(:max_users) }
# its(:count) { should eq(2) }
# end
# @example
#
# describe Array do
# its(:size) { is_expected.to eq(0) }
# end
# @example
#
# describe Array do
# its(:foo) { will raise_error(NoMethodError) }
# end
# @example
#
# describe Array do
# its(:size) { will_not raise_error }
# end
# @example
#
# # This ...
# describe Array do
# its(:size, :focus) { should eq(0) }
# end
#
# # ... generates the same runtime structure as this:
# describe Array do
# describe "size" do
# it "should eq(0)", :focus do
# subject.size.should eq(0)
# end
# end
# end
# @example
#
# # This ...
# describe Array do
# its(:size) { should eq(0) }
# end
#
# # ... generates the same runtime structure as this:
# describe Array do
# describe "size" do
# it "should eq(0)" do
# subject.size.should eq(0)
# end
# end
# end
#
# source://rspec-its//lib/rspec/its.rb#121
def its(attribute, *options, &block); end
end
# source://rspec-its//lib/rspec/its/version.rb#3
RSpec::Its::VERSION = T.let(T.unsafe(nil), String)

View File

@ -4,46 +4,6 @@
# This is an autogenerated file for types exported from the `rubocop` gem.
# Please instead update this file by running `bin/tapioca gem rubocop`.
# This module provides methods that make it easier to test Cops.
#
# source://rubocop//lib/rubocop/rspec/cop_helper.rb#6
module CopHelper
extend ::RSpec::Its
extend ::RSpec::Core::SharedContext
# source://rubocop//lib/rubocop/rspec/cop_helper.rb#77
def _investigate(cop, processed_source); end
# source://rubocop//lib/rubocop/rspec/cop_helper.rb#67
def autocorrect_source(source, file = T.unsafe(nil)); end
# source://rubocop//lib/rubocop/rspec/cop_helper.rb#63
def autocorrect_source_file(source); end
# source://rubocop//lib/rubocop/rspec/cop_helper.rb#43
def configuration; end
# source://rubocop//lib/rubocop/rspec/cop_helper.rb#16
def inspect_source(source, file = T.unsafe(nil)); end
# source://rubocop//lib/rubocop/rspec/cop_helper.rb#28
def parse_source(source, file = T.unsafe(nil)); end
# source://rubocop//lib/rubocop/rspec/cop_helper.rb#51
def registry; end
end
# RuboCop can be run in contexts where unexpected other libraries are included,
# which may interfere with its normal behavior. In order to test those
# situations, it may be necessary to require another library for the duration
# of one spec
#
# source://rubocop//lib/rubocop/rspec/host_environment_simulation_helper.rb#7
module HostEnvironmentSimulatorHelper
# source://rubocop//lib/rubocop/rspec/host_environment_simulation_helper.rb#8
def in_its_own_process_with(*files); end
end
class Parser::Source::Comment
include ::RuboCop::Ext::Comment
end
@ -4906,12 +4866,6 @@ class RuboCop::Cop::Cop < ::RuboCop::Cop::Base
# source://rubocop//lib/rubocop/cop/cop.rb#70
def find_location(node, loc); end
# source://rubocop//lib/rubocop/rspec/cop_helper.rb#94
def highlights; end
# source://rubocop//lib/rubocop/rspec/cop_helper.rb#90
def messages; end
# Returns the value of attribute offenses.
#
# source://rubocop//lib/rubocop/cop/cop.rb#12
@ -55230,10 +55184,10 @@ RuboCop::Formatter::PacmanFormatter::FALLBACK_TERMINAL_WIDTH = T.let(T.unsafe(ni
RuboCop::Formatter::PacmanFormatter::GHOST = T.let(T.unsafe(nil), String)
# source://rubocop//lib/rubocop/formatter/pacman_formatter.rb#17
RuboCop::Formatter::PacmanFormatter::PACDOT = T.let(T.unsafe(nil), Rainbow::NullPresenter)
RuboCop::Formatter::PacmanFormatter::PACDOT = T.let(T.unsafe(nil), Rainbow::Presenter)
# source://rubocop//lib/rubocop/formatter/pacman_formatter.rb#16
RuboCop::Formatter::PacmanFormatter::PACMAN = T.let(T.unsafe(nil), Rainbow::NullPresenter)
RuboCop::Formatter::PacmanFormatter::PACMAN = T.let(T.unsafe(nil), Rainbow::Presenter)
# This formatter display dots for files with no offenses and
# letters for files with problems in the them. In the end it
@ -56735,58 +56689,6 @@ RuboCop::RSpec::ExpectOffense::AnnotatedSource::ABBREV = T.let(T.unsafe(nil), St
# source://rubocop//lib/rubocop/rspec/expect_offense.rb#215
RuboCop::RSpec::ExpectOffense::AnnotatedSource::ANNOTATION_PATTERN = T.let(T.unsafe(nil), Regexp)
# RSpec formatter for use with running `rake spec` in parallel. This formatter
# removes much of the noise from RSpec so that only the important information
# will be surfaced by test-queue.
# It also adds metadata to the output in order to more easily find the text
# needed for outputting after the parallel run completes.
#
# source://rubocop//lib/rubocop/rspec/parallel_formatter.rb#13
class RuboCop::RSpec::ParallelFormatter < ::RSpec::Core::Formatters::BaseTextFormatter
# The BEGIN/END comments are used by `spec_runner.rake` to determine what
# output goes where in the final parallelized output, and should not be
# removed!
#
# source://rubocop//lib/rubocop/rspec/parallel_formatter.rb#22
def dump_failures(notification); end
# Don't show pending tests
#
# source://rubocop//lib/rubocop/rspec/parallel_formatter.rb#17
def dump_pending(*_arg0); end
# source://rubocop//lib/rubocop/rspec/parallel_formatter.rb#33
def dump_summary(summary); end
private
# source://rubocop//lib/rubocop/rspec/parallel_formatter.rb#53
def colorize_summary(summary); end
# source://rubocop//lib/rubocop/rspec/parallel_formatter.rb#40
def colorizer; end
# The BEGIN/END comments are used by `spec_runner.rake` to determine what
# output goes where in the final parallelized output, and should not be
# removed!
#
# source://rubocop//lib/rubocop/rspec/parallel_formatter.rb#66
def output_rerun_commands(summary); end
# The BEGIN/END comments are used by `spec_runner.rake` to determine what
# output goes where in the final parallelized output, and should not be
# removed!
#
# source://rubocop//lib/rubocop/rspec/parallel_formatter.rb#47
def output_summary(summary); end
# source://rubocop//lib/rubocop/rspec/parallel_formatter.rb#85
def pluralize(*args); end
# source://rubocop//lib/rubocop/rspec/parallel_formatter.rb#72
def totals(summary); end
end
# Common methods and behaviors for dealing with remote config files.
#
# @api private

View File

@ -7,7 +7,7 @@ dependency_require_map = {
}.freeze
additional_requires_map = {
"rubocop" => ["rubocop/rspec/support"],
"rubocop-rspec" => ["rubocop/rspec/expect_offense"],
}.freeze
# Freeze lockfile

View File

@ -4,7 +4,7 @@ require "formula"
require "software_spec"
RSpec.describe Bottle::Filename do
subject { described_class.new(name, version, tag, rebuild) }
subject(:filename) { described_class.new(name, version, tag, rebuild) }
let(:name) { "user/repo/foo" }
let(:version) { PkgVersion.new(Version.new("1.0"), 0) }
@ -12,42 +12,42 @@ RSpec.describe Bottle::Filename do
let(:rebuild) { 0 }
describe "#extname" do
its(:extname) { is_expected.to eq ".x86_64_linux.bottle.tar.gz" }
it(:extname) { expect(filename.extname).to eq ".x86_64_linux.bottle.tar.gz" }
context "when rebuild is 0" do
its(:extname) { is_expected.to eq ".x86_64_linux.bottle.tar.gz" }
it(:extname) { expect(filename.extname).to eq ".x86_64_linux.bottle.tar.gz" }
end
context "when rebuild is 1" do
let(:rebuild) { 1 }
its(:extname) { is_expected.to eq ".x86_64_linux.bottle.1.tar.gz" }
it(:extname) { expect(filename.extname).to eq ".x86_64_linux.bottle.1.tar.gz" }
end
end
describe "#to_s and #to_str" do
its(:to_s) { is_expected.to eq "foo--1.0.x86_64_linux.bottle.tar.gz" }
its(:to_str) { is_expected.to eq "foo--1.0.x86_64_linux.bottle.tar.gz" }
it(:to_s) { expect(filename.to_s).to eq "foo--1.0.x86_64_linux.bottle.tar.gz" }
it(:to_str) { expect(filename.to_str).to eq "foo--1.0.x86_64_linux.bottle.tar.gz" }
end
describe "#url_encode" do
its(:url_encode) { is_expected.to eq "foo-1.0.x86_64_linux.bottle.tar.gz" }
it(:url_encode) { expect(filename.url_encode).to eq "foo-1.0.x86_64_linux.bottle.tar.gz" }
end
describe "#github_packages" do
its(:github_packages) { is_expected.to eq "foo--1.0.x86_64_linux.bottle.tar.gz" }
it(:github_packages) { expect(filename.github_packages).to eq "foo--1.0.x86_64_linux.bottle.tar.gz" }
end
describe "#json" do
its(:json) { is_expected.to eq "foo--1.0.x86_64_linux.bottle.json" }
it(:json) { expect(filename.json).to eq "foo--1.0.x86_64_linux.bottle.json" }
context "when rebuild is 1" do
its(:json) { is_expected.to eq "foo--1.0.x86_64_linux.bottle.json" }
it(:json) { expect(filename.json).to eq "foo--1.0.x86_64_linux.bottle.json" }
end
end
describe "::create" do
subject { described_class.create(f, tag, rebuild) }
subject(:filename) { described_class.create(f, tag, rebuild) }
let(:f) do
formula do
@ -56,6 +56,6 @@ RSpec.describe Bottle::Filename do
end
end
its(:to_s) { is_expected.to eq "formula_name--1.0.x86_64_linux.bottle.tar.gz" }
it(:to_s) { expect(filename.to_s).to eq "formula_name--1.0.x86_64_linux.bottle.tar.gz" }
end
end

View File

@ -37,13 +37,13 @@ RSpec.describe BuildEnvironment do
end
context "with a single argument" do
subject do
subject(:build_env) do
Class.new(build_environment_dsl) do
env :std
end
end
its(:env) { is_expected.to be_std }
it(:env) { expect(build_env.env).to be_std }
end
end
end

View File

@ -835,7 +835,7 @@ module Homebrew
describe "#audit_deps" do
describe "a dependency on a macOS-provided keg-only formula" do
describe "which is allowlisted" do
subject { fa }
subject(:f_a) { fa }
let(:fa) do
formula_auditor "foo", <<~RUBY, new_formula: true
@ -863,11 +863,11 @@ module Homebrew
fa.audit_deps
end
its(:problems) { are_expected.to be_empty }
it(:problems) { expect(f_a.problems).to be_empty }
end
describe "which is not allowlisted", :needs_macos do
subject { fa }
subject(:f_a) { fa }
let(:fa) do
formula_auditor "foo", <<~RUBY, new_formula: true, core_tap: true
@ -895,8 +895,9 @@ module Homebrew
fa.audit_deps
end
its(:new_formula_problems) do
are_expected.to include(a_hash_including(message: a_string_matching(/is provided by macOS/)))
it(:new_formula_problems) do
expect(f_a.new_formula_problems)
.to include(a_hash_including(message: a_string_matching(/is provided by macOS/)))
end
end
end

View File

@ -30,7 +30,7 @@ RSpec.describe ErrorDuringExecution do
describe "#to_s" do
context "when only given a command and a status" do
its(:to_s) { is_expected.to eq "Failure while executing; `false` exited with 1." }
it(:to_s) { expect(error.to_s).to eq "Failure while executing; `false` exited with 1." }
end
context "when additionally given the output" do
@ -45,7 +45,7 @@ RSpec.describe ErrorDuringExecution do
allow($stdout).to receive(:tty?).and_return(true)
end
its(:to_s) do
it(:to_s) do
expect(error.to_s).to eq <<~EOS
Failure while executing; `false` exited with 1. Here's the output:
This still worked.
@ -57,7 +57,7 @@ RSpec.describe ErrorDuringExecution do
context "when command arguments contain special characters" do
let(:command) { ["env", "PATH=/bin", "cat", "with spaces"] }
its(:to_s) do
it(:to_s) do
expect(error.to_s)
.to eq 'Failure while executing; `env PATH=/bin cat with\ spaces` exited with 1.'
end

View File

@ -4,15 +4,15 @@ require "exceptions"
RSpec.describe "Exception" do
describe MultipleVersionsInstalledError do
subject do
subject(:error) do
described_class.new <<~EOS
foo has multiple installed versions
Run `brew uninstall --force foo` to remove all versions.
EOS
end
its(:to_s) do
is_expected.to eq <<~EOS
it(:to_s) do
expect(error.to_s).to eq <<~EOS
foo has multiple installed versions
Run `brew uninstall --force foo` to remove all versions.
EOS
@ -20,15 +20,15 @@ RSpec.describe "Exception" do
end
describe NoSuchKegError do
subject { described_class.new("foo") }
subject(:error) { described_class.new("foo") }
its(:to_s) { is_expected.to eq("No such keg: #{HOMEBREW_CELLAR}/foo") }
it(:to_s) { expect(error.to_s).to eq("No such keg: #{HOMEBREW_CELLAR}/foo") }
end
describe FormulaValidationError do
subject(:error) { described_class.new("foo", "sha257", "magic") }
its(:to_s) do
it(:to_s) do
expect(error.to_s).to eq(%q(invalid attribute for formula 'foo': sha257 ("magic")))
end
end
@ -38,7 +38,7 @@ RSpec.describe "Exception" do
let(:tap) { instance_double(Tap, user: "u", repo: "r", to_s: "u/r", installed?: false) }
its(:to_s) { is_expected.to match(%r{Please tap it and then try again: brew tap u/r}) }
it(:to_s) { expect(error.to_s).to match(%r{Please tap it and then try again: brew tap u/r}) }
end
describe FormulaUnavailableError do
@ -61,7 +61,7 @@ RSpec.describe "Exception" do
end
context "without a dependent" do
its(:to_s) { is_expected.to eq('No available formula with the name "foo".') }
it(:to_s) { expect(error.to_s).to eq('No available formula with the name "foo".') }
end
context "with a dependent" do
@ -69,18 +69,18 @@ RSpec.describe "Exception" do
error.dependent = "foobar"
end
its(:to_s) do
it(:to_s) do
expect(error.to_s).to eq('No available formula with the name "foo" (dependency of foobar).')
end
end
end
describe TapFormulaUnavailableError do
subject { described_class.new(tap, "foo") }
subject(:error) { described_class.new(tap, "foo") }
let(:tap) { instance_double(Tap, user: "u", repo: "r", to_s: "u/r", installed?: false) }
its(:to_s) { is_expected.to match(%r{Please tap it and then try again: brew tap u/r}) }
it(:to_s) { expect(error.to_s).to match(%r{Please tap it and then try again: brew tap u/r}) }
end
describe FormulaClassUnavailableError do
@ -100,7 +100,7 @@ RSpec.describe "Exception" do
context "when there are no classes" do
let(:list) { [] }
its(:to_s) do
it(:to_s) do
expect(error.to_s).to match(/Expected to find class Foo, but found no classes\./)
end
end
@ -108,7 +108,7 @@ RSpec.describe "Exception" do
context "when the class is not derived from Formula" do
let(:list) { [mod.const_get(:Bar)] }
its(:to_s) do
it(:to_s) do
expect(error.to_s).to match(/Expected to find class Foo, but only found: Bar \(not derived from Formula!\)\./)
end
end
@ -116,128 +116,128 @@ RSpec.describe "Exception" do
context "when the class is derived from Formula" do
let(:list) { [mod.const_get(:Baz)] }
its(:to_s) { is_expected.to match(/Expected to find class Foo, but only found: Baz\./) }
it(:to_s) { expect(error.to_s).to match(/Expected to find class Foo, but only found: Baz\./) }
end
end
describe FormulaUnreadableError do
subject { described_class.new("foo", formula_error) }
subject(:error) { described_class.new("foo", formula_error) }
let(:formula_error) { LoadError.new("bar") }
its(:to_s) { is_expected.to eq("foo: bar") }
it(:to_s) { expect(error.to_s).to eq("foo: bar") }
end
describe TapUnavailableError do
subject { described_class.new("foo") }
subject(:error) { described_class.new("foo") }
its(:to_s) { is_expected.to eq("No available tap foo.\nRun brew tap-new foo to create a new foo tap!\n") }
it(:to_s) { expect(error.to_s).to eq("No available tap foo.\nRun brew tap-new foo to create a new foo tap!\n") }
end
describe TapAlreadyTappedError do
subject { described_class.new("foo") }
subject(:error) { described_class.new("foo") }
its(:to_s) { is_expected.to eq("Tap foo already tapped.\n") }
it(:to_s) { expect(error.to_s).to eq("Tap foo already tapped.\n") }
end
describe BuildError do
subject { described_class.new(formula, "badprg", ["arg1", 2, Pathname.new("arg3"), :arg4], {}) }
subject(:error) { described_class.new(formula, "badprg", ["arg1", 2, Pathname.new("arg3"), :arg4], {}) }
let(:formula) { instance_double(Formula, name: "foo") }
its(:to_s) { is_expected.to eq("Failed executing: badprg arg1 2 arg3 arg4") }
it(:to_s) { expect(error.to_s).to eq("Failed executing: badprg arg1 2 arg3 arg4") }
end
describe OperationInProgressError do
subject { described_class.new("foo") }
subject(:error) { described_class.new("foo") }
its(:to_s) { is_expected.to match(/Operation already in progress for foo/) }
it(:to_s) { expect(error.to_s).to match(/Operation already in progress for foo/) }
end
describe FormulaInstallationAlreadyAttemptedError do
subject { described_class.new(formula) }
subject(:error) { described_class.new(formula) }
let(:formula) { instance_double(Formula, full_name: "foo/bar") }
its(:to_s) { is_expected.to eq("Formula installation already attempted: foo/bar") }
it(:to_s) { expect(error.to_s).to eq("Formula installation already attempted: foo/bar") }
end
describe FormulaConflictError do
subject { described_class.new(formula, [conflict]) }
subject(:error) { described_class.new(formula, [conflict]) }
let(:formula) { instance_double(Formula, full_name: "foo/qux") }
let(:conflict) { instance_double(FormulaConflict, name: "bar", reason: "I decided to") }
its(:to_s) { is_expected.to match(/Please `brew unlink bar` before continuing\./) }
it(:to_s) { expect(error.to_s).to match(/Please `brew unlink bar` before continuing\./) }
end
describe CompilerSelectionError do
subject { described_class.new(formula) }
subject(:error) { described_class.new(formula) }
let(:formula) { instance_double(Formula, full_name: "foo") }
its(:to_s) { is_expected.to match(/foo cannot be built with any available compilers\./) }
it(:to_s) { expect(error.to_s).to match(/foo cannot be built with any available compilers\./) }
end
describe CurlDownloadStrategyError do
context "when the file does not exist" do
subject { described_class.new("file:///tmp/foo") }
subject(:error) { described_class.new("file:///tmp/foo") }
its(:to_s) { is_expected.to eq("File does not exist: /tmp/foo") }
it(:to_s) { expect(error.to_s).to eq("File does not exist: /tmp/foo") }
end
context "when the download failed" do
subject { described_class.new("https://brew.sh") }
subject(:error) { described_class.new("https://brew.sh") }
its(:to_s) { is_expected.to eq("Download failed: https://brew.sh") }
it(:to_s) { expect(error.to_s).to eq("Download failed: https://brew.sh") }
end
end
describe ErrorDuringExecution do
subject { described_class.new(["badprg", "arg1", "arg2"], status:) }
subject(:error) { described_class.new(["badprg", "arg1", "arg2"], status:) }
let(:status) { instance_double(Process::Status, exitstatus: 17, termsig: nil) }
its(:to_s) { is_expected.to eq("Failure while executing; `badprg arg1 arg2` exited with 17.") }
it(:to_s) { expect(error.to_s).to eq("Failure while executing; `badprg arg1 arg2` exited with 17.") }
end
describe ChecksumMismatchError do
subject { described_class.new("/file.tar.gz", expected_checksum, actual_checksum) }
subject(:error) { described_class.new("/file.tar.gz", expected_checksum, actual_checksum) }
let(:expected_checksum) { instance_double(Checksum, to_s: "deadbeef") }
let(:actual_checksum) { instance_double(Checksum, to_s: "deadcafe") }
its(:to_s) { is_expected.to match(/SHA256 mismatch/) }
it(:to_s) { expect(error.to_s).to match(/SHA256 mismatch/) }
end
describe ResourceMissingError do
subject { described_class.new(formula, resource) }
subject(:error) { described_class.new(formula, resource) }
let(:formula) { instance_double(Formula, full_name: "bar") }
let(:resource) { instance_double(Resource, inspect: "<resource foo>") }
its(:to_s) { is_expected.to eq("bar does not define resource <resource foo>") }
it(:to_s) { expect(error.to_s).to eq("bar does not define resource <resource foo>") }
end
describe DuplicateResourceError do
subject { described_class.new(resource) }
subject(:error) { described_class.new(resource) }
let(:resource) { instance_double(Resource, inspect: "<resource foo>") }
its(:to_s) { is_expected.to eq("Resource <resource foo> is defined more than once") }
it(:to_s) { expect(error.to_s).to eq("Resource <resource foo> is defined more than once") }
end
describe BottleFormulaUnavailableError do
subject { described_class.new("/foo.bottle.tar.gz", "foo/1.0/.brew/foo.rb") }
subject(:error) { described_class.new("/foo.bottle.tar.gz", "foo/1.0/.brew/foo.rb") }
let(:formula) { instance_double(Formula, full_name: "foo") }
its(:to_s) { is_expected.to match(/This bottle does not contain the formula file/) }
it(:to_s) { expect(error.to_s).to match(/This bottle does not contain the formula file/) }
end
describe BuildFlagsError do
subject { described_class.new(["-s"]) }
subject(:error) { described_class.new(["-s"]) }
its(:to_s) { is_expected.to match(/flag:\s+-s\nrequires building tools/) }
it(:to_s) { expect(error.to_s).to match(/flag:\s+-s\nrequires building tools/) }
end
end

View File

@ -5,39 +5,39 @@ require "patch"
RSpec.describe Patch do
describe "#create" do
context "with a simple patch" do
subject { described_class.create(:p2, nil) }
subject(:patch) { described_class.create(:p2, nil) }
it { is_expected.to be_a ExternalPatch }
it { is_expected.to be_external }
its(:strip) { is_expected.to eq(:p2) }
it(:strip) { expect(patch.strip).to eq(:p2) }
end
context "with a string patch" do
subject { described_class.create(:p0, "foo") }
subject(:patch) { described_class.create(:p0, "foo") }
it { is_expected.to be_a StringPatch }
its(:strip) { is_expected.to eq(:p0) }
it(:strip) { expect(patch.strip).to eq(:p0) }
end
context "with a string patch without strip" do
subject { described_class.create("foo", nil) }
subject(:patch) { described_class.create("foo", nil) }
it { is_expected.to be_a StringPatch }
its(:strip) { is_expected.to eq(:p1) }
it(:strip) { expect(patch.strip).to eq(:p1) }
end
context "with a data patch" do
subject { described_class.create(:p0, :DATA) }
subject(:patch) { described_class.create(:p0, :DATA) }
it { is_expected.to be_a DATAPatch }
its(:strip) { is_expected.to eq(:p0) }
it(:strip) { expect(patch.strip).to eq(:p0) }
end
context "with a data patch without strip" do
subject { described_class.create(:DATA, nil) }
subject(:patch) { described_class.create(:DATA, nil) }
it { is_expected.to be_a DATAPatch }
its(:strip) { is_expected.to eq(:p1) }
it(:strip) { expect(patch.strip).to eq(:p1) }
end
it "raises an error for unknown values" do
@ -55,9 +55,9 @@ RSpec.describe Patch do
subject(:patch) { described_class.create(:p2, nil) }
context "when the patch is empty" do
its(:resource) { is_expected.to be_a Resource::PatchResource }
its(:patch_files) { is_expected.to eq(patch.resource.patch_files) }
its(:patch_files) { is_expected.to eq([]) }
it(:resource) { expect(patch.resource).to be_a Resource::PatchResource }
it { expect(patch.patch_files).to eq(patch.resource.patch_files) }
it { expect(patch.patch_files).to eq([]) }
end
it "returns applied patch files" do
@ -77,9 +77,9 @@ RSpec.describe Patch do
describe EmbeddedPatch do
describe "#new" do
subject { described_class.new(:p1) }
subject(:patch) { described_class.new(:p1) }
its(:inspect) { is_expected.to eq("#<EmbeddedPatch: :p1>") }
it(:inspect) { expect(patch.inspect).to eq("#<EmbeddedPatch: :p1>") }
end
end
@ -87,11 +87,11 @@ RSpec.describe Patch do
subject(:patch) { described_class.new(:p1) { url "file:///my.patch" } }
describe "#url" do
its(:url) { is_expected.to eq("file:///my.patch") }
it(:url) { expect(patch.url).to eq("file:///my.patch") }
end
describe "#inspect" do
its(:inspect) { is_expected.to eq('#<ExternalPatch: :p1 "file:///my.patch">') }
it(:inspect) { expect(patch.inspect).to eq('#<ExternalPatch: :p1 "file:///my.patch">') }
end
describe "#cached_download" do
@ -99,7 +99,7 @@ RSpec.describe Patch do
allow(patch.resource).to receive(:cached_download).and_return("/tmp/foo.tar.gz")
end
its(:cached_download) { is_expected.to eq("/tmp/foo.tar.gz") }
it(:cached_download) { expect(patch.cached_download).to eq("/tmp/foo.tar.gz") }
end
end
end

View File

@ -11,30 +11,30 @@ RSpec.describe Requirement do
let(:klass) { Class.new(described_class) }
describe "#tags" do
subject { klass.new(tags) }
subject(:req) { klass.new(tags) }
context "with a single tag" do
let(:tags) { ["bar"] }
its(:tags) { are_expected.to eq(tags) }
it(:tags) { expect(req.tags).to eq(tags) }
end
context "with multiple tags" do
let(:tags) { ["bar", "baz"] }
its(:tags) { are_expected.to eq(tags) }
it(:tags) { expect(req.tags).to eq(tags) }
end
context "with symbol tags" do
let(:tags) { [:build] }
its(:tags) { are_expected.to eq(tags) }
it(:tags) { expect(req.tags).to eq(tags) }
end
context "with symbol and string tags" do
let(:tags) { [:build, "bar"] }
its(:tags) { are_expected.to eq(tags) }
it(:tags) { expect(req.tags).to eq(tags) }
end
end
@ -168,8 +168,8 @@ RSpec.describe Requirement do
stub_const const.to_s, Class.new(described_class)
end
its(:name) { is_expected.to eq("foo") }
its(:option_names) { are_expected.to eq(["foo"]) }
it(:name) { expect(requirement.name).to eq("foo") }
it(:option_names) { expect(requirement.option_names).to eq(["foo"]) }
end
describe "#modify_build_environment" do

View File

@ -24,7 +24,6 @@ Warnings.ignore :parser_syntax do
require "rubocop"
end
require "rspec/its"
require "rspec/github"
require "rspec/retry"
require "rspec/sorbet"

View File

@ -21,7 +21,7 @@ RSpec.describe SystemCommand do
let(:sudo_as_root) { false }
context "when given some environment variables" do
its("run!.stdout") { is_expected.to eq("123") }
it("run!.stdout") { expect(command.run!.stdout).to eq("123") }
describe "the resulting command line" do
it "includes the given variables explicitly" do
@ -94,10 +94,10 @@ RSpec.describe SystemCommand do
context "when the exit code is 0" do
describe "its result" do
subject { described_class.run("true") }
subject(:result) { described_class.run("true") }
it { is_expected.to be_a_success }
its(:exit_status) { is_expected.to eq(0) }
it(:exit_status) { expect(result.exit_status).to eq(0) }
end
end
@ -114,10 +114,10 @@ RSpec.describe SystemCommand do
context "with a command that does not have to succeed" do
describe "its result" do
subject { described_class.run(command) }
subject(:result) { described_class.run(command) }
it { is_expected.not_to be_a_success }
its(:exit_status) { is_expected.to eq(1) }
it(:exit_status) { expect(result.exit_status).to eq(1) }
end
end
end
@ -131,10 +131,10 @@ RSpec.describe SystemCommand do
end
describe "its result" do
subject { described_class.run(command, args: [path]) }
subject(:result) { described_class.run(command, args: [path]) }
it { is_expected.to be_a_success }
its(:stdout) { is_expected.to eq("somefile\n") }
it(:stdout) { expect(result.stdout).to eq("somefile\n") }
end
end
@ -149,11 +149,11 @@ RSpec.describe SystemCommand do
shared_examples "it returns '1 2 3 4 5 6'" do
describe "its result" do
subject { described_class.run(command, **options) }
subject(:result) { described_class.run(command, **options) }
it { is_expected.to be_a_success }
its(:stdout) { is_expected.to eq([1, 3, 5, nil].join("\n")) }
its(:stderr) { is_expected.to eq([2, 4, 6, nil].join("\n")) }
it(:stdout) { expect(result.stdout).to eq([1, 3, 5, nil].join("\n")) }
it(:stderr) { expect(result.stderr).to eq([2, 4, 6, nil].join("\n")) }
end
end

View File

@ -279,13 +279,13 @@ RSpec.describe Tap do
context "when using the default remote" do
let(:remote) { "https://github.com/Homebrew/homebrew-services" }
its(:custom_remote?) { is_expected.to be false }
it(:custom_remote?) { expect(tap.custom_remote?).to be false }
end
context "when using a non-default remote" do
let(:remote) { "git@github.com:Homebrew/homebrew-services" }
its(:custom_remote?) { is_expected.to be true }
it(:custom_remote?) { expect(tap.custom_remote?).to be true }
end
end

View File

@ -3,7 +3,7 @@
require "utils/user"
RSpec.describe User do
subject { described_class.current }
subject(:user) { described_class.current }
it { is_expected.to eq ENV.fetch("USER") }
@ -22,7 +22,7 @@ RSpec.describe User do
EOS
end
its(:gui?) { is_expected.to be true }
it(:gui?) { expect(user.gui?).to be true }
end
context "when the current user is not in a console session" do
@ -33,7 +33,7 @@ RSpec.describe User do
EOS
end
its(:gui?) { is_expected.to be false }
it(:gui?) { expect(user.gui?).to be false }
end
end
end

View File

@ -80,7 +80,6 @@ $:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/rspec-mocks-3.13.0/lib")
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/rspec-3.13.0/lib")
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/rspec-github-2.4.0/lib")
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/rspec-its-1.3.0/lib")
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/rspec-retry-0.6.2/lib")
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/rspec-sorbet-1.9.2/lib")
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/rspec_junit_formatter-0.6.0/lib")