Skip to content

Commit

Permalink
add spec for alternate global Brewfile path
Browse files Browse the repository at this point in the history
  • Loading branch information
rrotter committed Jan 25, 2025
1 parent 37dc2d4 commit 28bf5f9
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions spec/bundle/brewfile_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,22 @@
let(:dash_writes_to_stdout) { false }
let(:env_bundle_file_global_value) { nil }
let(:env_bundle_file_value) { nil }
let(:env_user_config_home_value) { "/Users/username/.homebrew" }
let(:file_value) { nil }
let(:has_global) { false }
let(:config_dir_brewfile_exist) { false }

before do
allow(ENV).to receive(:fetch).and_return(nil)
allow(ENV).to receive(:fetch).with("HOMEBREW_BUNDLE_FILE_GLOBAL", any_args)
.and_return(env_bundle_file_global_value)
allow(ENV).to receive(:fetch).with("HOMEBREW_BUNDLE_FILE", any_args)
.and_return(env_bundle_file_value)

allow(ENV).to receive(:fetch).with("HOMEBREW_USER_CONFIG_HOME", any_args)
.and_return(env_user_config_home_value)
allow(File).to receive(:exist?).with("/Users/username/.homebrew/Brewfile")
.and_return(config_dir_brewfile_exist)
end

context "when `file` is specified with a relative path" do
Expand Down Expand Up @@ -154,6 +161,15 @@
expect(path).to eq(expected_pathname)
end
end

context "when HOMEBREW_USER_CONFIG_HOME/Brewfile exists" do
let(:config_dir_brewfile_exist) { true }
let(:expected_pathname) { Pathname.new("#{env_user_config_home_value}/Brewfile") }

it "returns the expected path" do
expect(path).to eq(expected_pathname)
end
end
end

context "when HOMEBREW_BUNDLE_FILE has a value" do
Expand Down

0 comments on commit 28bf5f9

Please sign in to comment.