| 
									
										
										
										
											2019-04-19 15:38:03 +09:00
										 |  |  | # frozen_string_literal: true | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-14 17:45:20 +01:00
										 |  |  | require "exceptions" | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-02-18 15:11:11 -08:00
										 |  |  | RSpec.describe "Exception" do | 
					
						
							| 
									
										
										
										
											2021-01-31 14:50:29 -05:00
										 |  |  |   describe MultipleVersionsInstalledError do | 
					
						
							| 
									
										
										
										
											2024-03-17 22:47:37 -07:00
										 |  |  |     subject(:error) do | 
					
						
							| 
									
										
										
										
											2021-01-31 14:50:29 -05:00
										 |  |  |       described_class.new <<~EOS | 
					
						
							|  |  |  |         foo has multiple installed versions | 
					
						
							|  |  |  |         Run `brew uninstall --force foo` to remove all versions. | 
					
						
							|  |  |  |       EOS | 
					
						
							| 
									
										
										
										
											2023-03-08 23:14:46 +00:00
										 |  |  |     end | 
					
						
							| 
									
										
										
										
											2017-02-14 17:45:20 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-03-17 22:47:37 -07:00
										 |  |  |     it(:to_s) do | 
					
						
							|  |  |  |       expect(error.to_s).to eq <<~EOS | 
					
						
							| 
									
										
										
										
											2021-01-31 14:50:29 -05:00
										 |  |  |         foo has multiple installed versions | 
					
						
							|  |  |  |         Run `brew uninstall --force foo` to remove all versions. | 
					
						
							|  |  |  |       EOS | 
					
						
							| 
									
										
										
										
											2023-03-08 23:14:46 +00:00
										 |  |  |     end | 
					
						
							| 
									
										
										
										
											2021-01-31 14:50:29 -05:00
										 |  |  |   end | 
					
						
							| 
									
										
										
										
											2018-03-25 13:30:37 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-01-31 14:50:29 -05:00
										 |  |  |   describe NoSuchKegError do | 
					
						
							| 
									
										
										
										
											2024-03-17 22:47:37 -07:00
										 |  |  |     subject(:error) { described_class.new("foo") } | 
					
						
							| 
									
										
										
										
											2017-02-14 17:45:20 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-03-17 22:47:37 -07:00
										 |  |  |     it(:to_s) { expect(error.to_s).to eq("No such keg: #{HOMEBREW_CELLAR}/foo") } | 
					
						
							| 
									
										
										
										
											2021-01-31 14:50:29 -05:00
										 |  |  |   end | 
					
						
							| 
									
										
										
										
											2018-03-25 13:30:37 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-01-31 14:50:29 -05:00
										 |  |  |   describe FormulaValidationError do | 
					
						
							|  |  |  |     subject(:error) { described_class.new("foo", "sha257", "magic") } | 
					
						
							| 
									
										
										
										
											2017-02-14 17:45:20 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-03-17 22:47:37 -07:00
										 |  |  |     it(:to_s) do | 
					
						
							| 
									
										
										
										
											2021-01-31 14:50:29 -05:00
										 |  |  |       expect(error.to_s).to eq(%q(invalid attribute for formula 'foo': sha257 ("magic"))) | 
					
						
							| 
									
										
										
										
											2023-03-08 23:14:46 +00:00
										 |  |  |     end | 
					
						
							| 
									
										
										
										
											2021-01-31 14:50:29 -05:00
										 |  |  |   end | 
					
						
							| 
									
										
										
										
											2017-02-14 17:45:20 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-03-12 01:28:20 +05:30
										 |  |  |   describe TapFormulaOrCaskUnavailableError do | 
					
						
							|  |  |  |     subject(:error) { described_class.new(tap, "foo") } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-01-22 17:06:48 -08:00
										 |  |  |     let(:tap) { instance_double(Tap, user: "u", repo: "r", to_s: "u/r", installed?: false) } | 
					
						
							| 
									
										
										
										
											2021-03-12 01:28:20 +05:30
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-03-17 22:47:37 -07:00
										 |  |  |     it(:to_s) { expect(error.to_s).to match(%r{Please tap it and then try again: brew tap u/r}) } | 
					
						
							| 
									
										
										
										
											2021-03-12 01:28:20 +05:30
										 |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-01-31 14:50:29 -05:00
										 |  |  |   describe FormulaUnavailableError do | 
					
						
							|  |  |  |     subject(:error) { described_class.new("foo") } | 
					
						
							| 
									
										
										
										
											2017-02-14 17:45:20 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-01-31 14:50:29 -05:00
										 |  |  |     describe "#dependent_s" do | 
					
						
							|  |  |  |       it "returns nil if there is no dependent" do | 
					
						
							| 
									
										
										
										
											2022-03-01 00:01:13 +00:00
										 |  |  |         expect(error.dependent_s).to be_nil | 
					
						
							| 
									
										
										
										
											2021-01-31 14:50:29 -05:00
										 |  |  |       end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       it "returns nil if it depended on by itself" do | 
					
						
							|  |  |  |         error.dependent = "foo" | 
					
						
							| 
									
										
										
										
											2022-03-01 00:01:13 +00:00
										 |  |  |         expect(error.dependent_s).to be_nil | 
					
						
							| 
									
										
										
										
											2021-01-31 14:50:29 -05:00
										 |  |  |       end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       it "returns a string if there is a dependent" do | 
					
						
							|  |  |  |         error.dependent = "foobar" | 
					
						
							|  |  |  |         expect(error.dependent_s).to eq(" (dependency of foobar)") | 
					
						
							|  |  |  |       end | 
					
						
							| 
									
										
										
										
											2017-02-14 17:45:20 +01:00
										 |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-01-31 14:50:29 -05:00
										 |  |  |     context "without a dependent" do | 
					
						
							| 
									
										
										
										
											2024-03-17 22:47:37 -07:00
										 |  |  |       it(:to_s) { expect(error.to_s).to eq('No available formula with the name "foo".') } | 
					
						
							| 
									
										
										
										
											2017-02-14 17:45:20 +01:00
										 |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-01-31 14:50:29 -05:00
										 |  |  |     context "with a dependent" do | 
					
						
							|  |  |  |       before do | 
					
						
							|  |  |  |         error.dependent = "foobar" | 
					
						
							|  |  |  |       end | 
					
						
							| 
									
										
										
										
											2017-02-14 17:45:20 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-03-17 22:47:37 -07:00
										 |  |  |       it(:to_s) do | 
					
						
							| 
									
										
										
										
											2021-01-31 14:50:29 -05:00
										 |  |  |         expect(error.to_s).to eq('No available formula with the name "foo" (dependency of foobar).') | 
					
						
							| 
									
										
										
										
											2023-03-08 23:14:46 +00:00
										 |  |  |       end | 
					
						
							| 
									
										
										
										
											2017-02-14 17:45:20 +01:00
										 |  |  |     end | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-01-31 14:50:29 -05:00
										 |  |  |   describe TapFormulaUnavailableError do | 
					
						
							| 
									
										
										
										
											2024-03-17 22:47:37 -07:00
										 |  |  |     subject(:error) { described_class.new(tap, "foo") } | 
					
						
							| 
									
										
										
										
											2018-03-25 13:30:37 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-01-22 17:06:48 -08:00
										 |  |  |     let(:tap) { instance_double(Tap, user: "u", repo: "r", to_s: "u/r", installed?: false) } | 
					
						
							| 
									
										
										
										
											2018-03-25 13:30:37 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-03-17 22:47:37 -07:00
										 |  |  |     it(:to_s) { expect(error.to_s).to match(%r{Please tap it and then try again: brew tap u/r}) } | 
					
						
							| 
									
										
										
										
											2021-01-31 14:50:29 -05:00
										 |  |  |   end | 
					
						
							| 
									
										
										
										
											2017-02-14 17:45:20 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-01-31 14:50:29 -05:00
										 |  |  |   describe FormulaClassUnavailableError do | 
					
						
							|  |  |  |     subject(:error) { described_class.new("foo", "foo.rb", "Foo", list) } | 
					
						
							| 
									
										
										
										
											2018-03-25 13:30:37 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-01-31 14:50:29 -05:00
										 |  |  |     let(:mod) do | 
					
						
							|  |  |  |       Module.new do | 
					
						
							| 
									
										
										
										
											2023-01-24 20:07:22 -08:00
										 |  |  |         # These are defined within an anonymous module to avoid polluting the global namespace. | 
					
						
							| 
									
										
										
										
											2023-02-18 23:09:23 +00:00
										 |  |  |         # rubocop:disable RSpec/LeakyConstantDeclaration,Lint/ConstantDefinitionInBlock | 
					
						
							| 
									
										
										
										
											2021-01-31 14:50:29 -05:00
										 |  |  |         class Bar < Requirement; end | 
					
						
							| 
									
										
										
										
											2020-11-30 16:27:49 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-01-31 14:50:29 -05:00
										 |  |  |         class Baz < Formula; end | 
					
						
							| 
									
										
										
										
											2023-02-18 23:09:23 +00:00
										 |  |  |         # rubocop:enable RSpec/LeakyConstantDeclaration,Lint/ConstantDefinitionInBlock | 
					
						
							| 
									
										
										
										
											2021-01-31 14:50:29 -05:00
										 |  |  |       end | 
					
						
							| 
									
										
										
										
											2017-02-14 17:45:20 +01:00
										 |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-19 23:15:33 +00:00
										 |  |  |     context "when there are no classes" do | 
					
						
							| 
									
										
										
										
											2021-01-31 14:50:29 -05:00
										 |  |  |       let(:list) { [] } | 
					
						
							| 
									
										
										
										
											2018-03-25 13:30:37 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-03-17 22:47:37 -07:00
										 |  |  |       it(:to_s) do | 
					
						
							| 
									
										
										
										
											2021-01-31 14:50:29 -05:00
										 |  |  |         expect(error.to_s).to match(/Expected to find class Foo, but found no classes\./) | 
					
						
							| 
									
										
										
										
											2023-03-08 23:14:46 +00:00
										 |  |  |       end | 
					
						
							| 
									
										
										
										
											2021-01-31 14:50:29 -05:00
										 |  |  |     end | 
					
						
							| 
									
										
										
										
											2017-02-14 17:45:20 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-19 23:15:33 +00:00
										 |  |  |     context "when the class is not derived from Formula" do | 
					
						
							| 
									
										
										
										
											2021-01-31 14:50:29 -05:00
										 |  |  |       let(:list) { [mod.const_get(:Bar)] } | 
					
						
							| 
									
										
										
										
											2018-03-25 13:30:37 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-03-17 22:47:37 -07:00
										 |  |  |       it(:to_s) do | 
					
						
							| 
									
										
										
										
											2021-01-31 14:50:29 -05:00
										 |  |  |         expect(error.to_s).to match(/Expected to find class Foo, but only found: Bar \(not derived from Formula!\)\./) | 
					
						
							| 
									
										
										
										
											2023-03-08 23:14:46 +00:00
										 |  |  |       end | 
					
						
							| 
									
										
										
										
											2021-01-31 14:50:29 -05:00
										 |  |  |     end | 
					
						
							| 
									
										
										
										
											2017-02-14 17:45:20 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-19 23:15:33 +00:00
										 |  |  |     context "when the class is derived from Formula" do | 
					
						
							| 
									
										
										
										
											2021-01-31 14:50:29 -05:00
										 |  |  |       let(:list) { [mod.const_get(:Baz)] } | 
					
						
							| 
									
										
										
										
											2018-03-25 13:30:37 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-03-17 22:47:37 -07:00
										 |  |  |       it(:to_s) { expect(error.to_s).to match(/Expected to find class Foo, but only found: Baz\./) } | 
					
						
							| 
									
										
										
										
											2021-01-31 14:50:29 -05:00
										 |  |  |     end | 
					
						
							| 
									
										
										
										
											2017-02-14 17:45:20 +01:00
										 |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-01-31 14:50:29 -05:00
										 |  |  |   describe FormulaUnreadableError do | 
					
						
							| 
									
										
										
										
											2024-03-17 22:47:37 -07:00
										 |  |  |     subject(:error) { described_class.new("foo", formula_error) } | 
					
						
							| 
									
										
										
										
											2018-03-25 13:30:37 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-01-31 14:50:29 -05:00
										 |  |  |     let(:formula_error) { LoadError.new("bar") } | 
					
						
							| 
									
										
										
										
											2018-03-25 13:30:37 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-03-17 22:47:37 -07:00
										 |  |  |     it(:to_s) { expect(error.to_s).to eq("foo: bar") } | 
					
						
							| 
									
										
										
										
											2021-01-31 14:50:29 -05:00
										 |  |  |   end | 
					
						
							| 
									
										
										
										
											2017-02-14 17:45:20 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-01-31 14:50:29 -05:00
										 |  |  |   describe TapUnavailableError do | 
					
						
							| 
									
										
										
										
											2024-03-17 22:47:37 -07:00
										 |  |  |     subject(:error) { described_class.new("foo") } | 
					
						
							| 
									
										
										
										
											2018-03-25 13:30:37 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-03-17 22:47:37 -07:00
										 |  |  |     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") } | 
					
						
							| 
									
										
										
										
											2021-01-31 14:50:29 -05:00
										 |  |  |   end | 
					
						
							| 
									
										
										
										
											2017-02-14 17:45:20 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-01-31 14:50:29 -05:00
										 |  |  |   describe TapAlreadyTappedError do | 
					
						
							| 
									
										
										
										
											2024-03-17 22:47:37 -07:00
										 |  |  |     subject(:error) { described_class.new("foo") } | 
					
						
							| 
									
										
										
										
											2018-03-25 13:30:37 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-03-17 22:47:37 -07:00
										 |  |  |     it(:to_s) { expect(error.to_s).to eq("Tap foo already tapped.\n") } | 
					
						
							| 
									
										
										
										
											2021-01-31 14:50:29 -05:00
										 |  |  |   end | 
					
						
							| 
									
										
										
										
											2017-02-14 17:45:20 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-01-31 14:50:29 -05:00
										 |  |  |   describe BuildError do | 
					
						
							| 
									
										
										
										
											2024-03-17 22:47:37 -07:00
										 |  |  |     subject(:error) { described_class.new(formula, "badprg", ["arg1", 2, Pathname.new("arg3"), :arg4], {}) } | 
					
						
							| 
									
										
										
										
											2018-03-25 13:30:37 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-01-22 17:06:48 -08:00
										 |  |  |     let(:formula) { instance_double(Formula, name: "foo") } | 
					
						
							| 
									
										
										
										
											2018-03-25 13:30:37 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-03-17 22:47:37 -07:00
										 |  |  |     it(:to_s) { expect(error.to_s).to eq("Failed executing: badprg arg1 2 arg3 arg4") } | 
					
						
							| 
									
										
										
										
											2021-01-31 14:50:29 -05:00
										 |  |  |   end | 
					
						
							| 
									
										
										
										
											2017-02-14 17:45:20 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-01-31 14:50:29 -05:00
										 |  |  |   describe OperationInProgressError do | 
					
						
							| 
									
										
										
										
											2024-07-30 17:51:02 +01:00
										 |  |  |     subject(:error) { described_class.new(Pathname("foo")) } | 
					
						
							| 
									
										
										
										
											2018-03-25 13:30:37 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-07-30 17:51:02 +01:00
										 |  |  |     it(:to_s) { expect(error.to_s).to match(/has already locked foo/) } | 
					
						
							| 
									
										
										
										
											2021-01-31 14:50:29 -05:00
										 |  |  |   end | 
					
						
							| 
									
										
										
										
											2017-02-14 17:45:20 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-01-31 14:50:29 -05:00
										 |  |  |   describe FormulaInstallationAlreadyAttemptedError do | 
					
						
							| 
									
										
										
										
											2024-03-17 22:47:37 -07:00
										 |  |  |     subject(:error) { described_class.new(formula) } | 
					
						
							| 
									
										
										
										
											2018-03-25 13:30:37 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-01-22 17:06:48 -08:00
										 |  |  |     let(:formula) { instance_double(Formula, full_name: "foo/bar") } | 
					
						
							| 
									
										
										
										
											2018-03-25 13:30:37 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-03-17 22:47:37 -07:00
										 |  |  |     it(:to_s) { expect(error.to_s).to eq("Formula installation already attempted: foo/bar") } | 
					
						
							| 
									
										
										
										
											2021-01-31 14:50:29 -05:00
										 |  |  |   end | 
					
						
							| 
									
										
										
										
											2017-02-14 17:45:20 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-01-31 14:50:29 -05:00
										 |  |  |   describe FormulaConflictError do | 
					
						
							| 
									
										
										
										
											2024-03-17 22:47:37 -07:00
										 |  |  |     subject(:error) { described_class.new(formula, [conflict]) } | 
					
						
							| 
									
										
										
										
											2018-03-25 13:30:37 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-01-22 17:06:48 -08:00
										 |  |  |     let(:formula) { instance_double(Formula, full_name: "foo/qux") } | 
					
						
							|  |  |  |     let(:conflict) { instance_double(FormulaConflict, name: "bar", reason: "I decided to") } | 
					
						
							| 
									
										
										
										
											2018-03-25 13:30:37 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-03-17 22:47:37 -07:00
										 |  |  |     it(:to_s) { expect(error.to_s).to match(/Please `brew unlink bar` before continuing\./) } | 
					
						
							| 
									
										
										
										
											2021-01-31 14:50:29 -05:00
										 |  |  |   end | 
					
						
							| 
									
										
										
										
											2017-02-14 17:45:20 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-01-31 14:50:29 -05:00
										 |  |  |   describe CompilerSelectionError do | 
					
						
							| 
									
										
										
										
											2024-03-17 22:47:37 -07:00
										 |  |  |     subject(:error) { described_class.new(formula) } | 
					
						
							| 
									
										
										
										
											2018-03-25 13:30:37 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-01-22 17:06:48 -08:00
										 |  |  |     let(:formula) { instance_double(Formula, full_name: "foo") } | 
					
						
							| 
									
										
										
										
											2018-03-25 13:30:37 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-03-17 22:47:37 -07:00
										 |  |  |     it(:to_s) { expect(error.to_s).to match(/foo cannot be built with any available compilers\./) } | 
					
						
							| 
									
										
										
										
											2021-01-31 14:50:29 -05:00
										 |  |  |   end | 
					
						
							| 
									
										
										
										
											2017-02-14 17:45:20 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-01-31 14:50:29 -05:00
										 |  |  |   describe CurlDownloadStrategyError do | 
					
						
							| 
									
										
										
										
											2021-02-19 23:15:33 +00:00
										 |  |  |     context "when the file does not exist" do | 
					
						
							| 
									
										
										
										
											2024-03-17 22:47:37 -07:00
										 |  |  |       subject(:error) { described_class.new("file:///tmp/foo") } | 
					
						
							| 
									
										
										
										
											2018-03-25 13:30:37 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-03-17 22:47:37 -07:00
										 |  |  |       it(:to_s) { expect(error.to_s).to eq("File does not exist: /tmp/foo") } | 
					
						
							| 
									
										
										
										
											2021-01-31 14:50:29 -05:00
										 |  |  |     end | 
					
						
							| 
									
										
										
										
											2017-02-14 17:45:20 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-19 23:15:33 +00:00
										 |  |  |     context "when the download failed" do | 
					
						
							| 
									
										
										
										
											2024-03-17 22:47:37 -07:00
										 |  |  |       subject(:error) { described_class.new("https://brew.sh") } | 
					
						
							| 
									
										
										
										
											2018-03-25 13:30:37 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-03-17 22:47:37 -07:00
										 |  |  |       it(:to_s) { expect(error.to_s).to eq("Download failed: https://brew.sh") } | 
					
						
							| 
									
										
										
										
											2021-01-31 14:50:29 -05:00
										 |  |  |     end | 
					
						
							| 
									
										
										
										
											2017-02-14 17:45:20 +01:00
										 |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-01-31 14:50:29 -05:00
										 |  |  |   describe ErrorDuringExecution do | 
					
						
							| 
									
										
										
										
											2024-03-17 22:47:37 -07:00
										 |  |  |     subject(:error) { described_class.new(["badprg", "arg1", "arg2"], status:) } | 
					
						
							| 
									
										
										
										
											2018-09-20 09:07:56 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-23 21:30:36 +00:00
										 |  |  |     let(:status) { instance_double(Process::Status, exitstatus: 17, termsig: nil) } | 
					
						
							| 
									
										
										
										
											2018-03-25 13:30:37 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-03-17 22:47:37 -07:00
										 |  |  |     it(:to_s) { expect(error.to_s).to eq("Failure while executing; `badprg arg1 arg2` exited with 17.") } | 
					
						
							| 
									
										
										
										
											2021-01-31 14:50:29 -05:00
										 |  |  |   end | 
					
						
							| 
									
										
										
										
											2017-02-14 17:45:20 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-01-31 14:50:29 -05:00
										 |  |  |   describe ChecksumMismatchError do | 
					
						
							| 
									
										
										
										
											2024-03-17 22:47:37 -07:00
										 |  |  |     subject(:error) { described_class.new("/file.tar.gz", expected_checksum, actual_checksum) } | 
					
						
							| 
									
										
										
										
											2018-03-25 13:30:37 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-04-20 12:14:45 +00:00
										 |  |  |     let(:expected_checksum) { instance_double(Checksum, to_s: "deadbeef") } | 
					
						
							|  |  |  |     let(:actual_checksum) { instance_double(Checksum, to_s: "deadcafe") } | 
					
						
							| 
									
										
										
										
											2018-03-25 13:30:37 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-03-17 22:47:37 -07:00
										 |  |  |     it(:to_s) { expect(error.to_s).to match(/SHA256 mismatch/) } | 
					
						
							| 
									
										
										
										
											2021-01-31 14:50:29 -05:00
										 |  |  |   end | 
					
						
							| 
									
										
										
										
											2017-02-14 17:45:20 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-01-31 14:50:29 -05:00
										 |  |  |   describe ResourceMissingError do | 
					
						
							| 
									
										
										
										
											2024-03-17 22:47:37 -07:00
										 |  |  |     subject(:error) { described_class.new(formula, resource) } | 
					
						
							| 
									
										
										
										
											2018-03-25 13:30:37 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-01-22 17:06:48 -08:00
										 |  |  |     let(:formula) { instance_double(Formula, full_name: "bar") } | 
					
						
							|  |  |  |     let(:resource) { instance_double(Resource, inspect: "<resource foo>") } | 
					
						
							| 
									
										
										
										
											2018-03-25 13:30:37 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-03-17 22:47:37 -07:00
										 |  |  |     it(:to_s) { expect(error.to_s).to eq("bar does not define resource <resource foo>") } | 
					
						
							| 
									
										
										
										
											2021-01-31 14:50:29 -05:00
										 |  |  |   end | 
					
						
							| 
									
										
										
										
											2017-02-14 17:45:20 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-01-31 14:50:29 -05:00
										 |  |  |   describe DuplicateResourceError do | 
					
						
							| 
									
										
										
										
											2024-03-17 22:47:37 -07:00
										 |  |  |     subject(:error) { described_class.new(resource) } | 
					
						
							| 
									
										
										
										
											2018-03-25 13:30:37 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-01-22 17:06:48 -08:00
										 |  |  |     let(:resource) { instance_double(Resource, inspect: "<resource foo>") } | 
					
						
							| 
									
										
										
										
											2018-03-25 13:30:37 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-03-17 22:47:37 -07:00
										 |  |  |     it(:to_s) { expect(error.to_s).to eq("Resource <resource foo> is defined more than once") } | 
					
						
							| 
									
										
										
										
											2021-01-31 14:50:29 -05:00
										 |  |  |   end | 
					
						
							| 
									
										
										
										
											2017-02-14 17:45:20 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-01-31 14:50:29 -05:00
										 |  |  |   describe BottleFormulaUnavailableError do | 
					
						
							| 
									
										
										
										
											2024-03-17 22:47:37 -07:00
										 |  |  |     subject(:error) { described_class.new("/foo.bottle.tar.gz", "foo/1.0/.brew/foo.rb") } | 
					
						
							| 
									
										
										
										
											2018-03-25 13:30:37 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-01-22 17:06:48 -08:00
										 |  |  |     let(:formula) { instance_double(Formula, full_name: "foo") } | 
					
						
							| 
									
										
										
										
											2018-03-25 13:30:37 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-03-17 22:47:37 -07:00
										 |  |  |     it(:to_s) { expect(error.to_s).to match(/This bottle does not contain the formula file/) } | 
					
						
							| 
									
										
										
										
											2021-01-31 14:50:29 -05:00
										 |  |  |   end | 
					
						
							| 
									
										
										
										
											2019-10-11 09:34:43 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-01-31 14:50:29 -05:00
										 |  |  |   describe BuildFlagsError do | 
					
						
							| 
									
										
										
										
											2024-03-17 22:47:37 -07:00
										 |  |  |     subject(:error) { described_class.new(["-s"]) } | 
					
						
							| 
									
										
										
										
											2019-10-11 09:34:43 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-03-17 22:47:37 -07:00
										 |  |  |     it(:to_s) { expect(error.to_s).to match(/flag:\s+-s\nrequires building tools/) } | 
					
						
							| 
									
										
										
										
											2021-01-31 14:50:29 -05:00
										 |  |  |   end | 
					
						
							| 
									
										
										
										
											2019-10-11 09:34:43 +02:00
										 |  |  | end |