rkh-bundler 1.2.0.pre
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +22 -0
- data/.travis.yml +42 -0
- data/CHANGELOG.md +1105 -0
- data/ISSUES.md +67 -0
- data/LICENSE +23 -0
- data/README.md +31 -0
- data/Rakefile +208 -0
- data/UPGRADING.md +103 -0
- data/bin/bundle +31 -0
- data/bundler.gemspec +31 -0
- data/lib/bundler.rb +353 -0
- data/lib/bundler/capistrano.rb +11 -0
- data/lib/bundler/cli.rb +693 -0
- data/lib/bundler/definition.rb +568 -0
- data/lib/bundler/dep_proxy.rb +43 -0
- data/lib/bundler/dependency.rb +134 -0
- data/lib/bundler/deployment.rb +58 -0
- data/lib/bundler/dsl.rb +256 -0
- data/lib/bundler/endpoint_specification.rb +78 -0
- data/lib/bundler/environment.rb +47 -0
- data/lib/bundler/fetcher.rb +225 -0
- data/lib/bundler/gem_helper.rb +162 -0
- data/lib/bundler/gem_helpers.rb +23 -0
- data/lib/bundler/gem_installer.rb +9 -0
- data/lib/bundler/gem_tasks.rb +2 -0
- data/lib/bundler/graph.rb +148 -0
- data/lib/bundler/index.rb +187 -0
- data/lib/bundler/installer.rb +190 -0
- data/lib/bundler/lazy_specification.rb +79 -0
- data/lib/bundler/lockfile_parser.rb +127 -0
- data/lib/bundler/match_platform.rb +13 -0
- data/lib/bundler/psyched_yaml.rb +15 -0
- data/lib/bundler/remote_specification.rb +57 -0
- data/lib/bundler/resolver.rb +486 -0
- data/lib/bundler/ruby_version.rb +94 -0
- data/lib/bundler/rubygems_ext.rb +153 -0
- data/lib/bundler/rubygems_integration.rb +394 -0
- data/lib/bundler/runtime.rb +233 -0
- data/lib/bundler/settings.rb +128 -0
- data/lib/bundler/setup.rb +23 -0
- data/lib/bundler/shared_helpers.rb +71 -0
- data/lib/bundler/source.rb +869 -0
- data/lib/bundler/spec_set.rb +137 -0
- data/lib/bundler/templates/Executable +16 -0
- data/lib/bundler/templates/Executable.standalone +12 -0
- data/lib/bundler/templates/Gemfile +4 -0
- data/lib/bundler/templates/newgem/Gemfile.tt +4 -0
- data/lib/bundler/templates/newgem/LICENSE.tt +22 -0
- data/lib/bundler/templates/newgem/README.md.tt +29 -0
- data/lib/bundler/templates/newgem/Rakefile.tt +2 -0
- data/lib/bundler/templates/newgem/bin/newgem.tt +3 -0
- data/lib/bundler/templates/newgem/gitignore.tt +17 -0
- data/lib/bundler/templates/newgem/lib/newgem.rb.tt +9 -0
- data/lib/bundler/templates/newgem/lib/newgem/version.rb.tt +7 -0
- data/lib/bundler/templates/newgem/newgem.gemspec.tt +17 -0
- data/lib/bundler/ui.rb +88 -0
- data/lib/bundler/vendor/net/http/faster.rb +27 -0
- data/lib/bundler/vendor/net/http/persistent.rb +468 -0
- data/lib/bundler/vendor/thor.rb +358 -0
- data/lib/bundler/vendor/thor/actions.rb +314 -0
- data/lib/bundler/vendor/thor/actions/create_file.rb +105 -0
- data/lib/bundler/vendor/thor/actions/create_link.rb +57 -0
- data/lib/bundler/vendor/thor/actions/directory.rb +93 -0
- data/lib/bundler/vendor/thor/actions/empty_directory.rb +134 -0
- data/lib/bundler/vendor/thor/actions/file_manipulation.rb +270 -0
- data/lib/bundler/vendor/thor/actions/inject_into_file.rb +109 -0
- data/lib/bundler/vendor/thor/base.rb +576 -0
- data/lib/bundler/vendor/thor/core_ext/file_binary_read.rb +9 -0
- data/lib/bundler/vendor/thor/core_ext/hash_with_indifferent_access.rb +75 -0
- data/lib/bundler/vendor/thor/core_ext/ordered_hash.rb +100 -0
- data/lib/bundler/vendor/thor/error.rb +30 -0
- data/lib/bundler/vendor/thor/group.rb +273 -0
- data/lib/bundler/vendor/thor/invocation.rb +168 -0
- data/lib/bundler/vendor/thor/parser.rb +4 -0
- data/lib/bundler/vendor/thor/parser/argument.rb +67 -0
- data/lib/bundler/vendor/thor/parser/arguments.rb +161 -0
- data/lib/bundler/vendor/thor/parser/option.rb +120 -0
- data/lib/bundler/vendor/thor/parser/options.rb +172 -0
- data/lib/bundler/vendor/thor/rake_compat.rb +66 -0
- data/lib/bundler/vendor/thor/runner.rb +309 -0
- data/lib/bundler/vendor/thor/shell.rb +88 -0
- data/lib/bundler/vendor/thor/shell/basic.rb +302 -0
- data/lib/bundler/vendor/thor/shell/color.rb +108 -0
- data/lib/bundler/vendor/thor/shell/html.rb +121 -0
- data/lib/bundler/vendor/thor/task.rb +113 -0
- data/lib/bundler/vendor/thor/util.rb +229 -0
- data/lib/bundler/vendor/thor/version.rb +3 -0
- data/lib/bundler/vendored_thor.rb +7 -0
- data/lib/bundler/version.rb +6 -0
- data/lib/bundler/vlad.rb +11 -0
- data/man/bundle-config.ronn +130 -0
- data/man/bundle-exec.ronn +111 -0
- data/man/bundle-install.ronn +335 -0
- data/man/bundle-package.ronn +59 -0
- data/man/bundle-update.ronn +176 -0
- data/man/bundle.ronn +83 -0
- data/man/gemfile.5.ronn +324 -0
- data/man/index.txt +6 -0
- data/spec/bundler/dsl_spec.rb +48 -0
- data/spec/bundler/gem_helper_spec.rb +174 -0
- data/spec/bundler/source_spec.rb +25 -0
- data/spec/cache/gems_spec.rb +239 -0
- data/spec/cache/git_spec.rb +124 -0
- data/spec/cache/path_spec.rb +103 -0
- data/spec/cache/platform_spec.rb +57 -0
- data/spec/install/deploy_spec.rb +211 -0
- data/spec/install/gems/c_ext_spec.rb +48 -0
- data/spec/install/gems/dependency_api_spec.rb +402 -0
- data/spec/install/gems/env_spec.rb +107 -0
- data/spec/install/gems/flex_spec.rb +313 -0
- data/spec/install/gems/groups_spec.rb +268 -0
- data/spec/install/gems/packed_spec.rb +84 -0
- data/spec/install/gems/platform_spec.rb +208 -0
- data/spec/install/gems/post_install_spec.rb +47 -0
- data/spec/install/gems/resolving_spec.rb +72 -0
- data/spec/install/gems/simple_case_spec.rb +814 -0
- data/spec/install/gems/standalone_spec.rb +260 -0
- data/spec/install/gems/sudo_spec.rb +74 -0
- data/spec/install/gems/win32_spec.rb +26 -0
- data/spec/install/gemspec_spec.rb +170 -0
- data/spec/install/git_spec.rb +796 -0
- data/spec/install/invalid_spec.rb +35 -0
- data/spec/install/path_spec.rb +405 -0
- data/spec/install/upgrade_spec.rb +26 -0
- data/spec/lock/git_spec.rb +35 -0
- data/spec/lock/lockfile_spec.rb +809 -0
- data/spec/other/check_spec.rb +265 -0
- data/spec/other/clean_spec.rb +492 -0
- data/spec/other/config_spec.rb +138 -0
- data/spec/other/console_spec.rb +54 -0
- data/spec/other/exec_spec.rb +229 -0
- data/spec/other/ext_spec.rb +37 -0
- data/spec/other/help_spec.rb +39 -0
- data/spec/other/init_spec.rb +40 -0
- data/spec/other/newgem_spec.rb +87 -0
- data/spec/other/open_spec.rb +35 -0
- data/spec/other/outdated_spec.rb +93 -0
- data/spec/other/platform_spec.rb +881 -0
- data/spec/other/show_spec.rb +88 -0
- data/spec/quality_spec.rb +62 -0
- data/spec/realworld/edgecases_spec.rb +177 -0
- data/spec/resolver/basic_spec.rb +20 -0
- data/spec/resolver/platform_spec.rb +82 -0
- data/spec/runtime/executable_spec.rb +120 -0
- data/spec/runtime/load_spec.rb +107 -0
- data/spec/runtime/platform_spec.rb +90 -0
- data/spec/runtime/require_spec.rb +261 -0
- data/spec/runtime/setup_spec.rb +755 -0
- data/spec/runtime/with_clean_env_spec.rb +80 -0
- data/spec/spec_helper.rb +98 -0
- data/spec/support/artifice/endopint_marshal_fail_basic_authentication.rb +13 -0
- data/spec/support/artifice/endpoint.rb +54 -0
- data/spec/support/artifice/endpoint_500.rb +37 -0
- data/spec/support/artifice/endpoint_api_missing.rb +16 -0
- data/spec/support/artifice/endpoint_basic_authentication.rb +13 -0
- data/spec/support/artifice/endpoint_extra.rb +27 -0
- data/spec/support/artifice/endpoint_extra_missing.rb +15 -0
- data/spec/support/artifice/endpoint_fallback.rb +18 -0
- data/spec/support/artifice/endpoint_marshal_fail.rb +11 -0
- data/spec/support/artifice/endpoint_redirect.rb +15 -0
- data/spec/support/builders.rb +604 -0
- data/spec/support/fakeweb/rack-1.0.0.marshal +2 -0
- data/spec/support/fakeweb/windows.rb +23 -0
- data/spec/support/helpers.rb +317 -0
- data/spec/support/indexes.rb +112 -0
- data/spec/support/matchers.rb +77 -0
- data/spec/support/path.rb +73 -0
- data/spec/support/platforms.rb +86 -0
- data/spec/support/ruby_ext.rb +20 -0
- data/spec/support/rubygems_ext.rb +37 -0
- data/spec/support/rubygems_hax/platform.rb +22 -0
- data/spec/support/sudo.rb +21 -0
- data/spec/update/gems_spec.rb +134 -0
- data/spec/update/git_spec.rb +196 -0
- data/spec/update/source_spec.rb +51 -0
- metadata +338 -0
@@ -0,0 +1,755 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe "Bundler.setup" do
|
4
|
+
describe "with no arguments" do
|
5
|
+
it "makes all groups available" do
|
6
|
+
install_gemfile <<-G
|
7
|
+
source "file://#{gem_repo1}"
|
8
|
+
gem "rack", :group => :test
|
9
|
+
G
|
10
|
+
|
11
|
+
ruby <<-RUBY
|
12
|
+
require 'rubygems'
|
13
|
+
require 'bundler'
|
14
|
+
Bundler.setup
|
15
|
+
|
16
|
+
require 'rack'
|
17
|
+
puts RACK
|
18
|
+
RUBY
|
19
|
+
err.should eq("")
|
20
|
+
out.should eq("1.0.0")
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe "when called with groups" do
|
25
|
+
before(:each) do
|
26
|
+
install_gemfile <<-G
|
27
|
+
source "file://#{gem_repo1}"
|
28
|
+
gem "yard"
|
29
|
+
gem "rack", :group => :test
|
30
|
+
G
|
31
|
+
end
|
32
|
+
|
33
|
+
it "doesn't make all groups available" do
|
34
|
+
ruby <<-RUBY
|
35
|
+
require 'rubygems'
|
36
|
+
require 'bundler'
|
37
|
+
Bundler.setup(:default)
|
38
|
+
|
39
|
+
begin
|
40
|
+
require 'rack'
|
41
|
+
rescue LoadError
|
42
|
+
puts "WIN"
|
43
|
+
end
|
44
|
+
RUBY
|
45
|
+
err.should eq("")
|
46
|
+
out.should eq("WIN")
|
47
|
+
end
|
48
|
+
|
49
|
+
it "leaves all groups available if they were already" do
|
50
|
+
ruby <<-RUBY
|
51
|
+
require 'rubygems'
|
52
|
+
require 'bundler'
|
53
|
+
Bundler.setup
|
54
|
+
Bundler.setup(:default)
|
55
|
+
|
56
|
+
require 'rack'
|
57
|
+
puts RACK
|
58
|
+
RUBY
|
59
|
+
err.should eq("")
|
60
|
+
out.should eq("1.0.0")
|
61
|
+
end
|
62
|
+
|
63
|
+
it "leaves :default available if setup is called twice" do
|
64
|
+
ruby <<-RUBY
|
65
|
+
require 'rubygems'
|
66
|
+
require 'bundler'
|
67
|
+
Bundler.setup(:default)
|
68
|
+
Bundler.setup(:default, :test)
|
69
|
+
|
70
|
+
begin
|
71
|
+
require 'yard'
|
72
|
+
puts "WIN"
|
73
|
+
rescue LoadError
|
74
|
+
puts "FAIL"
|
75
|
+
end
|
76
|
+
RUBY
|
77
|
+
err.should eq("")
|
78
|
+
out.should match("WIN")
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
it "raises if the Gemfile was not yet installed" do
|
83
|
+
gemfile <<-G
|
84
|
+
source "file://#{gem_repo1}"
|
85
|
+
gem "rack"
|
86
|
+
G
|
87
|
+
|
88
|
+
ruby <<-R
|
89
|
+
require 'rubygems'
|
90
|
+
require 'bundler'
|
91
|
+
|
92
|
+
begin
|
93
|
+
Bundler.setup
|
94
|
+
puts "FAIL"
|
95
|
+
rescue Bundler::GemNotFound
|
96
|
+
puts "WIN"
|
97
|
+
end
|
98
|
+
R
|
99
|
+
|
100
|
+
out.should == "WIN"
|
101
|
+
end
|
102
|
+
|
103
|
+
it "doesn't create a Gemfile.lock if the setup fails" do
|
104
|
+
gemfile <<-G
|
105
|
+
source "file://#{gem_repo1}"
|
106
|
+
gem "rack"
|
107
|
+
G
|
108
|
+
|
109
|
+
ruby <<-R, :expect_err => true
|
110
|
+
require 'rubygems'
|
111
|
+
require 'bundler'
|
112
|
+
|
113
|
+
Bundler.setup
|
114
|
+
R
|
115
|
+
|
116
|
+
bundled_app("Gemfile.lock").should_not exist
|
117
|
+
end
|
118
|
+
|
119
|
+
it "doesn't change the Gemfile.lock if the setup fails" do
|
120
|
+
install_gemfile <<-G
|
121
|
+
source "file://#{gem_repo1}"
|
122
|
+
gem "rack"
|
123
|
+
G
|
124
|
+
|
125
|
+
lockfile = File.read(bundled_app("Gemfile.lock"))
|
126
|
+
|
127
|
+
gemfile <<-G
|
128
|
+
source "file://#{gem_repo1}"
|
129
|
+
gem "rack"
|
130
|
+
gem "nosuchgem", "10.0"
|
131
|
+
G
|
132
|
+
|
133
|
+
ruby <<-R, :expect_err => true
|
134
|
+
require 'rubygems'
|
135
|
+
require 'bundler'
|
136
|
+
|
137
|
+
Bundler.setup
|
138
|
+
R
|
139
|
+
|
140
|
+
File.read(bundled_app("Gemfile.lock")).should == lockfile
|
141
|
+
end
|
142
|
+
|
143
|
+
it "makes a Gemfile.lock if setup succeeds" do
|
144
|
+
install_gemfile <<-G
|
145
|
+
source "file://#{gem_repo1}"
|
146
|
+
gem "rack"
|
147
|
+
G
|
148
|
+
|
149
|
+
File.read(bundled_app("Gemfile.lock"))
|
150
|
+
|
151
|
+
FileUtils.rm(bundled_app("Gemfile.lock"))
|
152
|
+
|
153
|
+
run "1"
|
154
|
+
bundled_app("Gemfile.lock").should exist
|
155
|
+
end
|
156
|
+
|
157
|
+
it "uses BUNDLE_GEMFILE to locate the gemfile if present" do
|
158
|
+
gemfile <<-G
|
159
|
+
source "file://#{gem_repo1}"
|
160
|
+
gem "rack"
|
161
|
+
G
|
162
|
+
|
163
|
+
gemfile bundled_app('4realz'), <<-G
|
164
|
+
source "file://#{gem_repo1}"
|
165
|
+
gem "activesupport", "2.3.5"
|
166
|
+
G
|
167
|
+
|
168
|
+
ENV['BUNDLE_GEMFILE'] = bundled_app('4realz').to_s
|
169
|
+
bundle :install
|
170
|
+
|
171
|
+
should_be_installed "activesupport 2.3.5"
|
172
|
+
end
|
173
|
+
|
174
|
+
it "prioritizes gems in BUNDLE_PATH over gems in GEM_HOME" do
|
175
|
+
ENV['BUNDLE_PATH'] = bundled_app('.bundle').to_s
|
176
|
+
install_gemfile <<-G
|
177
|
+
source "file://#{gem_repo1}"
|
178
|
+
gem "rack", "1.0.0"
|
179
|
+
G
|
180
|
+
|
181
|
+
build_gem "rack", "1.0", :to_system => true do |s|
|
182
|
+
s.write "lib/rack.rb", "RACK = 'FAIL'"
|
183
|
+
end
|
184
|
+
|
185
|
+
should_be_installed "rack 1.0.0"
|
186
|
+
end
|
187
|
+
|
188
|
+
describe "integrate with rubygems" do
|
189
|
+
describe "by replacing #gem" do
|
190
|
+
before :each do
|
191
|
+
install_gemfile <<-G
|
192
|
+
source "file://#{gem_repo1}"
|
193
|
+
gem "rack", "0.9.1"
|
194
|
+
G
|
195
|
+
end
|
196
|
+
|
197
|
+
it "replaces #gem but raises when the gem is missing" do
|
198
|
+
run <<-R
|
199
|
+
begin
|
200
|
+
gem "activesupport"
|
201
|
+
puts "FAIL"
|
202
|
+
rescue LoadError
|
203
|
+
puts "WIN"
|
204
|
+
end
|
205
|
+
R
|
206
|
+
|
207
|
+
out.should == "WIN"
|
208
|
+
end
|
209
|
+
|
210
|
+
it "version_requirement is now deprecated in rubygems 1.4.0+ when gem is missing" do
|
211
|
+
run <<-R, :expect_err => true
|
212
|
+
begin
|
213
|
+
gem "activesupport"
|
214
|
+
puts "FAIL"
|
215
|
+
rescue LoadError
|
216
|
+
puts "WIN"
|
217
|
+
end
|
218
|
+
R
|
219
|
+
|
220
|
+
err.should be_empty
|
221
|
+
end
|
222
|
+
|
223
|
+
it "replaces #gem but raises when the version is wrong" do
|
224
|
+
run <<-R
|
225
|
+
begin
|
226
|
+
gem "rack", "1.0.0"
|
227
|
+
puts "FAIL"
|
228
|
+
rescue LoadError
|
229
|
+
puts "WIN"
|
230
|
+
end
|
231
|
+
R
|
232
|
+
|
233
|
+
out.should == "WIN"
|
234
|
+
end
|
235
|
+
|
236
|
+
it "version_requirement is now deprecated in rubygems 1.4.0+ when the version is wrong" do
|
237
|
+
run <<-R, :expect_err => true
|
238
|
+
begin
|
239
|
+
gem "rack", "1.0.0"
|
240
|
+
puts "FAIL"
|
241
|
+
rescue LoadError
|
242
|
+
puts "WIN"
|
243
|
+
end
|
244
|
+
R
|
245
|
+
|
246
|
+
err.should be_empty
|
247
|
+
end
|
248
|
+
end
|
249
|
+
|
250
|
+
describe "by hiding system gems" do
|
251
|
+
before :each do
|
252
|
+
system_gems "activesupport-2.3.5"
|
253
|
+
install_gemfile <<-G
|
254
|
+
source "file://#{gem_repo1}"
|
255
|
+
gem "yard"
|
256
|
+
G
|
257
|
+
end
|
258
|
+
|
259
|
+
it "removes system gems from Gem.source_index" do
|
260
|
+
run "require 'yard'"
|
261
|
+
out.should == "bundler-#{Bundler::VERSION}\nyard-1.0"
|
262
|
+
end
|
263
|
+
|
264
|
+
context "when the ruby stdlib is a substring of Gem.path" do
|
265
|
+
it "does not reject the stdlib from $LOAD_PATH" do
|
266
|
+
substring = "/" + $LOAD_PATH.find{|p| p =~ /vendor_ruby/ }.split("/")[2]
|
267
|
+
run "puts 'worked!'", :env => {"GEM_PATH" => substring}
|
268
|
+
out.should == "worked!"
|
269
|
+
end
|
270
|
+
end
|
271
|
+
end
|
272
|
+
end
|
273
|
+
|
274
|
+
describe "with paths" do
|
275
|
+
it "activates the gems in the path source" do
|
276
|
+
system_gems "rack-1.0.0"
|
277
|
+
|
278
|
+
build_lib "rack", "1.0.0" do |s|
|
279
|
+
s.write "lib/rack.rb", "puts 'WIN'"
|
280
|
+
end
|
281
|
+
|
282
|
+
gemfile <<-G
|
283
|
+
path "#{lib_path('rack-1.0.0')}"
|
284
|
+
source "file://#{gem_repo1}"
|
285
|
+
gem "rack"
|
286
|
+
G
|
287
|
+
|
288
|
+
run "require 'rack'"
|
289
|
+
out.should == "WIN"
|
290
|
+
end
|
291
|
+
end
|
292
|
+
|
293
|
+
describe "with git" do
|
294
|
+
before do
|
295
|
+
build_git "rack", "1.0.0"
|
296
|
+
|
297
|
+
gemfile <<-G
|
298
|
+
gem "rack", :git => "#{lib_path('rack-1.0.0')}"
|
299
|
+
G
|
300
|
+
end
|
301
|
+
|
302
|
+
it "provides a useful exception when the git repo is not checked out yet" do
|
303
|
+
run "1", :expect_err => true
|
304
|
+
err.should include("#{lib_path('rack-1.0.0')} (at master) is not checked out. Please run `bundle install`")
|
305
|
+
end
|
306
|
+
|
307
|
+
it "does not hit the git binary if the lockfile is available and up to date" do
|
308
|
+
bundle "install"
|
309
|
+
|
310
|
+
break_git!
|
311
|
+
|
312
|
+
ruby <<-R
|
313
|
+
require 'rubygems'
|
314
|
+
require 'bundler'
|
315
|
+
|
316
|
+
begin
|
317
|
+
Bundler.setup
|
318
|
+
puts "WIN"
|
319
|
+
rescue Exception => e
|
320
|
+
puts "FAIL"
|
321
|
+
end
|
322
|
+
R
|
323
|
+
|
324
|
+
out.should == "WIN"
|
325
|
+
end
|
326
|
+
|
327
|
+
it "provides a good exception if the lockfile is unavailable" do
|
328
|
+
bundle "install"
|
329
|
+
|
330
|
+
FileUtils.rm(bundled_app("Gemfile.lock"))
|
331
|
+
|
332
|
+
break_git!
|
333
|
+
|
334
|
+
ruby <<-R
|
335
|
+
require "rubygems"
|
336
|
+
require "bundler"
|
337
|
+
|
338
|
+
begin
|
339
|
+
Bundler.setup
|
340
|
+
puts "FAIL"
|
341
|
+
rescue Bundler::GitError => e
|
342
|
+
puts e.message
|
343
|
+
end
|
344
|
+
R
|
345
|
+
|
346
|
+
run "puts 'FAIL'", :expect_err => true
|
347
|
+
|
348
|
+
err.should_not include "This is not the git you are looking for"
|
349
|
+
end
|
350
|
+
|
351
|
+
it "works even when the cache directory has been deleted" do
|
352
|
+
bundle "install --path vendor/bundle"
|
353
|
+
FileUtils.rm_rf vendored_gems('cache')
|
354
|
+
should_be_installed "rack 1.0.0"
|
355
|
+
end
|
356
|
+
|
357
|
+
it "does not randomly change the path when specifying --path and the bundle directory becomes read only" do
|
358
|
+
begin
|
359
|
+
bundle "install --path vendor/bundle"
|
360
|
+
|
361
|
+
Dir["**/*"].each do |f|
|
362
|
+
File.directory?(f) ?
|
363
|
+
File.chmod(0555, f) :
|
364
|
+
File.chmod(0444, f)
|
365
|
+
end
|
366
|
+
should_be_installed "rack 1.0.0"
|
367
|
+
ensure
|
368
|
+
Dir["**/*"].each do |f|
|
369
|
+
File.directory?(f) ?
|
370
|
+
File.chmod(0755, f) :
|
371
|
+
File.chmod(0644, f)
|
372
|
+
end
|
373
|
+
end
|
374
|
+
end
|
375
|
+
end
|
376
|
+
|
377
|
+
describe "when excluding groups" do
|
378
|
+
it "doesn't change the resolve if --without is used" do
|
379
|
+
install_gemfile <<-G, :without => :rails
|
380
|
+
source "file://#{gem_repo1}"
|
381
|
+
gem "activesupport"
|
382
|
+
|
383
|
+
group :rails do
|
384
|
+
gem "rails", "2.3.2"
|
385
|
+
end
|
386
|
+
G
|
387
|
+
|
388
|
+
install_gems "activesupport-2.3.5"
|
389
|
+
|
390
|
+
should_be_installed "activesupport 2.3.2", :groups => :default
|
391
|
+
end
|
392
|
+
|
393
|
+
it "remembers --without and does not bail on bare Bundler.setup" do
|
394
|
+
install_gemfile <<-G, :without => :rails
|
395
|
+
source "file://#{gem_repo1}"
|
396
|
+
gem "activesupport"
|
397
|
+
|
398
|
+
group :rails do
|
399
|
+
gem "rails", "2.3.2"
|
400
|
+
end
|
401
|
+
G
|
402
|
+
|
403
|
+
install_gems "activesupport-2.3.5"
|
404
|
+
|
405
|
+
should_be_installed "activesupport 2.3.2"
|
406
|
+
end
|
407
|
+
|
408
|
+
it "remembers --without and does not include groups passed to Bundler.setup" do
|
409
|
+
install_gemfile <<-G, :without => :rails
|
410
|
+
source "file://#{gem_repo1}"
|
411
|
+
gem "activesupport"
|
412
|
+
|
413
|
+
group :rack do
|
414
|
+
gem "rack"
|
415
|
+
end
|
416
|
+
|
417
|
+
group :rails do
|
418
|
+
gem "rails", "2.3.2"
|
419
|
+
end
|
420
|
+
G
|
421
|
+
|
422
|
+
should_not_be_installed "activesupport 2.3.2", :groups => :rack
|
423
|
+
should_be_installed "rack 1.0.0", :groups => :rack
|
424
|
+
end
|
425
|
+
end
|
426
|
+
|
427
|
+
# Unfortunately, gem_prelude does not record the information about
|
428
|
+
# activated gems, so this test cannot work on 1.9 :(
|
429
|
+
if RUBY_VERSION < "1.9"
|
430
|
+
describe "preactivated gems" do
|
431
|
+
it "raises an exception if a pre activated gem conflicts with the bundle" do
|
432
|
+
system_gems "thin-1.0", "rack-1.0.0"
|
433
|
+
build_gem "thin", "1.1", :to_system => true do |s|
|
434
|
+
s.add_dependency "rack"
|
435
|
+
end
|
436
|
+
|
437
|
+
gemfile <<-G
|
438
|
+
gem "thin", "1.0"
|
439
|
+
G
|
440
|
+
|
441
|
+
ruby <<-R
|
442
|
+
require 'rubygems'
|
443
|
+
gem "thin"
|
444
|
+
require 'bundler'
|
445
|
+
begin
|
446
|
+
Bundler.setup
|
447
|
+
puts "FAIL"
|
448
|
+
rescue Gem::LoadError => e
|
449
|
+
puts e.message
|
450
|
+
end
|
451
|
+
R
|
452
|
+
|
453
|
+
out.should == "You have already activated thin 1.1, but your Gemfile requires thin 1.0. Using bundle exec may solve this."
|
454
|
+
end
|
455
|
+
|
456
|
+
it "version_requirement is now deprecated in rubygems 1.4.0+" do
|
457
|
+
system_gems "thin-1.0", "rack-1.0.0"
|
458
|
+
build_gem "thin", "1.1", :to_system => true do |s|
|
459
|
+
s.add_dependency "rack"
|
460
|
+
end
|
461
|
+
|
462
|
+
gemfile <<-G
|
463
|
+
gem "thin", "1.0"
|
464
|
+
G
|
465
|
+
|
466
|
+
ruby <<-R, :expect_err => true
|
467
|
+
require 'rubygems'
|
468
|
+
gem "thin"
|
469
|
+
require 'bundler'
|
470
|
+
begin
|
471
|
+
Bundler.setup
|
472
|
+
puts "FAIL"
|
473
|
+
rescue Gem::LoadError => e
|
474
|
+
puts e.message
|
475
|
+
end
|
476
|
+
R
|
477
|
+
|
478
|
+
err.should be_empty
|
479
|
+
end
|
480
|
+
end
|
481
|
+
end
|
482
|
+
|
483
|
+
# Rubygems returns loaded_from as a string
|
484
|
+
it "has loaded_from as a string on all specs" do
|
485
|
+
build_git "foo"
|
486
|
+
build_git "no-gemspec", :gemspec => false
|
487
|
+
|
488
|
+
install_gemfile <<-G
|
489
|
+
source "file://#{gem_repo1}"
|
490
|
+
gem "rack"
|
491
|
+
gem "foo", :git => "#{lib_path('foo-1.0')}"
|
492
|
+
gem "no-gemspec", "1.0", :git => "#{lib_path('no-gemspec-1.0')}"
|
493
|
+
G
|
494
|
+
|
495
|
+
run <<-R
|
496
|
+
Gem.loaded_specs.each do |n, s|
|
497
|
+
puts "FAIL" unless String === s.loaded_from
|
498
|
+
end
|
499
|
+
R
|
500
|
+
|
501
|
+
out.should be_empty
|
502
|
+
end
|
503
|
+
|
504
|
+
it "ignores empty gem paths" do
|
505
|
+
install_gemfile <<-G
|
506
|
+
source "file://#{gem_repo1}"
|
507
|
+
gem "rack"
|
508
|
+
G
|
509
|
+
|
510
|
+
ENV["GEM_HOME"] = ""
|
511
|
+
bundle %{exec ruby -e "require 'set'"}
|
512
|
+
|
513
|
+
err.should be_empty
|
514
|
+
end
|
515
|
+
|
516
|
+
it "should prepend gemspec require paths to $LOAD_PATH in order" do
|
517
|
+
update_repo2 do
|
518
|
+
build_gem("requirepaths") do |s|
|
519
|
+
s.write("lib/rq.rb", "puts 'yay'")
|
520
|
+
s.write("src/rq.rb", "puts 'nooo'")
|
521
|
+
s.require_paths = ["lib", "src"]
|
522
|
+
end
|
523
|
+
end
|
524
|
+
|
525
|
+
install_gemfile <<-G
|
526
|
+
source "file://#{gem_repo2}"
|
527
|
+
gem "requirepaths", :require => nil
|
528
|
+
G
|
529
|
+
|
530
|
+
run "require 'rq'"
|
531
|
+
out.should == "yay"
|
532
|
+
end
|
533
|
+
|
534
|
+
it "ignores Gem.refresh" do
|
535
|
+
system_gems "rack-1.0.0"
|
536
|
+
|
537
|
+
install_gemfile <<-G
|
538
|
+
source "file://#{gem_repo1}"
|
539
|
+
gem "activesupport"
|
540
|
+
G
|
541
|
+
|
542
|
+
run <<-R
|
543
|
+
Gem.refresh
|
544
|
+
puts Bundler.rubygems.find_name("rack").inspect
|
545
|
+
R
|
546
|
+
|
547
|
+
out.should == "[]"
|
548
|
+
end
|
549
|
+
|
550
|
+
describe "when a vendored gem specification uses the :path option" do
|
551
|
+
it "should resolve paths relative to the Gemfile" do
|
552
|
+
path = bundled_app(File.join('vendor', 'foo'))
|
553
|
+
build_lib "foo", :path => path
|
554
|
+
|
555
|
+
# If the .gemspec exists, then Bundler handles the path differently.
|
556
|
+
# See Source::Path.load_spec_files for details.
|
557
|
+
FileUtils.rm(File.join(path, 'foo.gemspec'))
|
558
|
+
|
559
|
+
install_gemfile <<-G
|
560
|
+
gem 'foo', '1.2.3', :path => 'vendor/foo'
|
561
|
+
G
|
562
|
+
|
563
|
+
Dir.chdir(bundled_app.parent) do
|
564
|
+
run <<-R, :env => {"BUNDLE_GEMFILE" => bundled_app('Gemfile')}
|
565
|
+
require 'foo'
|
566
|
+
R
|
567
|
+
end
|
568
|
+
err.should == ""
|
569
|
+
end
|
570
|
+
|
571
|
+
it "should make sure the Bundler.root is really included in the path relative to the Gemfile" do
|
572
|
+
relative_path = File.join('vendor', Dir.pwd[1..-1], 'foo')
|
573
|
+
absolute_path = bundled_app(relative_path)
|
574
|
+
FileUtils.mkdir_p(absolute_path)
|
575
|
+
build_lib "foo", :path => absolute_path
|
576
|
+
|
577
|
+
# If the .gemspec exists, then Bundler handles the path differently.
|
578
|
+
# See Source::Path.load_spec_files for details.
|
579
|
+
FileUtils.rm(File.join(absolute_path, 'foo.gemspec'))
|
580
|
+
|
581
|
+
gemfile <<-G
|
582
|
+
gem 'foo', '1.2.3', :path => '#{relative_path}'
|
583
|
+
G
|
584
|
+
|
585
|
+
bundle :install
|
586
|
+
|
587
|
+
Dir.chdir(bundled_app.parent) do
|
588
|
+
run <<-R, :env => {"BUNDLE_GEMFILE" => bundled_app('Gemfile')}
|
589
|
+
require 'foo'
|
590
|
+
R
|
591
|
+
end
|
592
|
+
|
593
|
+
err.should == ""
|
594
|
+
end
|
595
|
+
end
|
596
|
+
|
597
|
+
describe "with git gems that don't have gemspecs" do
|
598
|
+
before :each do
|
599
|
+
build_git "no-gemspec", :gemspec => false
|
600
|
+
|
601
|
+
install_gemfile <<-G
|
602
|
+
gem "no-gemspec", "1.0", :git => "#{lib_path('no-gemspec-1.0')}"
|
603
|
+
G
|
604
|
+
end
|
605
|
+
|
606
|
+
it "loads the library via a virtual spec" do
|
607
|
+
run <<-R
|
608
|
+
require 'no-gemspec'
|
609
|
+
puts NOGEMSPEC
|
610
|
+
R
|
611
|
+
|
612
|
+
out.should == "1.0"
|
613
|
+
end
|
614
|
+
end
|
615
|
+
|
616
|
+
describe "with bundled and system gems" do
|
617
|
+
before :each do
|
618
|
+
system_gems "rack-1.0.0"
|
619
|
+
|
620
|
+
install_gemfile <<-G
|
621
|
+
source "file://#{gem_repo1}"
|
622
|
+
|
623
|
+
gem "activesupport", "2.3.5"
|
624
|
+
G
|
625
|
+
end
|
626
|
+
|
627
|
+
it "does not pull in system gems" do
|
628
|
+
run <<-R
|
629
|
+
require 'rubygems'
|
630
|
+
|
631
|
+
begin;
|
632
|
+
require 'rack'
|
633
|
+
rescue LoadError
|
634
|
+
puts 'WIN'
|
635
|
+
end
|
636
|
+
R
|
637
|
+
|
638
|
+
out.should == "WIN"
|
639
|
+
end
|
640
|
+
|
641
|
+
it "provides a gem method" do
|
642
|
+
run <<-R
|
643
|
+
gem 'activesupport'
|
644
|
+
require 'activesupport'
|
645
|
+
puts ACTIVESUPPORT
|
646
|
+
R
|
647
|
+
|
648
|
+
out.should == "2.3.5"
|
649
|
+
end
|
650
|
+
|
651
|
+
it "raises an exception if gem is used to invoke a system gem not in the bundle" do
|
652
|
+
run <<-R
|
653
|
+
begin
|
654
|
+
gem 'rack'
|
655
|
+
rescue LoadError => e
|
656
|
+
puts e.message
|
657
|
+
end
|
658
|
+
R
|
659
|
+
|
660
|
+
out.should == "rack is not part of the bundle. Add it to Gemfile."
|
661
|
+
end
|
662
|
+
|
663
|
+
it "sets GEM_HOME appropriately" do
|
664
|
+
run "puts ENV['GEM_HOME']"
|
665
|
+
out.should == default_bundle_path.to_s
|
666
|
+
end
|
667
|
+
end
|
668
|
+
|
669
|
+
describe "with system gems in the bundle" do
|
670
|
+
before :each do
|
671
|
+
system_gems "rack-1.0.0"
|
672
|
+
|
673
|
+
install_gemfile <<-G
|
674
|
+
source "file://#{gem_repo1}"
|
675
|
+
gem "rack", "1.0.0"
|
676
|
+
gem "activesupport", "2.3.5"
|
677
|
+
G
|
678
|
+
end
|
679
|
+
|
680
|
+
it "sets GEM_PATH appropriately" do
|
681
|
+
run "puts Gem.path"
|
682
|
+
paths = out.split("\n")
|
683
|
+
paths.should include(system_gem_path.to_s)
|
684
|
+
paths.should include(default_bundle_path.to_s)
|
685
|
+
end
|
686
|
+
end
|
687
|
+
|
688
|
+
describe "with a gemspec that requires other files" do
|
689
|
+
before :each do
|
690
|
+
build_git "bar", :gemspec => false do |s|
|
691
|
+
s.write "lib/bar/version.rb", %{BAR_VERSION = '1.0'}
|
692
|
+
s.write "bar.gemspec", <<-G
|
693
|
+
lib = File.expand_path('../lib/', __FILE__)
|
694
|
+
$:.unshift lib unless $:.include?(lib)
|
695
|
+
require 'bar/version'
|
696
|
+
|
697
|
+
Gem::Specification.new do |s|
|
698
|
+
s.name = 'bar'
|
699
|
+
s.version = BAR_VERSION
|
700
|
+
s.summary = 'Bar'
|
701
|
+
s.files = Dir["lib/**/*.rb"]
|
702
|
+
end
|
703
|
+
G
|
704
|
+
end
|
705
|
+
|
706
|
+
gemfile <<-G
|
707
|
+
gem "bar", :git => "#{lib_path('bar-1.0')}"
|
708
|
+
G
|
709
|
+
end
|
710
|
+
|
711
|
+
it "evals each gemspec in the context of its parent directory" do
|
712
|
+
bundle :install
|
713
|
+
run "require 'bar'; puts BAR"
|
714
|
+
out.should == "1.0"
|
715
|
+
end
|
716
|
+
|
717
|
+
it "error intelligently if the gemspec has a LoadError" do
|
718
|
+
update_git "bar", :gemspec => false do |s|
|
719
|
+
s.write "bar.gemspec", "require 'foobarbaz'"
|
720
|
+
end
|
721
|
+
bundle :install
|
722
|
+
out.should include("was a LoadError while evaluating bar.gemspec")
|
723
|
+
out.should include("foobarbaz")
|
724
|
+
out.should include("bar.gemspec:1")
|
725
|
+
out.should include("try to require a relative path") if RUBY_VERSION >= "1.9"
|
726
|
+
end
|
727
|
+
|
728
|
+
it "evals each gemspec with a binding from the top level" do
|
729
|
+
bundle "install"
|
730
|
+
|
731
|
+
ruby <<-RUBY
|
732
|
+
require 'bundler'
|
733
|
+
def Bundler.require(path)
|
734
|
+
raise "LOSE"
|
735
|
+
end
|
736
|
+
Bundler.load
|
737
|
+
RUBY
|
738
|
+
|
739
|
+
err.should eq("")
|
740
|
+
out.should eq("")
|
741
|
+
end
|
742
|
+
end
|
743
|
+
|
744
|
+
describe "when Bundler is bundled" do
|
745
|
+
it "doesn't blow up" do
|
746
|
+
install_gemfile <<-G
|
747
|
+
gem "bundler", :path => "#{File.expand_path("..", lib)}"
|
748
|
+
G
|
749
|
+
|
750
|
+
bundle %|exec ruby -e "require 'bundler'; Bundler.setup"|
|
751
|
+
err.should be_empty
|
752
|
+
end
|
753
|
+
end
|
754
|
+
|
755
|
+
end
|