honkster-bundler 1.1.pre

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (137) hide show
  1. data/.gitignore +14 -0
  2. data/CHANGELOG.md +547 -0
  3. data/ISSUES.md +32 -0
  4. data/LICENSE +20 -0
  5. data/README.md +29 -0
  6. data/Rakefile +150 -0
  7. data/UPGRADING.md +103 -0
  8. data/bin/bundle +21 -0
  9. data/bundler.gemspec +30 -0
  10. data/lib/bundler.rb +268 -0
  11. data/lib/bundler/capistrano.rb +11 -0
  12. data/lib/bundler/cli.rb +515 -0
  13. data/lib/bundler/definition.rb +427 -0
  14. data/lib/bundler/dependency.rb +114 -0
  15. data/lib/bundler/deployment.rb +37 -0
  16. data/lib/bundler/dsl.rb +245 -0
  17. data/lib/bundler/environment.rb +47 -0
  18. data/lib/bundler/gem_helper.rb +145 -0
  19. data/lib/bundler/graph.rb +130 -0
  20. data/lib/bundler/index.rb +114 -0
  21. data/lib/bundler/installer.rb +84 -0
  22. data/lib/bundler/lazy_specification.rb +71 -0
  23. data/lib/bundler/lockfile_parser.rb +108 -0
  24. data/lib/bundler/remote_specification.rb +59 -0
  25. data/lib/bundler/resolver.rb +454 -0
  26. data/lib/bundler/rubygems_ext.rb +203 -0
  27. data/lib/bundler/runtime.rb +148 -0
  28. data/lib/bundler/settings.rb +117 -0
  29. data/lib/bundler/setup.rb +15 -0
  30. data/lib/bundler/shared_helpers.rb +151 -0
  31. data/lib/bundler/source.rb +662 -0
  32. data/lib/bundler/spec_set.rb +134 -0
  33. data/lib/bundler/templates/Executable +16 -0
  34. data/lib/bundler/templates/Gemfile +4 -0
  35. data/lib/bundler/templates/newgem/Gemfile.tt +4 -0
  36. data/lib/bundler/templates/newgem/Rakefile.tt +2 -0
  37. data/lib/bundler/templates/newgem/bin/newgem.tt +3 -0
  38. data/lib/bundler/templates/newgem/gitignore.tt +3 -0
  39. data/lib/bundler/templates/newgem/lib/newgem.rb.tt +7 -0
  40. data/lib/bundler/templates/newgem/lib/newgem/version.rb.tt +7 -0
  41. data/lib/bundler/templates/newgem/newgem.gemspec.tt +21 -0
  42. data/lib/bundler/ui.rb +60 -0
  43. data/lib/bundler/vendor/thor.rb +319 -0
  44. data/lib/bundler/vendor/thor/actions.rb +297 -0
  45. data/lib/bundler/vendor/thor/actions/create_file.rb +105 -0
  46. data/lib/bundler/vendor/thor/actions/directory.rb +93 -0
  47. data/lib/bundler/vendor/thor/actions/empty_directory.rb +134 -0
  48. data/lib/bundler/vendor/thor/actions/file_manipulation.rb +229 -0
  49. data/lib/bundler/vendor/thor/actions/inject_into_file.rb +104 -0
  50. data/lib/bundler/vendor/thor/base.rb +556 -0
  51. data/lib/bundler/vendor/thor/core_ext/file_binary_read.rb +9 -0
  52. data/lib/bundler/vendor/thor/core_ext/hash_with_indifferent_access.rb +75 -0
  53. data/lib/bundler/vendor/thor/core_ext/ordered_hash.rb +100 -0
  54. data/lib/bundler/vendor/thor/error.rb +30 -0
  55. data/lib/bundler/vendor/thor/invocation.rb +168 -0
  56. data/lib/bundler/vendor/thor/parser.rb +4 -0
  57. data/lib/bundler/vendor/thor/parser/argument.rb +67 -0
  58. data/lib/bundler/vendor/thor/parser/arguments.rb +161 -0
  59. data/lib/bundler/vendor/thor/parser/option.rb +120 -0
  60. data/lib/bundler/vendor/thor/parser/options.rb +174 -0
  61. data/lib/bundler/vendor/thor/shell.rb +88 -0
  62. data/lib/bundler/vendor/thor/shell/basic.rb +275 -0
  63. data/lib/bundler/vendor/thor/shell/color.rb +108 -0
  64. data/lib/bundler/vendor/thor/shell/html.rb +121 -0
  65. data/lib/bundler/vendor/thor/task.rb +114 -0
  66. data/lib/bundler/vendor/thor/util.rb +229 -0
  67. data/lib/bundler/vendor/thor/version.rb +3 -0
  68. data/lib/bundler/version.rb +6 -0
  69. data/lib/bundler/vlad.rb +9 -0
  70. data/man/bundle-config.ronn +90 -0
  71. data/man/bundle-exec.ronn +98 -0
  72. data/man/bundle-install.ronn +310 -0
  73. data/man/bundle-package.ronn +59 -0
  74. data/man/bundle-update.ronn +176 -0
  75. data/man/bundle.ronn +77 -0
  76. data/man/gemfile.5.ronn +273 -0
  77. data/man/index.txt +6 -0
  78. data/spec/cache/gems_spec.rb +205 -0
  79. data/spec/cache/git_spec.rb +9 -0
  80. data/spec/cache/path_spec.rb +27 -0
  81. data/spec/cache/platform_spec.rb +57 -0
  82. data/spec/install/deploy_spec.rb +197 -0
  83. data/spec/install/deprecated_spec.rb +43 -0
  84. data/spec/install/gems/c_ext_spec.rb +48 -0
  85. data/spec/install/gems/env_spec.rb +107 -0
  86. data/spec/install/gems/flex_spec.rb +272 -0
  87. data/spec/install/gems/groups_spec.rb +228 -0
  88. data/spec/install/gems/packed_spec.rb +72 -0
  89. data/spec/install/gems/platform_spec.rb +195 -0
  90. data/spec/install/gems/resolving_spec.rb +72 -0
  91. data/spec/install/gems/simple_case_spec.rb +749 -0
  92. data/spec/install/gems/sudo_spec.rb +77 -0
  93. data/spec/install/gems/win32_spec.rb +26 -0
  94. data/spec/install/gemspec_spec.rb +96 -0
  95. data/spec/install/git_spec.rb +553 -0
  96. data/spec/install/invalid_spec.rb +17 -0
  97. data/spec/install/path_spec.rb +329 -0
  98. data/spec/install/upgrade_spec.rb +26 -0
  99. data/spec/lock/flex_spec.rb +650 -0
  100. data/spec/lock/git_spec.rb +35 -0
  101. data/spec/other/check_spec.rb +221 -0
  102. data/spec/other/config_spec.rb +40 -0
  103. data/spec/other/console_spec.rb +54 -0
  104. data/spec/other/exec_spec.rb +241 -0
  105. data/spec/other/ext_spec.rb +16 -0
  106. data/spec/other/gem_helper_spec.rb +126 -0
  107. data/spec/other/help_spec.rb +36 -0
  108. data/spec/other/init_spec.rb +40 -0
  109. data/spec/other/newgem_spec.rb +24 -0
  110. data/spec/other/open_spec.rb +35 -0
  111. data/spec/other/show_spec.rb +82 -0
  112. data/spec/pack/gems_spec.rb +22 -0
  113. data/spec/quality_spec.rb +55 -0
  114. data/spec/resolver/basic_spec.rb +20 -0
  115. data/spec/resolver/platform_spec.rb +57 -0
  116. data/spec/runtime/environment_rb_spec.rb +162 -0
  117. data/spec/runtime/executable_spec.rb +110 -0
  118. data/spec/runtime/load_spec.rb +102 -0
  119. data/spec/runtime/platform_spec.rb +90 -0
  120. data/spec/runtime/require_spec.rb +231 -0
  121. data/spec/runtime/setup_spec.rb +412 -0
  122. data/spec/runtime/with_clean_env_spec.rb +15 -0
  123. data/spec/spec_helper.rb +82 -0
  124. data/spec/support/builders.rb +566 -0
  125. data/spec/support/helpers.rb +243 -0
  126. data/spec/support/indexes.rb +113 -0
  127. data/spec/support/matchers.rb +89 -0
  128. data/spec/support/path.rb +71 -0
  129. data/spec/support/platforms.rb +49 -0
  130. data/spec/support/ruby_ext.rb +19 -0
  131. data/spec/support/rubygems_ext.rb +30 -0
  132. data/spec/support/rubygems_hax/rubygems_plugin.rb +9 -0
  133. data/spec/support/sudo.rb +21 -0
  134. data/spec/update/gems_spec.rb +112 -0
  135. data/spec/update/git_spec.rb +159 -0
  136. data/spec/update/source_spec.rb +50 -0
  137. metadata +251 -0
