honkster-bundler 1.1.pre

Sign up to get free protection for your applications and to get access to all the features.
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,77 @@
1
+ require "spec_helper"
2
+
3
+ describe "when using sudo" do
4
+ before :each do
5
+ pending "set BUNDLER_SUDO_TESTS to run sudo specs" unless test_sudo?
6
+ end
7
+
8
+ describe "and GEM_HOME is owned by root" do
9
+ before :each do
10
+ chown_system_gems_to_root
11
+ end
12
+
13
+ it "installs" do
14
+ install_gemfile <<-G
15
+ source "file://#{gem_repo1}"
16
+ gem "rack", '1.0'
17
+ G
18
+
19
+ system_gem_path("gems/rack-1.0.0").should exist
20
+ system_gem_path("gems/rack-1.0.0").stat.uid.should == 0
21
+ should_be_installed "rack 1.0"
22
+ end
23
+
24
+ it "installs when BUNDLE_PATH is owned by root" do
25
+ bundle_path = tmp("owned_by_root")
26
+ FileUtils.mkdir_p bundle_path
27
+ sudo "chown -R root #{bundle_path}"
28
+
29
+ ENV['BUNDLE_PATH'] = bundle_path.to_s
30
+ install_gemfile <<-G
31
+ source "file://#{gem_repo1}"
32
+ gem "rack", '1.0'
33
+ G
34
+
35
+ bundle_path.join("gems/rack-1.0.0").should exist
36
+ bundle_path.join("gems/rack-1.0.0").stat.uid.should == 0
37
+ should_be_installed "rack 1.0"
38
+ end
39
+
40
+ it "installs when BUNDLE_PATH does not exist"
41
+ end
42
+
43
+ describe "and BUNDLE_PATH is not writable" do
44
+ it "installs" do
45
+ sudo "chmod ugo-w #{default_bundle_path}"
46
+ install_gemfile <<-G
47
+ source "file://#{gem_repo1}"
48
+ gem "rack", '1.0'
49
+ G
50
+
51
+ default_bundle_path("gems/rack-1.0.0").should exist
52
+ should_be_installed "rack 1.0"
53
+ end
54
+ end
55
+
56
+ describe "and BUNDLE_PATH is not writable" do
57
+ it "installs" do
58
+ begin
59
+ gem_home = tmp('sudo_gem_home')
60
+
61
+ sudo "mkdir -p #{gem_home}"
62
+ sudo "chmod ugo-w #{gem_home}"
63
+ ENV['GEM_HOME'] = gem_home.to_s
64
+ ENV['GEM_PATH'] = nil
65
+
66
+ install_gemfile <<-G
67
+ source "file://#{gem_repo1}"
68
+ gem "rack", '1.0'
69
+ G
70
+
71
+ gem_home.join('bin/rackup').should exist
72
+ should_be_installed "rack 1.0"
73
+ end
74
+ end
75
+ end
76
+
77
+ end
@@ -0,0 +1,26 @@
1
+ require 'spec_helper'
2
+
3
+ describe "bundle install with win32-generated lockfile" do
4
+ it 'should read lockfile' do
5
+ File.open(bundled_app('Gemfile.lock'), 'wb') do |f|
6
+ f << "GEM\r\n"
7
+ f << " remote: file:#{gem_repo1}/\r\n"
8
+ f << " specs:\r\n"
9
+ f << "\r\n"
10
+ f << " rack (1.0.0)\r\n"
11
+ f << "\r\n"
12
+ f << "PLATFORMS\r\n"
13
+ f << " ruby\r\n"
14
+ f << "\r\n"
15
+ f << "DEPENDENCIES\r\n"
16
+ f << " rack\r\n"
17
+ end
18
+
19
+ install_gemfile <<-G, :exitstatus => true
20
+ source "file://#{gem_repo1}"
21
+
22
+ gem "rack"
23
+ G
24
+ @exitstatus.should == 0
25
+ end
26
+ end
@@ -0,0 +1,96 @@
1
+ require "spec_helper"
2
+
3
+ describe "bundle install from an existing gemspec" do
4
+
5
+ before(:each) do
6
+ build_gem "bar", :to_system => true
7
+ build_gem "bar-dev", :to_system => true
8
+ end
9
+
10
+ it "should install runtime and development dependencies" do
11
+ build_lib("foo", :path => tmp.join("foo")) do |s|
12
+ s.write("Gemfile", "source :rubygems\ngemspec")
13
+ s.add_dependency "bar", "=1.0.0"
14
+ s.add_development_dependency "bar-dev", '=1.0.0'
15
+ end
16
+ install_gemfile <<-G
17
+ source "file://#{gem_repo2}"
18
+ gemspec :path => '#{tmp.join("foo")}'
19
+ G
20
+
21
+ should_be_installed "bar 1.0.0"
22
+ should_be_installed "bar-dev 1.0.0", :groups => :development
23
+ end
24
+
25
+ it "should handle a list of requirements" do
26
+ build_gem "baz", "1.0", :to_system => true
27
+ build_gem "baz", "1.1", :to_system => true
28
+
29
+ build_lib("foo", :path => tmp.join("foo")) do |s|
30
+ s.write("Gemfile", "source :rubygems\ngemspec")
31
+ s.add_dependency "baz", ">= 1.0", "< 1.1"
32
+ end
33
+ install_gemfile <<-G
34
+ source "file://#{gem_repo2}"
35
+ gemspec :path => '#{tmp.join("foo")}'
36
+ G
37
+
38
+ should_be_installed "baz 1.0"
39
+ end
40
+
41
+ it "should raise if there are no gemspecs available" do
42
+ build_lib("foo", :path => tmp.join("foo"), :gemspec => false)
43
+
44
+ error = install_gemfile(<<-G, :expect_err => true)
45
+ source "file://#{gem_repo2}"
46
+ gemspec :path => '#{tmp.join("foo")}'
47
+ G
48
+ error.should match(/There are no gemspecs at #{tmp.join('foo')}/)
49
+ end
50
+
51
+ it "should raise if there are too many gemspecs available" do
52
+ build_lib("foo", :path => tmp.join("foo")) do |s|
53
+ s.write("foo2.gemspec", "")
54
+ end
55
+
56
+ error = install_gemfile(<<-G, :expect_err => true)
57
+ source "file://#{gem_repo2}"
58
+ gemspec :path => '#{tmp.join("foo")}'
59
+ G
60
+ error.should match(/There are multiple gemspecs at #{tmp.join('foo')}/)
61
+ end
62
+
63
+ it "should pick a specific gemspec" do
64
+ build_lib("foo", :path => tmp.join("foo")) do |s|
65
+ s.write("foo2.gemspec", "")
66
+ s.add_dependency "bar", "=1.0.0"
67
+ s.add_development_dependency "bar-dev", '=1.0.0'
68
+ end
69
+
70
+ install_gemfile(<<-G, :expect_err => true)
71
+ source "file://#{gem_repo2}"
72
+ gemspec :path => '#{tmp.join("foo")}', :name => 'foo'
73
+ G
74
+
75
+ should_be_installed "bar 1.0.0"
76
+ should_be_installed "bar-dev 1.0.0", :groups => :development
77
+ end
78
+
79
+ it "should use a specific group for development dependencies" do
80
+ build_lib("foo", :path => tmp.join("foo")) do |s|
81
+ s.write("foo2.gemspec", "")
82
+ s.add_dependency "bar", "=1.0.0"
83
+ s.add_development_dependency "bar-dev", '=1.0.0'
84
+ end
85
+
86
+ install_gemfile(<<-G, :expect_err => true)
87
+ source "file://#{gem_repo2}"
88
+ gemspec :path => '#{tmp.join("foo")}', :name => 'foo', :development_group => :dev
89
+ G
90
+
91
+ should_be_installed "bar 1.0.0"
92
+ should_not_be_installed "bar-dev 1.0.0", :groups => :development
93
+ should_be_installed "bar-dev 1.0.0", :groups => :dev
94
+ end
95
+
96
+ end
@@ -0,0 +1,553 @@
1
+ require "spec_helper"
2
+
3
+ describe "bundle install with git sources" do
4
+ describe "when floating on master" do
5
+ before :each do
6
+ build_git "foo" do |s|
7
+ s.executables = "foobar"
8
+ end
9
+
10
+ install_gemfile <<-G
11
+ source "file://#{gem_repo1}"
12
+ git "#{lib_path('foo-1.0')}" do
13
+ gem 'foo'
14
+ end
15
+ G
16
+ end
17
+
18
+ it "fetches gems" do
19
+ should_be_installed("foo 1.0")
20
+
21
+ run <<-RUBY
22
+ require 'foo'
23
+ puts "WIN" unless defined?(FOO_PREV_REF)
24
+ RUBY
25
+
26
+ out.should == "WIN"
27
+ end
28
+
29
+ it "caches the git repo" do
30
+ Dir["#{default_bundle_path}/cache/bundler/git/foo-1.0-*"].should have(1).item
31
+ end
32
+
33
+ it "does not update the git source implicitly" do
34
+ update_git "foo"
35
+
36
+ in_app_root2 do
37
+ install_gemfile bundled_app2("Gemfile"), <<-G
38
+ git "#{lib_path('foo-1.0')}" do
39
+ gem 'foo'
40
+ end
41
+ G
42
+ end
43
+
44
+ in_app_root do
45
+ run <<-RUBY
46
+ require 'foo'
47
+ puts "fail" if defined?(FOO_PREV_REF)
48
+ RUBY
49
+
50
+ out.should be_empty
51
+ end
52
+ end
53
+
54
+ it "setups executables" do
55
+ pending_jruby_shebang_fix
56
+ bundle "exec foobar"
57
+ out.should == "1.0"
58
+ end
59
+
60
+ it "complains if pinned specs don't exist in the git repo" do
61
+ build_git "foo"
62
+
63
+ install_gemfile <<-G
64
+ gem "foo", "1.1", :git => "#{lib_path('foo-1.0')}"
65
+ G
66
+
67
+ out.should include("Source contains 'foo' at: 1.0")
68
+ end
69
+
70
+ it "still works after moving the application directory" do
71
+ bundle "install vendor"
72
+ FileUtils.mv bundled_app, tmp('bundled_app.bck')
73
+
74
+ Dir.chdir tmp('bundled_app.bck')
75
+ should_be_installed "foo 1.0"
76
+ end
77
+
78
+ it "can still install after moving the application directory" do
79
+ bundle "install vendor"
80
+ FileUtils.mv bundled_app, tmp('bundled_app.bck')
81
+
82
+ update_git "foo", "1.1", :path => lib_path("foo-1.0")
83
+
84
+ Dir.chdir tmp('bundled_app.bck')
85
+ gemfile tmp('bundled_app.bck/Gemfile'), <<-G
86
+ source "file://#{gem_repo1}"
87
+ git "#{lib_path('foo-1.0')}" do
88
+ gem 'foo'
89
+ end
90
+
91
+ gem "rack", "1.0"
92
+ G
93
+
94
+ bundle "update foo"
95
+
96
+ should_be_installed "foo 1.1", "rack 1.0"
97
+ end
98
+
99
+ end
100
+
101
+ describe "with an empty git block" do
102
+ before do
103
+ build_git "foo"
104
+ gemfile <<-G
105
+ source "file://#{gem_repo1}"
106
+ gem "rack"
107
+
108
+ git "#{lib_path("foo-1.0")}" do
109
+ # this page left intentionally blank
110
+ end
111
+ G
112
+ end
113
+
114
+ it "does not explode" do
115
+ bundle "install"
116
+ should_be_installed "rack 1.0"
117
+ end
118
+ end
119
+
120
+ describe "when specifying a revision" do
121
+ it "works" do
122
+ build_git "foo"
123
+ @revision = revision_for(lib_path("foo-1.0"))
124
+ update_git "foo"
125
+
126
+ install_gemfile <<-G
127
+ git "#{lib_path('foo-1.0')}", :ref => "#{@revision}" do
128
+ gem "foo"
129
+ end
130
+ G
131
+
132
+ run <<-RUBY
133
+ require 'foo'
134
+ puts "WIN" unless defined?(FOO_PREV_REF)
135
+ RUBY
136
+
137
+ out.should == "WIN"
138
+ end
139
+ end
140
+
141
+ describe "specified inline" do
142
+ # TODO: Figure out how to write this test so that it is not flaky depending
143
+ # on the current network situation.
144
+ # it "supports private git URLs" do
145
+ # gemfile <<-G
146
+ # gem "thingy", :git => "git@notthere.fallingsnow.net:somebody/thingy.git"
147
+ # G
148
+ #
149
+ # bundle :install, :expect_err => true
150
+ #
151
+ # # p out
152
+ # # p err
153
+ # puts err unless err.empty? # This spec fails randomly every so often
154
+ # err.should include("notthere.fallingsnow.net")
155
+ # err.should include("ssh")
156
+ # end
157
+
158
+ it "installs from git even if a newer gem is available elsewhere" do
159
+ build_git "rack", "0.8"
160
+
161
+ install_gemfile <<-G
162
+ source "file://#{gem_repo1}"
163
+ gem "rack", :git => "#{lib_path('rack-0.8')}"
164
+ G
165
+
166
+ should_be_installed "rack 0.8"
167
+ end
168
+
169
+ it "installs dependencies from git even if a newer gem is available elsewhere" do
170
+ system_gems "rack-1.0.0"
171
+
172
+ build_lib "rack", "1.0", :path => lib_path('nested/bar') do |s|
173
+ s.write "lib/rack.rb", "puts 'WIN OVERRIDE'"
174
+ end
175
+
176
+ build_git "foo", :path => lib_path('nested') do |s|
177
+ s.add_dependency "rack", "= 1.0"
178
+ end
179
+
180
+ install_gemfile <<-G
181
+ source "file://#{gem_repo1}"
182
+ gem "foo", :git => "#{lib_path('nested')}"
183
+ G
184
+
185
+ run "require 'rack'"
186
+ out.should == 'WIN OVERRIDE'
187
+ end
188
+
189
+ it "correctly unlocks when changing to a git source" do
190
+ install_gemfile <<-G
191
+ source "file://#{gem_repo1}"
192
+ gem "rack", "0.9.1"
193
+ G
194
+
195
+ build_git "rack", :path => lib_path("rack")
196
+
197
+ install_gemfile <<-G
198
+ source "file://#{gem_repo1}"
199
+ gem "rack", "1.0.0", :git => "#{lib_path('rack')}"
200
+ G
201
+
202
+ should_be_installed "rack 1.0.0"
203
+ end
204
+
205
+ it "correctly unlocks when changing to a git source without versions" do
206
+ install_gemfile <<-G
207
+ source "file://#{gem_repo1}"
208
+ gem "rack"
209
+ G
210
+
211
+ build_git "rack", "1.2", :path => lib_path("rack")
212
+
213
+ install_gemfile <<-G
214
+ source "file://#{gem_repo1}"
215
+ gem "rack", :git => "#{lib_path('rack')}"
216
+ G
217
+
218
+ should_be_installed "rack 1.2"
219
+ end
220
+ end
221
+
222
+ describe "block syntax" do
223
+ it "pulls all gems from a git block" do
224
+ build_lib "omg", :path => lib_path('hi2u/omg')
225
+ build_lib "hi2u", :path => lib_path('hi2u')
226
+
227
+ install_gemfile <<-G
228
+ path "#{lib_path('hi2u')}" do
229
+ gem "omg"
230
+ gem "hi2u"
231
+ end
232
+ G
233
+
234
+ should_be_installed "omg 1.0", "hi2u 1.0"
235
+ end
236
+ end
237
+
238
+ it "uses a ref if specified" do
239
+ build_git "foo"
240
+ @revision = revision_for(lib_path("foo-1.0"))
241
+ update_git "foo"
242
+
243
+ install_gemfile <<-G
244
+ gem "foo", :git => "#{lib_path('foo-1.0')}", :ref => "#{@revision}"
245
+ G
246
+
247
+ run <<-RUBY
248
+ require 'foo'
249
+ puts "WIN" unless defined?(FOO_PREV_REF)
250
+ RUBY
251
+
252
+ out.should == "WIN"
253
+ end
254
+
255
+ it "correctly handles cases with invalid gemspecs" do
256
+ build_git "foo" do |s|
257
+ s.summary = nil
258
+ end
259
+
260
+ install_gemfile <<-G
261
+ source "file://#{gem_repo1}"
262
+ gem "foo", :git => "#{lib_path('foo-1.0')}"
263
+ gem "rails", "2.3.2"
264
+ G
265
+
266
+ should_be_installed "foo 1.0"
267
+ should_be_installed "rails 2.3.2"
268
+ end
269
+
270
+ it "runs the gemspec in the context of its parent directory" do
271
+ build_lib "bar", :path => lib_path("foo/bar"), :gemspec => false do |s|
272
+ s.write lib_path("foo/bar/lib/version.rb"), %{BAR_VERSION = '1.0'}
273
+ s.write "bar.gemspec", <<-G
274
+ $:.unshift Dir.pwd # For 1.9
275
+ require 'lib/version'
276
+ Gem::Specification.new do |s|
277
+ s.name = 'bar'
278
+ s.version = BAR_VERSION
279
+ s.summary = 'Bar'
280
+ s.files = Dir["lib/**/*.rb"]
281
+ end
282
+ G
283
+ end
284
+
285
+ build_git "foo", :path => lib_path("foo") do |s|
286
+ s.write "bin/foo", ""
287
+ end
288
+
289
+ install_gemfile <<-G
290
+ source "file://#{gem_repo1}"
291
+ gem "bar", :git => "#{lib_path("foo")}"
292
+ gem "rails", "2.3.2"
293
+ G
294
+
295
+ should_be_installed "bar 1.0"
296
+ should_be_installed "rails 2.3.2"
297
+ end
298
+
299
+ it "installs from git even if a rubygems gem is present" do
300
+ build_gem "foo", "1.0", :path => lib_path('fake_foo'), :to_system => true do |s|
301
+ s.write "lib/foo.rb", "raise 'FAIL'"
302
+ end
303
+
304
+ build_git "foo", "1.0"
305
+
306
+ install_gemfile <<-G
307
+ gem "foo", "1.0", :git => "#{lib_path('foo-1.0')}"
308
+ G
309
+
310
+ should_be_installed "foo 1.0"
311
+ end
312
+
313
+ it "fakes the gem out if there is no gemspec" do
314
+ build_git "foo", :gemspec => false
315
+
316
+ install_gemfile <<-G
317
+ source "file://#{gem_repo1}"
318
+ gem "foo", "1.0", :git => "#{lib_path('foo-1.0')}"
319
+ gem "rails", "2.3.2"
320
+ G
321
+
322
+ should_be_installed("foo 1.0")
323
+ should_be_installed("rails 2.3.2")
324
+ end
325
+
326
+ it "catches git errors and spits out useful output" do
327
+ gemfile <<-G
328
+ gem "foo", "1.0", :git => "omgomg"
329
+ G
330
+
331
+ bundle :install, :expect_err => true
332
+
333
+ out.should include("An error has occurred in git")
334
+ err.should include("fatal")
335
+ err.should include("omgomg")
336
+ err.should include("fatal: The remote end hung up unexpectedly")
337
+ end
338
+
339
+ it "works when the gem path has spaces in it" do
340
+ build_git "foo", :path => lib_path('foo space-1.0')
341
+
342
+ install_gemfile <<-G
343
+ gem "foo", :git => "#{lib_path('foo space-1.0')}"
344
+ G
345
+
346
+ should_be_installed "foo 1.0"
347
+ end
348
+
349
+ it "handles repos that have been force-pushed" do
350
+ build_git "forced", "1.0"
351
+
352
+ install_gemfile <<-G
353
+ git "#{lib_path('forced-1.0')}" do
354
+ gem 'forced'
355
+ end
356
+ G
357
+ should_be_installed "forced 1.0"
358
+
359
+ update_git "forced" do |s|
360
+ s.write "lib/forced.rb", "FORCED = '1.1'"
361
+ end
362
+
363
+ bundle "update"
364
+ should_be_installed "forced 1.1"
365
+
366
+ Dir.chdir(lib_path('forced-1.0')) do
367
+ `git reset --hard HEAD^`
368
+ end
369
+
370
+ bundle "update"
371
+ should_be_installed "forced 1.0"
372
+ end
373
+
374
+ it "ignores submodules if :submodule is not passed" do
375
+ build_git "submodule", "1.0"
376
+ build_git "has_submodule", "1.0" do |s|
377
+ s.add_dependency "submodule"
378
+ end
379
+ Dir.chdir(lib_path('has_submodule-1.0')) do
380
+ `git submodule add #{lib_path('submodule-1.0')} submodule-1.0`
381
+ `git commit -m "submodulator"`
382
+ end
383
+
384
+ install_gemfile <<-G, :expect_err => true
385
+ git "#{lib_path('has_submodule-1.0')}" do
386
+ gem "has_submodule"
387
+ end
388
+ G
389
+ out.should =~ /Could not find gem 'submodule'/
390
+
391
+ should_not_be_installed "has_submodule 1.0", :expect_err => true
392
+ end
393
+
394
+ it "handles repos with submodules" do
395
+ build_git "submodule", "1.0"
396
+ build_git "has_submodule", "1.0" do |s|
397
+ s.add_dependency "submodule"
398
+ end
399
+ Dir.chdir(lib_path('has_submodule-1.0')) do
400
+ `git submodule add #{lib_path('submodule-1.0')} submodule-1.0`
401
+ `git commit -m "submodulator"`
402
+ end
403
+
404
+ install_gemfile <<-G
405
+ git "#{lib_path('has_submodule-1.0')}", :submodules => true do
406
+ gem "has_submodule"
407
+ end
408
+ G
409
+
410
+ should_be_installed "has_submodule 1.0"
411
+ end
412
+
413
+ it "handles implicit updates when modifying the source info" do
414
+ git = build_git "foo"
415
+
416
+ install_gemfile <<-G
417
+ git "#{lib_path('foo-1.0')}" do
418
+ gem "foo"
419
+ end
420
+ G
421
+
422
+ update_git "foo"
423
+ update_git "foo"
424
+
425
+ install_gemfile <<-G
426
+ git "#{lib_path('foo-1.0')}", :ref => "#{git.ref_for('HEAD^')}" do
427
+ gem "foo"
428
+ end
429
+ G
430
+
431
+ run <<-RUBY
432
+ require 'foo'
433
+ puts "WIN" if FOO_PREV_REF == '#{git.ref_for("HEAD^^")}'
434
+ RUBY
435
+
436
+ out.should == "WIN"
437
+ end
438
+
439
+ it "does not to a remote fetch if the revision is cached locally" do
440
+ build_git "foo"
441
+
442
+ install_gemfile <<-G
443
+ gem "foo", :git => "#{lib_path('foo-1.0')}"
444
+ G
445
+
446
+ FileUtils.rm_rf(lib_path('foo-1.0'))
447
+
448
+ bundle "install"
449
+ out.should_not =~ /updating/i
450
+ end
451
+
452
+ it "doesn't blow up if bundle install is run twice in a row" do
453
+ build_git "foo"
454
+
455
+ gemfile <<-G
456
+ gem "foo", :git => "#{lib_path('foo-1.0')}"
457
+ G
458
+
459
+ bundle "install"
460
+ bundle "install", :exitstatus => true
461
+ exitstatus.should == 0
462
+ end
463
+
464
+ describe "switching sources" do
465
+ it "doesn't explode when switching Path to Git sources" do
466
+ build_gem "foo", "1.0", :to_system => true do |s|
467
+ s.write "lib/foo.rb", "raise 'fail'"
468
+ end
469
+ build_lib "foo", "1.0", :path => lib_path('bar/foo')
470
+ build_git "bar", "1.0", :path => lib_path('bar') do |s|
471
+ s.add_dependency 'foo'
472
+ end
473
+
474
+ install_gemfile <<-G
475
+ source "file://#{gem_repo1}"
476
+ gem "bar", :path => "#{lib_path('bar')}"
477
+ G
478
+
479
+ install_gemfile <<-G
480
+ source "file://#{gem_repo1}"
481
+ gem "bar", :git => "#{lib_path('bar')}"
482
+ G
483
+
484
+ should_be_installed "foo 1.0", "bar 1.0"
485
+ end
486
+
487
+ it "doesn't explode when switching Gem to Git source" do
488
+ install_gemfile <<-G
489
+ source "file://#{gem_repo1}"
490
+ gem "rack-obama"
491
+ gem "rack", "1.0.0"
492
+ G
493
+
494
+ build_git "rack", "1.0" do |s|
495
+ s.write "lib/new_file.rb", "puts 'USING GIT'"
496
+ end
497
+
498
+ install_gemfile <<-G
499
+ source "file://#{gem_repo1}"
500
+ gem "rack-obama"
501
+ gem "rack", "1.0.0", :git => "#{lib_path("rack-1.0")}"
502
+ G
503
+
504
+ run "require 'new_file'"
505
+ out.should == "USING GIT"
506
+ end
507
+ end
508
+
509
+ describe "bundle install after the remote has been updated" do
510
+ it "installs" do
511
+ build_git "valim"
512
+
513
+ install_gemfile <<-G
514
+ gem "valim", :git => "file://#{lib_path("valim-1.0")}"
515
+ G
516
+
517
+ old_revision = revision_for(lib_path("valim-1.0"))
518
+ update_git "valim"
519
+ new_revision = revision_for(lib_path("valim-1.0"))
520
+
521
+ lockfile = File.read(bundled_app("Gemfile.lock"))
522
+ File.open(bundled_app("Gemfile.lock"), "w") do |file|
523
+ file.puts lockfile.gsub(/revision: #{old_revision}/, "revision: #{new_revision}")
524
+ end
525
+
526
+ bundle "install"
527
+
528
+ run <<-R
529
+ require "valim"
530
+ puts VALIM_PREV_REF
531
+ R
532
+
533
+ out.should == old_revision
534
+ end
535
+ end
536
+
537
+ describe "bundle install --deployment with git sources" do
538
+ it "works" do
539
+ build_git "valim", :path => lib_path('valim')
540
+
541
+ install_gemfile <<-G
542
+ source "file://#{gem_repo1}"
543
+
544
+ gem "valim", "= 1.0", :git => "#{lib_path('valim')}"
545
+ G
546
+
547
+ simulate_new_machine
548
+
549
+ bundle "install --deployment", :exitstatus => true
550
+ exitstatus.should == 0
551
+ end
552
+ end
553
+ end