|
8 | 8 | end |
9 | 9 |
|
10 | 10 | describe '#version' do |
| 11 | + before do |
| 12 | + # Reset CI-related environment variables before each test |
| 13 | + ENV['APTIBLE_TOOLBELT'] = nil |
| 14 | + ENV['CI'] = nil |
| 15 | + ENV['GITHUB_ACTIONS'] = nil |
| 16 | + ENV['CIRCLECI'] = nil |
| 17 | + ENV['TRAVIS'] = nil |
| 18 | + ENV['GITLAB_CI'] = nil |
| 19 | + ENV['DRONE'] = nil |
| 20 | + end |
| 21 | + |
11 | 22 | it 'should print the version' do |
12 | | - ClimateControl.modify(APTIBLE_TOOLBELT: nil) do |
13 | | - version = Aptible::CLI::VERSION |
14 | | - subject.version |
15 | | - expect(captured_output_text).to eq("aptible-cli v#{version}\n") |
16 | | - end |
| 23 | + version = Aptible::CLI::VERSION |
| 24 | + subject.version |
| 25 | + expect(captured_output_text).to eq("aptible-cli v#{version}\n") |
17 | 26 | end |
18 | 27 |
|
19 | 28 | it 'should print the version (with toolbelt)' do |
|
23 | 32 | expect(captured_output_text).to eq("aptible-cli v#{version} toolbelt\n") |
24 | 33 | end |
25 | 34 | end |
| 35 | + |
| 36 | + it 'should print the version with CI suffix' do |
| 37 | + ClimateControl.modify(CI: 'true') do |
| 38 | + version = Aptible::CLI::VERSION |
| 39 | + subject.version |
| 40 | + expect(captured_output_text).to eq("aptible-cli v#{version} (CI)\n") |
| 41 | + end |
| 42 | + end |
| 43 | + |
| 44 | + it 'should print the version (with toolbelt and CI)' do |
| 45 | + ClimateControl.modify(APTIBLE_TOOLBELT: '1', CI: 'true') do |
| 46 | + version = Aptible::CLI::VERSION |
| 47 | + subject.version |
| 48 | + expect(captured_output_text).to eq( |
| 49 | + "aptible-cli v#{version} toolbelt (CI)\n" |
| 50 | + ) |
| 51 | + end |
| 52 | + end |
| 53 | + |
| 54 | + it 'should print the version with GHA suffix' do |
| 55 | + ClimateControl.modify(CI: 'true', GITHUB_ACTIONS: 'true') do |
| 56 | + version = Aptible::CLI::VERSION |
| 57 | + subject.version |
| 58 | + expect(captured_output_text).to eq( |
| 59 | + "aptible-cli v#{version} (GitHub Actions)\n" |
| 60 | + ) |
| 61 | + end |
| 62 | + end |
| 63 | + |
| 64 | + it 'should print the version (with toolbelt and GHA)' do |
| 65 | + ClimateControl.modify( |
| 66 | + APTIBLE_TOOLBELT: '1', |
| 67 | + CI: 'true', |
| 68 | + GITHUB_ACTIONS: 'true' |
| 69 | + ) do |
| 70 | + version = Aptible::CLI::VERSION |
| 71 | + subject.version |
| 72 | + expect(captured_output_text).to eq( |
| 73 | + "aptible-cli v#{version} toolbelt (GitHub Actions)\n" |
| 74 | + ) |
| 75 | + end |
| 76 | + end |
| 77 | + |
| 78 | + it 'should print the version with Circle suffix' do |
| 79 | + ClimateControl.modify(CI: 'true', CIRCLECI: 'true') do |
| 80 | + version = Aptible::CLI::VERSION |
| 81 | + subject.version |
| 82 | + expect(captured_output_text).to eq( |
| 83 | + "aptible-cli v#{version} (CircleCI)\n" |
| 84 | + ) |
| 85 | + end |
| 86 | + end |
| 87 | + |
| 88 | + it 'should print the version (with toolbelt and Circle)' do |
| 89 | + ClimateControl.modify( |
| 90 | + APTIBLE_TOOLBELT: '1', |
| 91 | + CI: 'true', |
| 92 | + CIRCLECI: 'true' |
| 93 | + ) do |
| 94 | + version = Aptible::CLI::VERSION |
| 95 | + subject.version |
| 96 | + expect(captured_output_text).to eq( |
| 97 | + "aptible-cli v#{version} toolbelt (CircleCI)\n" |
| 98 | + ) |
| 99 | + end |
| 100 | + end |
| 101 | + |
| 102 | + it 'should print the version with Travis suffix' do |
| 103 | + ClimateControl.modify(CI: 'true', TRAVIS: 'true') do |
| 104 | + version = Aptible::CLI::VERSION |
| 105 | + subject.version |
| 106 | + expect(captured_output_text).to eq( |
| 107 | + "aptible-cli v#{version} (Travis CI)\n" |
| 108 | + ) |
| 109 | + end |
| 110 | + end |
| 111 | + |
| 112 | + it 'should print the version (with toolbelt and Travis)' do |
| 113 | + ClimateControl.modify( |
| 114 | + APTIBLE_TOOLBELT: '1', |
| 115 | + CI: 'true', |
| 116 | + TRAVIS: 'true' |
| 117 | + ) do |
| 118 | + version = Aptible::CLI::VERSION |
| 119 | + subject.version |
| 120 | + expect(captured_output_text).to eq( |
| 121 | + "aptible-cli v#{version} toolbelt (Travis CI)\n" |
| 122 | + ) |
| 123 | + end |
| 124 | + end |
| 125 | + |
| 126 | + it 'should print the version with GitLab suffix' do |
| 127 | + ClimateControl.modify(CI: 'true', GITLAB_CI: 'true') do |
| 128 | + version = Aptible::CLI::VERSION |
| 129 | + subject.version |
| 130 | + expect(captured_output_text).to eq( |
| 131 | + "aptible-cli v#{version} (GitLab CI)\n" |
| 132 | + ) |
| 133 | + end |
| 134 | + end |
| 135 | + |
| 136 | + it 'should print the version (with toolbelt and GitLab)' do |
| 137 | + ClimateControl.modify( |
| 138 | + APTIBLE_TOOLBELT: '1', |
| 139 | + CI: 'true', |
| 140 | + GITLAB_CI: 'true' |
| 141 | + ) do |
| 142 | + version = Aptible::CLI::VERSION |
| 143 | + subject.version |
| 144 | + expect(captured_output_text).to eq( |
| 145 | + "aptible-cli v#{version} toolbelt (GitLab CI)\n" |
| 146 | + ) |
| 147 | + end |
| 148 | + end |
| 149 | + |
| 150 | + it 'should print the version with Harness suffix' do |
| 151 | + ClimateControl.modify(CI: 'true', DRONE: 'true') do |
| 152 | + version = Aptible::CLI::VERSION |
| 153 | + subject.version |
| 154 | + expect(captured_output_text).to eq( |
| 155 | + "aptible-cli v#{version} (Harness)\n" |
| 156 | + ) |
| 157 | + end |
| 158 | + end |
| 159 | + |
| 160 | + it 'should print the version (with toolbelt and Harness)' do |
| 161 | + ClimateControl.modify( |
| 162 | + APTIBLE_TOOLBELT: '1', |
| 163 | + CI: 'true', |
| 164 | + DRONE: 'true' |
| 165 | + ) do |
| 166 | + version = Aptible::CLI::VERSION |
| 167 | + subject.version |
| 168 | + expect(captured_output_text).to eq( |
| 169 | + "aptible-cli v#{version} toolbelt (Harness)\n" |
| 170 | + ) |
| 171 | + end |
| 172 | + end |
26 | 173 | end |
27 | 174 |
|
28 | 175 | describe '#login' do |
|
0 commit comments