-
-
Notifications
You must be signed in to change notification settings - Fork 9.3k
/
env_config_spec.rb
102 lines (84 loc) 路 2.81 KB
/
env_config_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# frozen_string_literal: true
require "diagnostic"
RSpec.describe Homebrew::EnvConfig do
subject(:env_config) { described_class }
describe ".env_method_name" do
it "generates method names" do
expect(env_config.env_method_name("HOMEBREW_FOO", {})).to eql("foo")
end
it "generates boolean method names" do
expect(env_config.env_method_name("HOMEBREW_BAR", boolean: true)).to eql("bar?")
end
end
describe ".artifact_domain" do
it "returns value if set" do
ENV["HOMEBREW_ARTIFACT_DOMAIN"] = "https://brew.sh"
expect(env_config.artifact_domain).to eql("https://brew.sh")
end
it "returns nil if empty" do
ENV["HOMEBREW_ARTIFACT_DOMAIN"] = ""
expect(env_config.artifact_domain).to be_nil
end
end
describe ".cleanup_periodic_full_days" do
it "returns value if set" do
ENV["HOMEBREW_CLEANUP_PERIODIC_FULL_DAYS"] = "360"
expect(env_config.cleanup_periodic_full_days).to eql("360")
end
it "returns default if unset" do
ENV["HOMEBREW_CLEANUP_PERIODIC_FULL_DAYS"] = nil
expect(env_config.cleanup_periodic_full_days).to eql("30")
end
end
describe ".bat?" do
it "returns true if set" do
ENV["HOMEBREW_BAT"] = "1"
expect(env_config.bat?).to be(true)
end
it "returns false if unset" do
ENV["HOMEBREW_BAT"] = nil
expect(env_config.bat?).to be(false)
end
end
describe ".make_jobs" do
it "returns value if positive" do
ENV["HOMEBREW_MAKE_JOBS"] = "4"
expect(env_config.make_jobs).to eql("4")
end
it "returns default if negative" do
ENV["HOMEBREW_MAKE_JOBS"] = "-1"
expect(Hardware::CPU).to receive(:cores).and_return(16)
expect(env_config.make_jobs).to eql("16")
end
end
describe ".cask_opts_greedy" do
it "returns true if `--greedy` set" do
ENV["HOMEBREW_CASK_OPTS"] = "--greedy"
expect(env_config.cask_opts_greedy?).to be(true)
end
it "returns false by default" do
ENV["HOMEBREW_CASK_OPTS"] = ""
expect(env_config.cask_opts_greedy?).to be(false)
end
end
describe ".cask_opts_greedy_latest" do
it "returns true if `--greedy-latest` set" do
ENV["HOMEBREW_CASK_OPTS"] = "--greedy-latest"
expect(env_config.cask_opts_greedy_latest?).to be(true)
end
it "returns false by default" do
ENV["HOMEBREW_CASK_OPTS"] = ""
expect(env_config.cask_opts_greedy_latest?).to be(false)
end
end
describe ".cask_opts_greedy_auto_updates" do
it "returns true if `--greedy-auto-updates` set" do
ENV["HOMEBREW_CASK_OPTS"] = "--greedy-auto-updates"
expect(env_config.cask_opts_greedy_auto_updates?).to be(true)
end
it "returns false by default" do
ENV["HOMEBREW_CASK_OPTS"] = ""
expect(env_config.cask_opts_greedy_auto_updates?).to be(false)
end
end
end