bundler-maglev- 1.0.21

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