@@ -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,231 @@
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 "exec ruby -e 'Bundler.require'"
98
+ check out.should == "two"
99
+
100
+ bundle "exec ruby -e 'Bundler.require(:bar)'"
101
+ check out.should == "baz\nqux"
102
+
103
+ bundle "exec ruby -e 'Bundler.require(:default, :bar)'"
104
+ out.should == "baz\nqux\ntwo"
105
+ end
106
+ end
107
+
108
+ describe "order" do
109
+ before(:each) do
110
+ build_lib "one", "1.0.0" do |s|
111
+ s.write "lib/one.rb", <<-ONE
112
+ if defined?(Two)
113
+ Two.two
114
+ else
115
+ puts "two_not_loaded"
116
+ end
117
+ puts 'one'
118
+ ONE
119
+ end
120
+
121
+ build_lib "two", "1.0.0" do |s|
122
+ s.write "lib/two.rb", <<-TWO
123
+ module Two
124
+ def self.two
125
+ puts 'module_two'
126
+ end
127
+ end
128
+ puts 'two'
129
+ TWO
130
+ end
131
+ end
132
+
133
+ it "works when the gems are in the Gemfile in the correct order" do
134
+ gemfile <<-G
135
+ path "#{lib_path}"
136
+ gem "two"
137
+ gem "one"
138
+ G
139
+
140
+ run "Bundler.require"
141
+ check out.should == "two\nmodule_two\none"
142
+ end
143
+
144
+ describe "a gem with different requires for different envs" do
145
+ before(:each) do
146
+ build_gem "multi_gem", :to_system => true do |s|
147
+ s.write "lib/one.rb", "puts 'ONE'"
148
+ s.write "lib/two.rb", "puts 'TWO'"
149
+ end
150
+
151
+ install_gemfile <<-G
152
+ gem "multi_gem", :require => "one", :group => :one
153
+ gem "multi_gem", :require => "two", :group => :two
154
+ G
155
+ end
156
+
157
+ it "requires both with Bundler.require(both)" do
158
+ run "Bundler.require(:one, :two)"
159
+ out.should == "ONE\nTWO"
160
+ end
161
+
162
+ it "requires one with Bundler.require(:one)" do
163
+ run "Bundler.require(:one)"
164
+ out.should == "ONE"
165
+ end
166
+
167
+ it "requires :two with Bundler.require(:two)" do
168
+ run "Bundler.require(:two)"
169
+ out.should == "TWO"
170
+ end
171
+ end
172
+
173
+ it "fails when the gems are in the Gemfile in the wrong order" do
174
+ gemfile <<-G
175
+ path "#{lib_path}"
176
+ gem "one"
177
+ gem "two"
178
+ G
179
+
180
+ run "Bundler.require"
181
+ check out.should == "two_not_loaded\none\ntwo"
182
+ end
183
+
184
+ describe "with busted gems" do
185
+ it "should be busted" do
186
+ build_gem "busted_require", :to_system => true do |s|
187
+ s.write "lib/busted_require.rb", "require 'no_such_file_omg'"
188
+ end
189
+
190
+ install_gemfile <<-G
191
+ gem "busted_require"
192
+ G
193
+
194
+ run "Bundler.require", :expect_err => true
195
+ err.should include("no such file to load -- no_such_file_omg")
196
+ end
197
+ end
198
+ end
199
+ end
200
+
201
+ describe "Bundler.require with platform specific dependencies" do
202
+ it "does not require the gems that are pinned to other platforms" do
203
+ install_gemfile <<-G
204
+ source "file://#{gem_repo1}"
205
+
206
+ platforms :#{not_local_tag} do
207
+ gem "fail", :require => "omgomg"
208
+ end
209
+
210
+ gem "rack", "1.0.0"
211
+ G
212
+
213
+ run "Bundler.require", :expect_err => true
214
+ err.should be_empty
215
+ end
216
+
217
+ it "requires gems pinned to multiple platforms, including the current one" do
218
+ install_gemfile <<-G
219
+ source "file://#{gem_repo1}"
220
+
221
+ platforms :#{not_local_tag}, :#{local_tag} do
222
+ gem "rack", :require => "rack"
223
+ end
224
+ G
225
+
226
+ run "Bundler.require; puts RACK", :expect_err => true
227
+
228
+ out.should == "1.0.0"
229
+ err.should be_empty
230
+ end
231
+ 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