bundler 1.0.0 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of bundler might be problematic. Click here for more details.

Files changed (108) hide show
  1. data/.gitignore +12 -0
  2. data/CHANGELOG.md +28 -6
  3. data/ISSUES.md +1 -1
  4. data/README.md +7 -5
  5. data/Rakefile +173 -0
  6. data/UPGRADING.md +103 -0
  7. data/bundler.gemspec +28 -0
  8. data/lib/bundler.rb +1 -0
  9. data/lib/bundler/capistrano.rb +2 -31
  10. data/lib/bundler/cli.rb +18 -16
  11. data/lib/bundler/deployment.rb +37 -0
  12. data/lib/bundler/dsl.rb +3 -3
  13. data/lib/bundler/gem_helper.rb +4 -7
  14. data/lib/bundler/graph.rb +3 -3
  15. data/lib/bundler/installer.rb +1 -0
  16. data/lib/bundler/lockfile_parser.rb +1 -1
  17. data/lib/bundler/man/bundle +1 -1
  18. data/lib/bundler/man/bundle-config +92 -0
  19. data/lib/bundler/man/bundle-config.txt +72 -30
  20. data/lib/bundler/man/bundle-exec +1 -1
  21. data/lib/bundler/man/bundle-exec.txt +1 -1
  22. data/lib/bundler/man/bundle-install +1 -1
  23. data/lib/bundler/man/bundle-install.txt +1 -1
  24. data/lib/bundler/man/bundle-package +1 -1
  25. data/lib/bundler/man/bundle-package.txt +1 -1
  26. data/lib/bundler/man/bundle-update +1 -1
  27. data/lib/bundler/man/bundle-update.txt +1 -1
  28. data/lib/bundler/man/bundle.txt +1 -1
  29. data/lib/bundler/man/gemfile.5 +2 -2
  30. data/lib/bundler/man/gemfile.5.txt +2 -2
  31. data/lib/bundler/settings.rb +2 -2
  32. data/lib/bundler/source.rb +2 -3
  33. data/lib/bundler/templates/Executable +1 -1
  34. data/lib/bundler/templates/newgem/Gemfile.tt +1 -1
  35. data/lib/bundler/templates/newgem/bin/newgem.tt +3 -0
  36. data/lib/bundler/templates/newgem/newgem.gemspec.tt +11 -12
  37. data/lib/bundler/version.rb +1 -1
  38. data/lib/bundler/vlad.rb +9 -0
  39. data/man/bundle-config.ronn +90 -0
  40. data/man/bundle-exec.ronn +98 -0
  41. data/man/bundle-install.ronn +310 -0
  42. data/man/bundle-package.ronn +59 -0
  43. data/man/bundle-update.ronn +176 -0
  44. data/man/bundle.ronn +77 -0
  45. data/man/gemfile.5.ronn +254 -0
  46. data/man/index.txt +6 -0
  47. data/spec/cache/gems_spec.rb +205 -0
  48. data/spec/cache/git_spec.rb +9 -0
  49. data/spec/cache/path_spec.rb +27 -0
  50. data/spec/cache/platform_spec.rb +57 -0
  51. data/spec/install/deploy_spec.rb +171 -0
  52. data/spec/install/deprecated_spec.rb +43 -0
  53. data/spec/install/gems/c_ext_spec.rb +48 -0
  54. data/spec/install/gems/env_spec.rb +107 -0
  55. data/spec/install/gems/flex_spec.rb +272 -0
  56. data/spec/install/gems/groups_spec.rb +209 -0
  57. data/spec/install/gems/locked_spec.rb +48 -0
  58. data/spec/install/gems/packed_spec.rb +72 -0
  59. data/spec/install/gems/platform_spec.rb +181 -0
  60. data/spec/install/gems/resolving_spec.rb +72 -0
  61. data/spec/install/gems/simple_case_spec.rb +709 -0
  62. data/spec/install/gems/sudo_spec.rb +77 -0
  63. data/spec/install/gems/win32_spec.rb +26 -0
  64. data/spec/install/gemspec_spec.rb +96 -0
  65. data/spec/install/git_spec.rb +552 -0
  66. data/spec/install/invalid_spec.rb +17 -0
  67. data/spec/install/path_spec.rb +335 -0
  68. data/spec/install/upgrade_spec.rb +26 -0
  69. data/spec/lock/flex_spec.rb +625 -0
  70. data/spec/lock/git_spec.rb +35 -0
  71. data/spec/other/check_spec.rb +221 -0
  72. data/spec/other/config_spec.rb +40 -0
  73. data/spec/other/console_spec.rb +102 -0
  74. data/spec/other/exec_spec.rb +241 -0
  75. data/spec/other/ext_spec.rb +16 -0
  76. data/spec/other/gem_helper_spec.rb +116 -0
  77. data/spec/other/help_spec.rb +36 -0
  78. data/spec/other/init_spec.rb +40 -0
  79. data/spec/other/newgem_spec.rb +24 -0
  80. data/spec/other/open_spec.rb +51 -0
  81. data/spec/other/show_spec.rb +99 -0
  82. data/spec/pack/gems_spec.rb +22 -0
  83. data/spec/quality_spec.rb +55 -0
  84. data/spec/resolver/basic_spec.rb +20 -0
  85. data/spec/resolver/platform_spec.rb +57 -0
  86. data/spec/runtime/environment_rb_spec.rb +170 -0
  87. data/spec/runtime/executable_spec.rb +110 -0
  88. data/spec/runtime/load_spec.rb +107 -0
  89. data/spec/runtime/platform_spec.rb +90 -0
  90. data/spec/runtime/require_spec.rb +261 -0
  91. data/spec/runtime/setup_spec.rb +412 -0
  92. data/spec/runtime/with_clean_env_spec.rb +15 -0
  93. data/spec/spec_helper.rb +81 -0
  94. data/spec/support/builders.rb +566 -0
  95. data/spec/support/helpers.rb +243 -0
  96. data/spec/support/indexes.rb +113 -0
  97. data/spec/support/matchers.rb +89 -0
  98. data/spec/support/path.rb +71 -0
  99. data/spec/support/platforms.rb +49 -0
  100. data/spec/support/ruby_ext.rb +19 -0
  101. data/spec/support/rubygems_ext.rb +30 -0
  102. data/spec/support/rubygems_hax/rubygems_plugin.rb +9 -0
  103. data/spec/support/sudo.rb +21 -0
  104. data/spec/update/gems_spec.rb +86 -0
  105. data/spec/update/git_spec.rb +159 -0
  106. data/spec/update/source_spec.rb +50 -0
  107. metadata +170 -32
  108. data/ROADMAP.md +0 -36
