|
85 | 85 | expect(err).to include("Cannot specify --all with specific gems") |
86 | 86 | end |
87 | 87 |
|
88 | | - context "when generating bundle binstub outside bundler" do |
89 | | - it "should abort" do |
90 | | - install_gemfile <<-G |
91 | | - source "https://gem.repo1" |
92 | | - gem "myrack" |
93 | | - G |
94 | | - |
95 | | - bundle "binstubs myrack" |
96 | | - |
97 | | - File.open(bundled_app("bin/bundle"), "wb") do |file| |
98 | | - file.print "OMG" |
99 | | - end |
100 | | - |
101 | | - sys_exec "bin/myrackup", raise_on_error: false |
102 | | - |
103 | | - expect(err).to include("was not generated by Bundler") |
104 | | - end |
105 | | - end |
106 | | - |
107 | | - context "the bundle binstub" do |
108 | | - before do |
109 | | - pristine_system_gems "bundler-#{system_bundler_version}" |
110 | | - build_repo2 do |
111 | | - build_gem "myrack", "1.2" do |s| |
112 | | - s.executables = "myrackup" |
113 | | - end |
114 | | - |
115 | | - build_gem "prints_loaded_gems", "1.0" do |s| |
116 | | - s.executables = "print_loaded_gems" |
117 | | - s.bindir = "exe" |
118 | | - s.write "exe/print_loaded_gems", <<~R |
119 | | - #!/usr/bin/env ruby |
120 | | - specs = Gem.loaded_specs.values.reject {|s| s.default_gem? } |
121 | | - puts specs.map(&:full_name).sort.inspect |
122 | | - R |
123 | | - end |
124 | | - |
125 | | - build_bundler locked_bundler_version |
126 | | - end |
127 | | - install_gemfile <<-G |
128 | | - source "https://gem.repo2" |
129 | | - gem "myrack" |
130 | | - gem "prints_loaded_gems" |
131 | | - G |
132 | | - bundle "binstubs bundler myrack prints_loaded_gems" |
133 | | - end |
134 | | - |
135 | | - let(:system_bundler_version) { Bundler::VERSION } |
136 | | - let(:locked_bundler_version) { nil } |
137 | | - let(:lockfile_content) { lockfile.gsub(system_bundler_version, locked_bundler_version) } |
138 | | - |
139 | | - it "runs bundler" do |
140 | | - bundle "install --verbose", bundle_bin: "bin/bundle" |
141 | | - expect(out).to include %(Using bundler #{system_bundler_version}\n) |
142 | | - end |
143 | | - |
144 | | - context "when BUNDLER_VERSION is set" do |
145 | | - it "runs the correct version of bundler" do |
146 | | - bundle "install", env: { "BUNDLER_VERSION" => "999.999.999" }, raise_on_error: false, bundle_bin: "bin/bundle" |
147 | | - expect(exitstatus).to eq(42) |
148 | | - expect(err).to include("Activating bundler (999.999.999) failed:"). |
149 | | - and include("To install the version of bundler this project requires, run `gem install bundler -v '999.999.999'`") |
150 | | - end |
151 | | - |
152 | | - it "runs the correct version of bundler even if a higher version is installed" do |
153 | | - system_gems "bundler-999.999.998", "bundler-999.999.999" |
154 | | - |
155 | | - bundle "install --verbose", env: { "BUNDLER_VERSION" => "999.999.998" }, raise_on_error: false, bundle_bin: "bin/bundle" |
156 | | - expect(out).to include %(Using bundler 999.999.998\n) |
157 | | - end |
158 | | - end |
159 | | - |
160 | | - context "when a lockfile exists with a locked bundler version" do |
161 | | - let(:locked_bundler_version) { "999.999" } |
162 | | - |
163 | | - context "and the version is newer" do |
164 | | - before do |
165 | | - lockfile lockfile_content |
166 | | - end |
167 | | - |
168 | | - it "runs the correct version of bundler" do |
169 | | - bundle "install", raise_on_error: false, bundle_bin: "bin/bundle" |
170 | | - expect(exitstatus).to eq(42) |
171 | | - expect(err).to include("Activating bundler (~> 999.999) failed:"). |
172 | | - and include("To install the version of bundler this project requires, run `gem install bundler -v '~> 999.999'`") |
173 | | - end |
174 | | - end |
175 | | - |
176 | | - context "and the version is newer when given `gems.rb` and `gems.locked`" do |
177 | | - before do |
178 | | - gemfile bundled_app("gems.rb"), gemfile |
179 | | - lockfile bundled_app("gems.locked"), lockfile_content |
180 | | - end |
181 | | - |
182 | | - it "runs the correct version of bundler" do |
183 | | - bundle "install", env: { "BUNDLE_GEMFILE" => "gems.rb" }, raise_on_error: false, bundle_bin: "bin/bundle" |
184 | | - |
185 | | - expect(exitstatus).to eq(42) |
186 | | - expect(err).to include("Activating bundler (~> 999.999) failed:"). |
187 | | - and include("To install the version of bundler this project requires, run `gem install bundler -v '~> 999.999'`") |
188 | | - end |
189 | | - end |
190 | | - |
191 | | - context "and the version is older and a different major" do |
192 | | - let(:system_bundler_version) { "55" } |
193 | | - let(:locked_bundler_version) { "44" } |
194 | | - |
195 | | - before do |
196 | | - lockfile lockfile_content |
197 | | - end |
198 | | - |
199 | | - it "runs the correct version of bundler" do |
200 | | - bundle "install", raise_on_error: false, bundle_bin: "bin/bundle" |
201 | | - expect(exitstatus).to eq(42) |
202 | | - expect(err).to include("Activating bundler (~> 44.0) failed:"). |
203 | | - and include("To install the version of bundler this project requires, run `gem install bundler -v '~> 44.0'`") |
204 | | - end |
205 | | - end |
206 | | - |
207 | | - context "and the version is older and a different major when given `gems.rb` and `gems.locked`" do |
208 | | - let(:system_bundler_version) { "55" } |
209 | | - let(:locked_bundler_version) { "44" } |
210 | | - |
211 | | - before do |
212 | | - gemfile bundled_app("gems.rb"), gemfile |
213 | | - lockfile bundled_app("gems.locked"), lockfile_content |
214 | | - end |
215 | | - |
216 | | - it "runs the correct version of bundler" do |
217 | | - bundle "install", env: { "BUNDLE_GEMFILE" => "gems.rb" }, raise_on_error: false, bundle_bin: "bin/bundle" |
218 | | - expect(exitstatus).to eq(42) |
219 | | - expect(err).to include("Activating bundler (~> 44.0) failed:"). |
220 | | - and include("To install the version of bundler this project requires, run `gem install bundler -v '~> 44.0'`") |
221 | | - end |
222 | | - end |
223 | | - |
224 | | - context "and the version is older and the same major" do |
225 | | - let(:system_bundler_version) { "2.999.999" } |
226 | | - let(:locked_bundler_version) { "2.3.0" } |
227 | | - |
228 | | - before do |
229 | | - lockfile lockfile_content |
230 | | - end |
231 | | - |
232 | | - it "installs and runs the exact version of bundler" do |
233 | | - bundle "install --verbose", bundle_bin: "bin/bundle" |
234 | | - expect(exitstatus).not_to eq(42) |
235 | | - expect(out).to include("Bundler 2.999.999 is running, but your lockfile was generated with 2.3.0. Installing Bundler 2.3.0 and restarting using that version.") |
236 | | - expect(out).to include("Using bundler 2.3.0") |
237 | | - expect(err).not_to include("Activating bundler (~> 2.3.0) failed:") |
238 | | - end |
239 | | - end |
240 | | - |
241 | | - context "and the version is a pre-releaser" do |
242 | | - let(:system_bundler_version) { "55" } |
243 | | - let(:locked_bundler_version) { "2.12.0.a" } |
244 | | - |
245 | | - before do |
246 | | - lockfile lockfile_content |
247 | | - end |
248 | | - |
249 | | - it "runs the correct version of bundler when the version is a pre-release" do |
250 | | - bundle "install", raise_on_error: false, bundle_bin: "bin/bundle" |
251 | | - expect(exitstatus).to eq(42) |
252 | | - expect(err).to include("Activating bundler (~> 2.12.a) failed:"). |
253 | | - and include("To install the version of bundler this project requires, run `gem install bundler -v '~> 2.12.a'`") |
254 | | - end |
255 | | - end |
256 | | - end |
257 | | - |
258 | | - context "when update --bundler is called" do |
259 | | - it "calls through to the latest bundler version" do |
260 | | - bundle "update --bundler --verbose", bundle_bin: "bin/bundle" |
261 | | - using_bundler_line = /Using bundler ([\w\.]+)\n/.match(out) |
262 | | - expect(using_bundler_line).to_not be_nil |
263 | | - latest_version = using_bundler_line[1] |
264 | | - expect(Gem::Version.new(latest_version)).to be >= Gem::Version.new(system_bundler_version) |
265 | | - end |
266 | | - |
267 | | - it "calls through to the explicit bundler version" do |
268 | | - bundle "update --bundler=999.999.999", raise_on_error: false, bundle_bin: "bin/bundle" |
269 | | - expect(exitstatus).to eq(42) |
270 | | - expect(err).to include("Activating bundler (999.999.999) failed:"). |
271 | | - and include("To install the version of bundler this project requires, run `gem install bundler -v '999.999.999'`") |
272 | | - end |
273 | | - end |
274 | | - |
275 | | - context "without a lockfile" do |
276 | | - it "falls back to the latest installed bundler" do |
277 | | - FileUtils.rm bundled_app_lock |
278 | | - bundle "install --verbose", bundle_bin: "bin/bundle" |
279 | | - expect(out).to include "Using bundler #{system_bundler_version}\n" |
280 | | - end |
281 | | - end |
282 | | - |
283 | | - context "using another binstub" do |
284 | | - it "loads all gems" do |
285 | | - sys_exec bundled_app("bin/print_loaded_gems").to_s |
286 | | - expect(out).to eq %(["bundler-#{Bundler::VERSION}", "myrack-1.2", "prints_loaded_gems-1.0"]) |
287 | | - end |
288 | | - |
289 | | - context "when requesting a different bundler version" do |
290 | | - before { lockfile lockfile.gsub(Bundler::VERSION, "999.999.999") } |
291 | | - |
292 | | - it "attempts to load that version" do |
293 | | - sys_exec bundled_app("bin/myrackup").to_s, raise_on_error: false |
294 | | - expect(exitstatus).to eq(42) |
295 | | - expect(err).to include("Activating bundler (~> 999.999) failed:"). |
296 | | - and include("To install the version of bundler this project requires, run `gem install bundler -v '~> 999.999'`") |
297 | | - end |
298 | | - end |
299 | | - end |
300 | | - end |
301 | | - |
302 | 88 | it "installs binstubs from git gems" do |
303 | 89 | FileUtils.mkdir_p(lib_path("foo/bin")) |
304 | 90 | FileUtils.touch(lib_path("foo/bin/foo")) |
|
0 commit comments