@@ -0,0 +1,90 @@
1
+ require "spec_helper"
2
+
3
+ describe "Bundler.setup with multi platform stuff" do
4
+ it "raises a friendly error when gems are missing locally" do
5
+ gemfile <<-G
6
+ source "file://#{gem_repo1}"
7
+ gem "rack"
8
+ G
9
+
10
+ lockfile <<-G
11
+ GEM
12
+ remote: file:#{gem_repo1}/
13
+ specs:
14
+ rack (1.0)
15
+
16
+ PLATFORMS
17
+ #{local_tag}
18
+
19
+ DEPENDENCIES
20
+ rack
21
+ G
22
+
23
+ ruby <<-R
24
+ begin
25
+ require 'bundler'
26
+ Bundler.setup
27
+ rescue Bundler::GemNotFound => e
28
+ puts "WIN"
29
+ end
30
+ R
31
+
32
+ out.should == "WIN"
33
+ end
34
+
35
+ it "will resolve correctly on the current platform when the lockfile was targetted for a different one" do
36
+ lockfile <<-G
37
+ GEM
38
+ remote: file:#{gem_repo1}/
39
+ specs:
40
+ nokogiri (1.4.2-java)
41
+ weakling (= 0.0.3)
42
+ weakling (0.0.3)
43
+
44
+ PLATFORMS
45
+ java
46
+
47
+ DEPENDENCIES
48
+ nokogiri
49
+ G
50
+
51
+ system_gems "nokogiri-1.4.2"
52
+
53
+ simulate_platform "x86-darwin-10"
54
+ gemfile <<-G
55
+ source "file://#{gem_repo1}"
56
+ gem "nokogiri"
57
+ G
58
+
59
+ should_be_installed "nokogiri 1.4.2"
60
+ end
61
+
62
+ it "will add the resolve for the current platform" do
63
+ lockfile <<-G
64
+ GEM
65
+ remote: file:#{gem_repo1}/
66
+ specs:
67
+ nokogiri (1.4.2-java)
68
+ weakling (= 0.0.3)
69
+ weakling (0.0.3)
70
+
71
+ PLATFORMS
72
+ java
73
+
74
+ DEPENDENCIES
75
+ nokogiri
76
+ G
77
+
78
+ system_gems "nokogiri-1.4.2", "platform_specific-1.0-x86-darwin-100"
79
+
80
+ simulate_platform "x86-darwin-100"
81
+
82
+ gemfile <<-G
83
+ source "file://#{gem_repo1}"
84
+ gem "nokogiri"
85
+ gem "platform_specific"
86
+ G
87
+
88
+ should_be_installed "nokogiri 1.4.2", "platform_specific 1.0 x86-darwin-100"
89
+ end
90
+ end
@@ -0,0 +1,261 @@
1
+ require "spec_helper"
2
+
3
+ describe "Bundler.require" do
4
+ before :each do
5
+ build_lib "one", "1.0.0" do |s|
6
+ s.write "lib/baz.rb", "puts 'baz'"
7
+ s.write "lib/qux.rb", "puts 'qux'"
8
+ end
9
+
10
+ build_lib "two", "1.0.0" do |s|
11
+ s.write "lib/two.rb", "puts 'two'"
12
+ s.add_dependency "three", "= 1.0.0"
13
+ end
14
+
15
+ build_lib "three", "1.0.0" do |s|
16
+ s.write "lib/three.rb", "puts 'three'"
17
+ s.add_dependency "seven", "= 1.0.0"
18
+ end
19
+
20
+ build_lib "four", "1.0.0" do |s|
21
+ s.write "lib/four.rb", "puts 'four'"
22
+ end
23
+
24
+ build_lib "five", "1.0.0", :no_default => true do |s|
25
+ s.write "lib/mofive.rb", "puts 'five'"
26
+ end
27
+
28
+ build_lib "six", "1.0.0" do |s|
29
+ s.write "lib/six.rb", "puts 'six'"
30
+ end
31
+
32
+ build_lib "seven", "1.0.0" do |s|
33
+ s.write "lib/seven.rb", "puts 'seven'"
34
+ end
35
+
36
+ gemfile <<-G
37
+ path "#{lib_path}"
38
+ gem "one", :group => :bar, :require => %w(baz qux)
39
+ gem "two"
40
+ gem "three", :group => :not
41
+ gem "four", :require => false
42
+ gem "five"
43
+ gem "six", :group => "string"
44
+ gem "seven", :group => :not
45
+ G
46
+ end
47
+
48
+ it "requires the gems" do
49
+ # default group
50
+ run "Bundler.require"
51
+ check out.should == "two"
52
+
53
+ # specific group
54
+ run "Bundler.require(:bar)"
55
+ check out.should == "baz\nqux"
56
+
57
+ # default and specific group
58
+ run "Bundler.require(:default, :bar)"
59
+ check out.should == "baz\nqux\ntwo"
60
+
61
+ # specific group given as a string
62
+ run "Bundler.require('bar')"
63
+ check out.should == "baz\nqux"
64
+
65
+ # specific group declared as a string
66
+ run "Bundler.require(:string)"
67
+ check out.should == "six"
68
+
69
+ # required in resolver order instead of gemfile order
70
+ run("Bundler.require(:not)")
71
+ out.split("\n").sort.should == ['seven', 'three']
72
+ end
73
+
74
+ it "allows requiring gems with non standard names explicitly" do
75
+ run "Bundler.require ; require 'mofive'"
76
+ out.should == "two\nfive"
77
+ end
78
+
79
+ it "raises an exception if a require is specified but the file does not exist" do
80
+ gemfile <<-G
81
+ path "#{lib_path}"
82
+ gem "two", :require => 'fail'
83
+ G
84
+
85
+ run <<-R
86
+ begin
87
+ Bundler.require
88
+ rescue LoadError => e
89
+ puts e.message
90
+ end
91
+ R
92
+ out.should == 'no such file to load -- fail'
93
+ end
94
+
95
+ describe "using bundle exec" do
96
+ it "requires the locked gems" do
97
+ bundle :lock
98
+
99
+ bundle "exec ruby -e 'Bundler.require'"
100
+ check out.should == "two"
101
+
102
+ bundle "exec ruby -e 'Bundler.require(:bar)'"
103
+ check out.should == "baz\nqux"
104
+
105
+ bundle "exec ruby -e 'Bundler.require(:default, :bar)'"
106
+ out.should == "baz\nqux\ntwo"
107
+ end
108
+ end
109
+
110
+ describe "order" do
111
+ before(:each) do
112
+ build_lib "one", "1.0.0" do |s|
113
+ s.write "lib/one.rb", <<-ONE
114
+ if defined?(Two)
115
+ Two.two
116
+ else
117
+ puts "two_not_loaded"
118
+ end
119
+ puts 'one'
120
+ ONE
121
+ end
122
+
123
+ build_lib "two", "1.0.0" do |s|
124
+ s.write "lib/two.rb", <<-TWO
125
+ module Two
126
+ def self.two
127
+ puts 'module_two'
128
+ end
129
+ end
130
+ puts 'two'
131
+ TWO
132
+ end
133
+ end
134
+
135
+ it "works when the gems are in the Gemfile in the correct order" do
136
+ gemfile <<-G
137
+ path "#{lib_path}"
138
+ gem "two"
139
+ gem "one"
140
+ G
141
+
142
+ run "Bundler.require"
143
+ check out.should == "two\nmodule_two\none"
144
+ end
145
+
146
+ describe "a gem with different requires for different envs" do
147
+ before(:each) do
148
+ build_gem "multi_gem", :to_system => true do |s|
149
+ s.write "lib/one.rb", "puts 'ONE'"
150
+ s.write "lib/two.rb", "puts 'TWO'"
151
+ end
152
+
153
+ install_gemfile <<-G
154
+ gem "multi_gem", :require => "one", :group => :one
155
+ gem "multi_gem", :require => "two", :group => :two
156
+ G
157
+ end
158
+
159
+ it "requires both with Bundler.require(both)" do
160
+ run "Bundler.require(:one, :two)"
161
+ out.should == "ONE\nTWO"
162
+ end
163
+
164
+ it "requires one with Bundler.require(:one)" do
165
+ run "Bundler.require(:one)"
166
+ out.should == "ONE"
167
+ end
168
+
169
+ it "requires :two with Bundler.require(:two)" do
170
+ run "Bundler.require(:two)"
171
+ out.should == "TWO"
172
+ end
173
+ end
174
+
175
+ it "fails when the gems are in the Gemfile in the wrong order" do
176
+ gemfile <<-G
177
+ path "#{lib_path}"
178
+ gem "one"
179
+ gem "two"
180
+ G
181
+
182
+ run "Bundler.require"
183
+ check out.should == "two_not_loaded\none\ntwo"
184
+ end
185
+
186
+ describe "when locked" do
187
+ it "works when the gems are in the Gemfile in the correct order" do
188
+ gemfile <<-G
189
+ path "#{lib_path}"
190
+ gem "two"
191
+ gem "one"
192
+ G
193
+
194
+ bundle :lock
195
+
196
+ run "Bundler.require"
197
+ check out.should == "two\nmodule_two\none"
198
+ end
199
+
200
+ it "fails when the gems are in the Gemfile in the wrong order" do
201
+ gemfile <<-G
202
+ path "#{lib_path}"
203
+ gem "one"
204
+ gem "two"
205
+ G
206
+
207
+ bundle :lock
208
+
209
+ run "Bundler.require"
210
+ check out.should == "two_not_loaded\none\ntwo"
211
+ end
212
+ end
213
+
214
+ describe "with busted gems" do
215
+ it "should be busted" do
216
+ build_gem "busted_require", :to_system => true do |s|
217
+ s.write "lib/busted_require.rb", "require 'no_such_file_omg'"
218
+ end
219
+
220
+ install_gemfile <<-G
221
+ gem "busted_require"
222
+ G
223
+
224
+ run "Bundler.require", :expect_err => true
225
+ err.should include("no such file to load -- no_such_file_omg")
226
+ end
227
+ end
228
+ end
229
+ end
230
+
231
+ describe "Bundler.require with platform specific dependencies" do
232
+ it "does not require the gems that are pinned to other platforms" do
233
+ install_gemfile <<-G
234
+ source "file://#{gem_repo1}"
235
+
236
+ platforms :#{not_local_tag} do
237
+ gem "fail", :require => "omgomg"
238
+ end
239
+
240
+ gem "rack", "1.0.0"
241
+ G
242
+
243
+ run "Bundler.require", :expect_err => true
244
+ err.should be_empty
245
+ end
246
+
247
+ it "requires gems pinned to multiple platforms, including the current one" do
248
+ install_gemfile <<-G
249
+ source "file://#{gem_repo1}"
250
+
251
+ platforms :#{not_local_tag}, :#{local_tag} do
252
+ gem "rack", :require => "rack"
253
+ end
254
+ G
255
+
256
+ run "Bundler.require; puts RACK", :expect_err => true
257
+
258
+ out.should == "1.0.0"
259
+ err.should be_empty
260
+ end
261
+ end
@@ -0,0 +1,412 @@
1
+ require "spec_helper"
2
+
3
+ describe "Bundler.setup" do
4
+ it "raises if the Gemfile was not yet installed" do
5
+ gemfile <<-G
6
+ source "file://#{gem_repo1}"
7
+ gem "rack"
8
+ G
9
+
10
+ ruby <<-R
11
+ require 'rubygems'
12
+ require 'bundler'
13
+
14
+ begin
15
+ Bundler.setup
16
+ puts "FAIL"
17
+ rescue Bundler::GemNotFound
18
+ puts "WIN"
19
+ end
20
+ R
21
+
22
+ out.should == "WIN"
23
+ end
24
+
25
+ it "doesn't create a Gemfile.lock if the setup fails" do
26
+ gemfile <<-G
27
+ source "file://#{gem_repo1}"
28
+ gem "rack"
29
+ G
30
+
31
+ ruby <<-R, :expect_err => true
32
+ require 'rubygems'
33
+ require 'bundler'
34
+
35
+ Bundler.setup
36
+ R
37
+
38
+ bundled_app("Gemfile.lock").should_not exist
39
+ end
40
+
41
+ it "doesn't change the Gemfile.lock if the setup fails" do
42
+ install_gemfile <<-G
43
+ source "file://#{gem_repo1}"
44
+ gem "rack"
45
+ G
46
+
47
+ lockfile = File.read(bundled_app("Gemfile.lock"))
48
+
49
+ gemfile <<-G
50
+ source "file://#{gem_repo1}"
51
+ gem "rack"
52
+ gem "nosuchgem", "10.0"
53
+ G
54
+
55
+ ruby <<-R, :expect_err => true
56
+ require 'rubygems'
57
+ require 'bundler'
58
+
59
+ Bundler.setup
60
+ R
61
+
62
+ File.read(bundled_app("Gemfile.lock")).should == lockfile
63
+ end
64
+
65
+ it "makes a Gemfile.lock if setup succeeds" do
66
+ install_gemfile <<-G
67
+ source "file://#{gem_repo1}"
68
+ gem "rack"
69
+ G
70
+
71
+ lockfile = File.read(bundled_app("Gemfile.lock"))
72
+
73
+ FileUtils.rm(bundled_app("Gemfile.lock"))
74
+
75
+ run "1"
76
+ bundled_app("Gemfile.lock").should exist
77
+ end
78
+
79
+ it "uses BUNDLE_GEMFILE to locate the gemfile if present" do
80
+ gemfile <<-G
81
+ source "file://#{gem_repo1}"
82
+ gem "rack"
83
+ G
84
+
85
+ gemfile bundled_app('4realz'), <<-G
86
+ source "file://#{gem_repo1}"
87
+ gem "activesupport", "2.3.5"
88
+ G
89
+
90
+ ENV['BUNDLE_GEMFILE'] = bundled_app('4realz').to_s
91
+ bundle :install
92
+
93
+ should_be_installed "activesupport 2.3.5"
94
+ end
95
+
96
+ it "prioritizes gems in BUNDLE_PATH over gems in GEM_HOME" do
97
+ ENV['BUNDLE_PATH'] = bundled_app('.bundle').to_s
98
+ install_gemfile <<-G
99
+ source "file://#{gem_repo1}"
100
+ gem "rack", "1.0.0"
101
+ G
102
+
103
+ build_gem "rack", "1.0", :to_system => true do |s|
104
+ s.write "lib/rack.rb", "RACK = 'FAIL'"
105
+ end
106
+
107
+ should_be_installed "rack 1.0.0"
108
+ end
109
+
110
+ describe "cripping rubygems" do
111
+ describe "by replacing #gem" do
112
+ before :each do
113
+ install_gemfile <<-G
114
+ source "file://#{gem_repo1}"
115
+ gem "rack", "0.9.1"
116
+ G
117
+ end
118
+
119
+ it "replaces #gem but raises when the gem is missing" do
120
+ run <<-R
121
+ begin
122
+ gem "activesupport"
123
+ puts "FAIL"
124
+ rescue LoadError
125
+ puts "WIN"
126
+ end
127
+ R
128
+
129
+ out.should == "WIN"
130
+ end
131
+
132
+ it "replaces #gem but raises when the version is wrong" do
133
+ run <<-R
134
+ begin
135
+ gem "rack", "1.0.0"
136
+ puts "FAIL"
137
+ rescue LoadError
138
+ puts "WIN"
139
+ end
140
+ R
141
+
142
+ out.should == "WIN"
143
+ end
144
+ end
145
+
146
+ describe "by hiding system gems" do
147
+ before :each do
148
+ system_gems "activesupport-2.3.5"
149
+ install_gemfile <<-G
150
+ source "file://#{gem_repo1}"
151
+ gem "yard"
152
+ G
153
+ end
154
+
155
+ it "removes system gems from Gem.source_index" do
156
+ run "require 'yard'"
157
+ out.should == "bundler-#{Bundler::VERSION}\nyard-1.0"
158
+ end
159
+ end
160
+ end
161
+
162
+ describe "with paths" do
163
+ it "activates the gems in the path source" do
164
+ system_gems "rack-1.0.0"
165
+
166
+ build_lib "rack", "1.0.0" do |s|
167
+ s.write "lib/rack.rb", "puts 'WIN'"
168
+ end
169
+
170
+ gemfile <<-G
171
+ path "#{lib_path('rack-1.0.0')}"
172
+ source "file://#{gem_repo1}"
173
+ gem "rack"
174
+ G
175
+
176
+ run "require 'rack'"
177
+ out.should == "WIN"
178
+ end
179
+ end
180
+
181
+ describe "with git" do
182
+ before do
183
+ build_git "rack", "1.0.0"
184
+
185
+ gemfile <<-G
186
+ gem "rack", :git => "#{lib_path('rack-1.0.0')}"
187
+ G
188
+ end
189
+
190
+ it "provides a useful exception when the git repo is not checked out yet" do
191
+ run "1", :expect_err => true
192
+ err.should include("#{lib_path('rack-1.0.0')} (at master) is not checked out. Please run `bundle install`")
193
+ end
194
+
195
+ it "does not hit the git binary if the lockfile is available and up to date" do
196
+ bundle "install"
197
+
198
+ break_git!
199
+
200
+ ruby <<-R
201
+ require 'rubygems'
202
+ require 'bundler'
203
+
204
+ begin
205
+ Bundler.setup
206
+ puts "WIN"
207
+ rescue Exception => e
208
+ puts "FAIL"
209
+ end
210
+ R
211
+
212
+ out.should == "WIN"
213
+ end
214
+
215
+ it "provides a good exception if the lockfile is unavailable" do
216
+ bundle "install"
217
+
218
+ FileUtils.rm(bundled_app("Gemfile.lock"))
219
+
220
+ break_git!
221
+
222
+ ruby <<-R
223
+ require "rubygems"
224
+ require "bundler"
225
+
226
+ begin
227
+ Bundler.setup
228
+ puts "FAIL"
229
+ rescue Bundler::GitError => e
230
+ puts e.message
231
+ end
232
+ R
233
+
234
+ run "puts 'FAIL'", :expect_err => true
235
+
236
+ err.should_not include "This is not the git you are looking for"
237
+ end
238
+
239
+ it "works even when the cache directory has been deleted" do
240
+ bundle "install vendor"
241
+ FileUtils.rm_rf vendored_gems('cache')
242
+ should_be_installed "rack 1.0.0"
243
+ end
244
+
245
+ it "does not randomly change the path when specifying --path and the bundle directory becomes read only" do
246
+ begin
247
+ bundle "install vendor"
248
+
249
+ Dir["**/*"].each do |f|
250
+ File.directory?(f) ?
251
+ File.chmod(0555, f) :
252
+ File.chmod(0444, f)
253
+ end
254
+ should_be_installed "rack 1.0.0"
255
+ ensure
256
+ Dir["**/*"].each do |f|
257
+ File.directory?(f) ?
258
+ File.chmod(0755, f) :
259
+ File.chmod(0644, f)
260
+ end
261
+ end
262
+ end
263
+ end
264
+
265
+ describe "when excluding groups" do
266
+ it "doesn't change the resolve if --without is used" do
267
+ install_gemfile <<-G, :without => :rails
268
+ source "file://#{gem_repo1}"
269
+ gem "activesupport"
270
+
271
+ group :rails do
272
+ gem "rails", "2.3.2"
273
+ end
274
+ G
275
+
276
+ install_gems "activesupport-2.3.5"
277
+
278
+ should_be_installed "activesupport 2.3.2", :groups => :default
279
+ end
280
+
281
+ it "remembers --without and does not bail on bare Bundler.setup" do
282
+ install_gemfile <<-G, :without => :rails
283
+ source "file://#{gem_repo1}"
284
+ gem "activesupport"
285
+
286
+ group :rails do
287
+ gem "rails", "2.3.2"
288
+ end
289
+ G
290
+
291
+ install_gems "activesupport-2.3.5"
292
+
293
+ should_be_installed "activesupport 2.3.2"
294
+ end
295
+
296
+ it "remembers --without and does not include groups passed to Bundler.setup" do
297
+ install_gemfile <<-G, :without => :rails
298
+ source "file://#{gem_repo1}"
299
+ gem "activesupport"
300
+
301
+ group :rack do
302
+ gem "rack"
303
+ end
304
+
305
+ group :rails do
306
+ gem "rails", "2.3.2"
307
+ end
308
+ G
309
+
310
+ should_not_be_installed "activesupport 2.3.2", :groups => :rack
311
+ should_be_installed "rack 1.0.0", :groups => :rack
312
+ end
313
+ end
314
+
315
+ # Unfortunately, gem_prelude does not record the information about
316
+ # activated gems, so this test cannot work on 1.9 :(
317
+ if RUBY_VERSION < "1.9"
318
+ describe "preactivated gems" do
319
+ it "raises an exception if a pre activated gem conflicts with the bundle" do
320
+ system_gems "thin-1.0", "rack-1.0.0"
321
+ build_gem "thin", "1.1", :to_system => true do |s|
322
+ s.add_dependency "rack"
323
+ end
324
+
325
+ gemfile <<-G
326
+ gem "thin", "1.0"
327
+ G
328
+
329
+ ruby <<-R
330
+ require 'rubygems'
331
+ gem "thin"
332
+ require 'bundler'
333
+ begin
334
+ Bundler.setup
335
+ puts "FAIL"
336
+ rescue Gem::LoadError => e
337
+ puts e.message
338
+ end
339
+ R
340
+
341
+ out.should == "You have already activated thin 1.1, but your Gemfile requires thin 1.0. Consider using bundle exec."
342
+ end
343
+ end
344
+ end
345
+
346
+ # Rubygems returns loaded_from as a string
347
+ it "has loaded_from as a string on all specs" do
348
+ build_git "foo"
349
+ build_git "no-gemspec", :gemspec => false
350
+
351
+ install_gemfile <<-G
352
+ source "file://#{gem_repo1}"
353
+ gem "rack"
354
+ gem "foo", :git => "#{lib_path('foo-1.0')}"
355
+ gem "no-gemspec", "1.0", :git => "#{lib_path('no-gemspec-1.0')}"
356
+ G
357
+
358
+ run <<-R
359
+ Gem.loaded_specs.each do |n, s|
360
+ puts "FAIL" unless String === s.loaded_from
361
+ end
362
+ R
363
+
364
+ out.should be_empty
365
+ end
366
+
367
+ it "ignores empty gem paths" do
368
+ install_gemfile <<-G
369
+ source "file://#{gem_repo1}"
370
+ gem "rack"
371
+ G
372
+
373
+ ENV["GEM_HOME"] = ""
374
+ bundle %{exec ruby -e "require 'set'"}
375
+
376
+ err.should be_empty
377
+ end
378
+
379
+ it "should prepend gemspec require paths to $LOAD_PATH in order" do
380
+ update_repo2 do
381
+ build_gem("requirepaths") do |s|
382
+ s.write("lib/rq.rb", "puts 'yay'")
383
+ s.write("src/rq.rb", "puts 'nooo'")
384
+ s.require_paths = ["lib", "src"]
385
+ end
386
+ end
387
+
388
+ install_gemfile <<-G
389
+ source "file://#{gem_repo2}"
390
+ gem "requirepaths", :require => nil
391
+ G
392
+
393
+ run "require 'rq'"
394
+ out.should == "yay"
395
+ end
396
+
397
+ it "ignores Gem.refresh" do
398
+ system_gems "rack-1.0.0"
399
+
400
+ install_gemfile <<-G
401
+ source "file://#{gem_repo1}"
402
+ gem "activesupport"
403
+ G
404
+
405
+ run <<-R
406
+ Gem.refresh
407
+ puts Gem.source_index.find_name("rack").inspect
408
+ R
409
+
410
+ out.should == "[]"
411
+ end
412
+ end