bundler 1.4.0.rc.1 → 1.5.0.rc.1

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 (58) hide show
  1. data/.travis.yml +18 -15
  2. data/CHANGELOG.md +23 -2
  3. data/Rakefile +3 -1
  4. data/bundler.gemspec +1 -1
  5. data/lib/bundler.rb +3 -2
  6. data/lib/bundler/capistrano.rb +1 -0
  7. data/lib/bundler/cli.rb +19 -5
  8. data/lib/bundler/definition.rb +6 -2
  9. data/lib/bundler/dsl.rb +7 -3
  10. data/lib/bundler/endpoint_specification.rb +1 -1
  11. data/lib/bundler/fetcher.rb +22 -41
  12. data/lib/bundler/installer.rb +1 -11
  13. data/lib/bundler/lazy_specification.rb +1 -1
  14. data/lib/bundler/parallel_workers/unix_worker.rb +6 -0
  15. data/lib/bundler/remote_specification.rb +1 -1
  16. data/lib/bundler/retry.rb +4 -3
  17. data/lib/bundler/ruby_version.rb +1 -1
  18. data/lib/bundler/rubygems_ext.rb +7 -2
  19. data/lib/bundler/rubygems_integration.rb +31 -30
  20. data/lib/bundler/settings.rb +21 -0
  21. data/lib/bundler/source.rb +13 -2
  22. data/lib/bundler/source/git/git_proxy.rb +1 -1
  23. data/lib/bundler/source/rubygems.rb +43 -13
  24. data/lib/bundler/templates/newgem/README.md.tt +1 -1
  25. data/lib/bundler/templates/newgem/spec/newgem_spec.rb.tt +2 -2
  26. data/lib/bundler/version.rb +1 -1
  27. data/man/bundle-config.ronn +9 -0
  28. data/man/bundle-install.ronn +9 -5
  29. data/man/gemfile.5.ronn +6 -0
  30. data/spec/bundler/retry_spec.rb +26 -3
  31. data/spec/commands/config_spec.rb +14 -0
  32. data/spec/{integration/inject.rb → commands/inject_spec.rb} +0 -0
  33. data/spec/commands/newgem_spec.rb +2 -2
  34. data/spec/commands/outdated_spec.rb +17 -0
  35. data/spec/install/binstubs_spec.rb +24 -0
  36. data/spec/install/bundler_spec.rb +146 -0
  37. data/spec/install/{gemspec_spec.rb → gemfile/gemspec_spec.rb} +0 -0
  38. data/spec/install/{git_spec.rb → gemfile/git_spec.rb} +2 -2
  39. data/spec/install/gemfile/path_spec.rb +468 -0
  40. data/spec/install/gemfile_spec.rb +44 -0
  41. data/spec/install/gems/groups_spec.rb +236 -177
  42. data/spec/install/gems/mirror_spec.rb +39 -0
  43. data/spec/install/gems/platform_spec.rb +2 -14
  44. data/spec/install/gems/simple_case_spec.rb +1 -450
  45. data/spec/install/gemspecs_spec.rb +50 -0
  46. data/spec/install/path_spec.rb +91 -409
  47. data/spec/install/prereleases_spec.rb +43 -0
  48. data/spec/other/bundle_ruby_spec.rb +2 -2
  49. data/spec/other/ext_spec.rb +1 -1
  50. data/spec/other/platform_spec.rb +29 -2
  51. data/spec/realworld/parallel_install_spec.rb +2 -1
  52. data/spec/realworld/parallel_update_spec.rb +31 -0
  53. data/spec/runtime/platform_spec.rb +2 -2
  54. data/spec/spec_helper.rb +2 -2
  55. data/spec/support/{rubygems_hax/platform.rb → hax.rb} +0 -0
  56. metadata +110 -67
  57. checksums.yaml +0 -7
  58. data/spec/install/invalid_spec.rb +0 -50
@@ -53,6 +53,12 @@ engine version specified _must_ match the Ruby version.
53
53
 
54
54
  ruby "1.8.7", :engine => "jruby", :engine_version => "1.6.7"
55
55
 
56
+ ### PATCHLEVEL (:patchlevel)
57
+
58
+ Each application _may_ specify a Ruby patchlevel.
59
+
60
+ ruby "2.0.0", :patchlevel => "247"
61
+
56
62
  ## GEMS (#gem)
57
63
 
58
64
  Specify gem requirements using the `gem` method, with the following arguments.
@@ -3,7 +3,7 @@ require 'spec_helper'
3
3
  describe "bundle retry" do
4
4
  it "return successful result if no errors" do
5
5
  attempts = 0
6
- result = Bundler::Retry.new(nil, 3).attempt do
6
+ result = Bundler::Retry.new(nil, nil, 3).attempt do
7
7
  attempts += 1
8
8
  :success
9
9
  end
@@ -11,10 +11,21 @@ describe "bundle retry" do
11
11
  expect(attempts).to eq(1)
12
12
  end
13
13
 
14
+ it "defaults to retrying twice" do
15
+ attempts = 0
16
+ expect {
17
+ Bundler::Retry.new(nil).attempt do
18
+ attempts += 1
19
+ raise "nope"
20
+ end
21
+ }.to raise_error
22
+ expect(attempts).to eq(3)
23
+ end
24
+
14
25
  it "returns the first valid result" do
15
26
  jobs = [Proc.new{ raise "foo" }, Proc.new{ :bar }, Proc.new{ raise "foo" }]
16
27
  attempts = 0
17
- result = Bundler::Retry.new(nil, 3).attempt do
28
+ result = Bundler::Retry.new(nil, nil, 3).attempt do
18
29
  attempts += 1
19
30
  job = jobs.shift
20
31
  job.call
@@ -27,11 +38,23 @@ describe "bundle retry" do
27
38
  error = Bundler::GemfileNotFound
28
39
  attempts = 0
29
40
  expect {
30
- Bundler::Retry.new(nil, 3).attempt do
41
+ Bundler::Retry.new(nil, nil, 3).attempt do
31
42
  attempts += 1
32
43
  raise error
33
44
  end
34
45
  }.to raise_error(error)
35
46
  expect(attempts).to eq(4)
36
47
  end
48
+
49
+ it "raises exceptions" do
50
+ error = Bundler::GemfileNotFound
51
+ attempts = 0
52
+ expect {
53
+ Bundler::Retry.new(nil, error).attempt do
54
+ attempts += 1
55
+ raise error
56
+ end
57
+ }.to raise_error(error)
58
+ expect(attempts).to eq(1)
59
+ end
37
60
  end
@@ -178,4 +178,18 @@ describe ".bundle/config" do
178
178
  expect(out).to eq("false")
179
179
  end
180
180
  end
181
+
182
+ describe "gem mirrors" do
183
+ before(:each) { bundle :install }
184
+
185
+ it "configures mirrors using keys with `mirror.`" do
186
+ bundle "config --local mirror.http://gems.example.org http://gem-mirror.example.org"
187
+ run(<<-E)
188
+ Bundler.settings.gem_mirrors.each do |k, v|
189
+ puts "\#{k} => \#{v}"
190
+ end
191
+ E
192
+ expect(out).to eq("http://gems.example.org/ => http://gem-mirror.example.org/")
193
+ end
194
+ end
181
195
  end
@@ -154,7 +154,7 @@ describe "bundle gem" do
154
154
  end
155
155
 
156
156
  it "creates a default test which fails" do
157
- expect(bundled_app("test_gem/spec/test_gem_spec.rb").read).to match(/false.should be_true/)
157
+ expect(bundled_app("test_gem/spec/test_gem_spec.rb").read).to match(/expect(false).to be true/)
158
158
  end
159
159
  end
160
160
 
@@ -330,7 +330,7 @@ describe "bundle gem" do
330
330
  end
331
331
 
332
332
  it "creates a default test which fails" do
333
- expect(bundled_app("test-gem/spec/test/gem_spec.rb").read).to match(/false.should be_true/)
333
+ expect(bundled_app("test-gem/spec/test/gem_spec.rb").read).to match(/expect(false).to be true/)
334
334
  end
335
335
 
336
336
  it "creates a default rake task to run the specs" do
@@ -12,6 +12,7 @@ describe "bundle outdated" do
12
12
  gem "zebra", :git => "#{lib_path('zebra')}"
13
13
  gem "foo", :git => "#{lib_path('foo')}"
14
14
  gem "activesupport", "2.3.5"
15
+ gem "weakling", "~> 0.0.1"
15
16
  G
16
17
  end
17
18
 
@@ -19,6 +20,7 @@ describe "bundle outdated" do
19
20
  it "returns a sorted list of outdated gems" do
20
21
  update_repo2 do
21
22
  build_gem "activesupport", "3.0"
23
+ build_gem "weakling", "0.2"
22
24
  update_git "foo", :path => lib_path("foo")
23
25
  update_git "zebra", :path => lib_path("zebra")
24
26
  end
@@ -26,6 +28,7 @@ describe "bundle outdated" do
26
28
  bundle "outdated"
27
29
 
28
30
  expect(out).to include("activesupport (3.0 > 2.3.5) Gemfile specifies \"= 2.3.5\"")
31
+ expect(out).to include("weakling (0.2 > 0.0.3) Gemfile specifies \"~> 0.0.1\"")
29
32
  expect(out).to include("foo (1.0")
30
33
 
31
34
  # Gem names are one per-line, between "*" and their parenthesized version.
@@ -114,6 +117,20 @@ describe "bundle outdated" do
114
117
  end
115
118
  end
116
119
 
120
+ describe "with --strict option" do
121
+ it "only reports gems that have a newer version that matches the specified dependency version requirements" do
122
+ update_repo2 do
123
+ build_gem "activesupport", "3.0"
124
+ build_gem "weakling", "0.0.5"
125
+ end
126
+
127
+ bundle "outdated --strict"
128
+
129
+ expect(out).to_not include("activesupport (3.0 > 2.3.5) Gemfile specifies \"= 2.3.5\"")
130
+ expect(out).to include("weakling (0.0.5 > 0.0.3) Gemfile specifies \"~> 0.0.1\"")
131
+ end
132
+ end
133
+
117
134
  describe "with invalid gem name" do
118
135
  it "returns could not find gem name" do
119
136
  bundle "outdated invalid_gem_name"
@@ -0,0 +1,24 @@
1
+ require 'spec_helper'
2
+
3
+ describe "bundle install" do
4
+
5
+ describe "when system_bindir is set" do
6
+ # On OS X, Gem.bindir defaults to /usr/bin, so system_bindir is useful if
7
+ # you want to avoid sudo installs for system gems with OS X's default ruby
8
+ it "overrides Gem.bindir" do
9
+ expect(Pathname.new("/usr/bin")).not_to be_writable unless Process::euid == 0
10
+ gemfile <<-G
11
+ require 'rubygems'
12
+ def Gem.bindir; "/usr/bin"; end
13
+ source "file://#{gem_repo1}"
14
+ gem "rack"
15
+ G
16
+
17
+ config "BUNDLE_SYSTEM_BINDIR" => system_gem_path('altbin').to_s
18
+ bundle :install
19
+ should_be_installed "rack 1.0.0"
20
+ expect(system_gem_path("altbin/rackup")).to exist
21
+ end
22
+ end
23
+
24
+ end
@@ -0,0 +1,146 @@
1
+ require 'spec_helper'
2
+
3
+ describe "bundle install" do
4
+
5
+ describe "with bundler dependencies" do
6
+ before(:each) do
7
+ build_repo2 do
8
+ build_gem "rails", "3.0" do |s|
9
+ s.add_dependency "bundler", ">= 0.9.0.pre"
10
+ end
11
+ build_gem "bundler", "0.9.1"
12
+ build_gem "bundler", Bundler::VERSION
13
+ end
14
+ end
15
+
16
+ it "are forced to the current bundler version" do
17
+ install_gemfile <<-G
18
+ source "file://#{gem_repo2}"
19
+ gem "rails", "3.0"
20
+ G
21
+
22
+ should_be_installed "bundler #{Bundler::VERSION}"
23
+ end
24
+
25
+ it "are not added if not already present" do
26
+ install_gemfile <<-G
27
+ source "file://#{gem_repo1}"
28
+ gem "rack"
29
+ G
30
+ should_not_be_installed "bundler #{Bundler::VERSION}"
31
+ end
32
+
33
+ it "causes a conflict if explicitly requesting a different version" do
34
+ install_gemfile <<-G
35
+ source "file://#{gem_repo2}"
36
+ gem "rails", "3.0"
37
+ gem "bundler", "0.9.2"
38
+ G
39
+
40
+ nice_error = <<-E.strip.gsub(/^ {8}/, '')
41
+ Fetching source index from file:#{gem_repo2}/
42
+ Resolving dependencies...
43
+ Bundler could not find compatible versions for gem "bundler":
44
+ In Gemfile:
45
+ bundler (= 0.9.2) ruby
46
+
47
+ Current Bundler version:
48
+ bundler (#{Bundler::VERSION})
49
+ E
50
+ expect(out).to include(nice_error)
51
+ end
52
+
53
+ it "works for gems with multiple versions in its dependencies" do
54
+ install_gemfile <<-G
55
+ source "file://#{gem_repo2}"
56
+
57
+ gem "multiple_versioned_deps"
58
+ G
59
+
60
+
61
+ install_gemfile <<-G
62
+ source "file://#{gem_repo2}"
63
+
64
+ gem "multiple_versioned_deps"
65
+ gem "rack"
66
+ G
67
+
68
+ should_be_installed "multiple_versioned_deps 1.0.0"
69
+ end
70
+
71
+ it "includes bundler in the bundle when it's a child dependency" do
72
+ install_gemfile <<-G
73
+ source "file://#{gem_repo2}"
74
+ gem "rails", "3.0"
75
+ G
76
+
77
+ run "begin; gem 'bundler'; puts 'WIN'; rescue Gem::LoadError; puts 'FAIL'; end"
78
+ expect(out).to eq("WIN")
79
+ end
80
+
81
+ it "allows gem 'bundler' when Bundler is not in the Gemfile or its dependencies" do
82
+ install_gemfile <<-G
83
+ source "file://#{gem_repo2}"
84
+ gem "rack"
85
+ G
86
+
87
+ run "begin; gem 'bundler'; puts 'WIN'; rescue Gem::LoadError => e; puts e.backtrace; end"
88
+ expect(out).to eq("WIN")
89
+ end
90
+
91
+ it "causes a conflict if child dependencies conflict" do
92
+ install_gemfile <<-G
93
+ source "file://#{gem_repo2}"
94
+ gem "activemerchant"
95
+ gem "rails_fail"
96
+ G
97
+
98
+ nice_error = <<-E.strip.gsub(/^ {8}/, '')
99
+ Fetching source index from file:#{gem_repo2}/
100
+ Resolving dependencies...
101
+ Bundler could not find compatible versions for gem "activesupport":
102
+ In Gemfile:
103
+ activemerchant (>= 0) ruby depends on
104
+ activesupport (>= 2.0.0) ruby
105
+
106
+ rails_fail (>= 0) ruby depends on
107
+ activesupport (1.2.3)
108
+ E
109
+ expect(out).to eq(nice_error)
110
+ end
111
+
112
+ it "causes a conflict if a child dependency conflicts with the Gemfile" do
113
+ install_gemfile <<-G
114
+ source "file://#{gem_repo2}"
115
+ gem "rails_fail"
116
+ gem "activesupport", "2.3.5"
117
+ G
118
+
119
+ nice_error = <<-E.strip.gsub(/^ {8}/, '')
120
+ Fetching source index from file:#{gem_repo2}/
121
+ Resolving dependencies...
122
+ Bundler could not find compatible versions for gem "activesupport":
123
+ In Gemfile:
124
+ rails_fail (>= 0) ruby depends on
125
+ activesupport (= 1.2.3) ruby
126
+
127
+ activesupport (2.3.5)
128
+ E
129
+ expect(out).to eq(nice_error)
130
+ end
131
+
132
+ it "can install dependencies with newer bundler version" do
133
+ install_gemfile <<-G
134
+ source "file://#{gem_repo2}"
135
+ gem "rails", "3.0"
136
+ G
137
+
138
+ simulate_bundler_version "10.0.0"
139
+ #simulate_new_machine
140
+
141
+ bundle "check"
142
+ expect(out).to eq("The Gemfile's dependencies are satisfied")
143
+ end
144
+ end
145
+
146
+ end
@@ -27,7 +27,7 @@ describe "bundle install with git sources" do
27
27
  end
28
28
 
29
29
  it "caches the git repo" do
30
- expect(Dir["#{default_bundle_path}/cache/bundler/git/foo-1.0-*"]).to have(1).item
30
+ expect(Dir["#{default_bundle_path}/cache/bundler/git/foo-1.0-*"].size).to eq(1)
31
31
  end
32
32
 
33
33
  it "caches the evaluated gemspec" do
@@ -911,4 +911,4 @@ describe "bundle install with git sources" do
911
911
  expect(out).to include("You need to install git to be able to use gems from git repositories. For help installing git, please refer to GitHub's tutorial at https://help.github.com/articles/set-up-git")
912
912
  end
913
913
  end
914
- end
914
+ end
@@ -0,0 +1,468 @@
1
+ require "spec_helper"
2
+
3
+ describe "bundle install with explicit source paths" do
4
+ it "fetches gems" do
5
+ build_lib "foo"
6
+
7
+ install_gemfile <<-G
8
+ path "#{lib_path('foo-1.0')}"
9
+ gem 'foo'
10
+ G
11
+
12
+ should_be_installed("foo 1.0")
13
+ end
14
+
15
+ it "supports pinned paths" do
16
+ build_lib "foo"
17
+
18
+ install_gemfile <<-G
19
+ gem 'foo', :path => "#{lib_path('foo-1.0')}"
20
+ G
21
+
22
+ should_be_installed("foo 1.0")
23
+ end
24
+
25
+ it "supports relative paths" do
26
+ build_lib "foo"
27
+
28
+ relative_path = lib_path('foo-1.0').relative_path_from(Pathname.new(Dir.pwd))
29
+
30
+ install_gemfile <<-G
31
+ gem 'foo', :path => "#{relative_path}"
32
+ G
33
+
34
+ should_be_installed("foo 1.0")
35
+ end
36
+
37
+ it "expands paths" do
38
+ build_lib "foo"
39
+
40
+ relative_path = lib_path('foo-1.0').relative_path_from(Pathname.new('~').expand_path)
41
+
42
+ install_gemfile <<-G
43
+ gem 'foo', :path => "~/#{relative_path}"
44
+ G
45
+
46
+ should_be_installed("foo 1.0")
47
+ end
48
+
49
+ it "expands paths relative to Bundler.root" do
50
+ build_lib "foo", :path => bundled_app("foo-1.0")
51
+
52
+ install_gemfile <<-G
53
+ gem 'foo', :path => "./foo-1.0"
54
+ G
55
+
56
+ bundled_app("subdir").mkpath
57
+ Dir.chdir(bundled_app("subdir")) do
58
+ should_be_installed("foo 1.0")
59
+ end
60
+ end
61
+
62
+ it "expands paths when comparing locked paths to Gemfile paths" do
63
+ build_lib "foo", :path => bundled_app("foo-1.0")
64
+
65
+ install_gemfile <<-G
66
+ gem 'foo', :path => File.expand_path("../foo-1.0", __FILE__)
67
+ G
68
+
69
+ bundle "install --frozen", :exitstatus => true
70
+ expect(exitstatus).to eq(0)
71
+ end
72
+
73
+ it "installs dependencies from the path even if a newer gem is available elsewhere" do
74
+ system_gems "rack-1.0.0"
75
+
76
+ build_lib "rack", "1.0", :path => lib_path('nested/bar') do |s|
77
+ s.write "lib/rack.rb", "puts 'WIN OVERRIDE'"
78
+ end
79
+
80
+ build_lib "foo", :path => lib_path('nested') do |s|
81
+ s.add_dependency "rack", "= 1.0"
82
+ end
83
+
84
+ install_gemfile <<-G
85
+ source "file://#{gem_repo1}"
86
+ gem "foo", :path => "#{lib_path('nested')}"
87
+ G
88
+
89
+ run "require 'rack'"
90
+ expect(out).to eq('WIN OVERRIDE')
91
+ end
92
+
93
+ it "works" do
94
+ build_gem "foo", "1.0.0", :to_system => true do |s|
95
+ s.write "lib/foo.rb", "puts 'FAIL'"
96
+ end
97
+
98
+ build_lib "omg", "1.0", :path => lib_path("omg") do |s|
99
+ s.add_dependency "foo"
100
+ end
101
+
102
+ build_lib "foo", "1.0.0", :path => lib_path("omg/foo")
103
+
104
+ install_gemfile <<-G
105
+ gem "omg", :path => "#{lib_path('omg')}"
106
+ G
107
+
108
+ should_be_installed "foo 1.0"
109
+ end
110
+
111
+ it "supports gemspec syntax" do
112
+ build_lib "foo", "1.0", :path => lib_path("foo") do |s|
113
+ s.add_dependency "rack", "1.0"
114
+ end
115
+
116
+ gemfile = <<-G
117
+ source "file://#{gem_repo1}"
118
+ gemspec
119
+ G
120
+
121
+ File.open(lib_path("foo/Gemfile"), "w") {|f| f.puts gemfile }
122
+
123
+ Dir.chdir(lib_path("foo")) do
124
+ bundle "install"
125
+ should_be_installed "foo 1.0"
126
+ should_be_installed "rack 1.0"
127
+ end
128
+ end
129
+
130
+ it "supports gemspec syntax with an alternative path" do
131
+ build_lib "foo", "1.0", :path => lib_path("foo") do |s|
132
+ s.add_dependency "rack", "1.0"
133
+ end
134
+
135
+ install_gemfile <<-G
136
+ source "file://#{gem_repo1}"
137
+ gemspec :path => "#{lib_path("foo")}"
138
+ G
139
+
140
+ should_be_installed "foo 1.0"
141
+ should_be_installed "rack 1.0"
142
+ end
143
+
144
+ it "doesn't automatically unlock dependencies when using the gemspec syntax" do
145
+ build_lib "foo", "1.0", :path => lib_path("foo") do |s|
146
+ s.add_dependency "rack", ">= 1.0"
147
+ end
148
+
149
+ Dir.chdir lib_path("foo")
150
+
151
+ install_gemfile lib_path("foo/Gemfile"), <<-G
152
+ source "file://#{gem_repo1}"
153
+ gemspec
154
+ G
155
+
156
+ build_gem "rack", "1.0.1", :to_system => true
157
+
158
+ bundle "install"
159
+
160
+ should_be_installed "foo 1.0"
161
+ should_be_installed "rack 1.0"
162
+ end
163
+
164
+ it "doesn't automatically unlock dependencies when using the gemspec syntax and the gem has development dependencies" do
165
+ build_lib "foo", "1.0", :path => lib_path("foo") do |s|
166
+ s.add_dependency "rack", ">= 1.0"
167
+ s.add_development_dependency "activesupport"
168
+ end
169
+
170
+ Dir.chdir lib_path("foo")
171
+
172
+ install_gemfile lib_path("foo/Gemfile"), <<-G
173
+ source "file://#{gem_repo1}"
174
+ gemspec
175
+ G
176
+
177
+ build_gem "rack", "1.0.1", :to_system => true
178
+
179
+ bundle "install"
180
+
181
+ should_be_installed "foo 1.0"
182
+ should_be_installed "rack 1.0"
183
+ end
184
+
185
+ it "raises if there are multiple gemspecs" do
186
+ build_lib "foo", "1.0", :path => lib_path("foo") do |s|
187
+ s.write "bar.gemspec"
188
+ end
189
+
190
+ install_gemfile <<-G, :exitstatus => true
191
+ gemspec :path => "#{lib_path("foo")}"
192
+ G
193
+
194
+ expect(exitstatus).to eq(15)
195
+ expect(out).to match(/There are multiple gemspecs/)
196
+ end
197
+
198
+ it "allows :name to be specified to resolve ambiguity" do
199
+ build_lib "foo", "1.0", :path => lib_path("foo") do |s|
200
+ s.write "bar.gemspec"
201
+ end
202
+
203
+ install_gemfile <<-G, :exitstatus => true
204
+ gemspec :path => "#{lib_path("foo")}", :name => "foo"
205
+ G
206
+
207
+ should_be_installed "foo 1.0"
208
+ end
209
+
210
+ it "sets up executables" do
211
+ pending_jruby_shebang_fix
212
+
213
+ build_lib "foo" do |s|
214
+ s.executables = "foobar"
215
+ end
216
+
217
+ install_gemfile <<-G
218
+ path "#{lib_path('foo-1.0')}"
219
+ gem 'foo'
220
+ G
221
+
222
+ bundle "exec foobar"
223
+ expect(out).to eq("1.0")
224
+ end
225
+
226
+ it "handles directories in bin/" do
227
+ build_lib "foo"
228
+ lib_path("foo-1.0").join("foo.gemspec").rmtree
229
+ lib_path("foo-1.0").join("bin/performance").mkpath
230
+
231
+ install_gemfile <<-G
232
+ gem 'foo', '1.0', :path => "#{lib_path('foo-1.0')}"
233
+ G
234
+ expect(err).to eq("")
235
+ end
236
+
237
+ it "removes the .gem file after installing" do
238
+ build_lib "foo"
239
+
240
+ install_gemfile <<-G
241
+ gem 'foo', :path => "#{lib_path('foo-1.0')}"
242
+ G
243
+
244
+ expect(lib_path('foo-1.0').join('foo-1.0.gem')).not_to exist
245
+ end
246
+
247
+ describe "block syntax" do
248
+ it "pulls all gems from a path block" do
249
+ build_lib "omg"
250
+ build_lib "hi2u"
251
+
252
+ install_gemfile <<-G
253
+ path "#{lib_path}" do
254
+ gem "omg"
255
+ gem "hi2u"
256
+ end
257
+ G
258
+
259
+ should_be_installed "omg 1.0", "hi2u 1.0"
260
+ end
261
+ end
262
+
263
+ it "keeps source pinning" do
264
+ build_lib "foo", "1.0", :path => lib_path('foo')
265
+ build_lib "omg", "1.0", :path => lib_path('omg')
266
+ build_lib "foo", "1.0", :path => lib_path('omg/foo') do |s|
267
+ s.write "lib/foo.rb", "puts 'FAIL'"
268
+ end
269
+
270
+ install_gemfile <<-G
271
+ gem "foo", :path => "#{lib_path('foo')}"
272
+ gem "omg", :path => "#{lib_path('omg')}"
273
+ G
274
+
275
+ should_be_installed "foo 1.0"
276
+ end
277
+
278
+ it "works when the path does not have a gemspec" do
279
+ build_lib "foo", :gemspec => false
280
+
281
+ gemfile <<-G
282
+ gem "foo", "1.0", :path => "#{lib_path('foo-1.0')}"
283
+ G
284
+
285
+ should_be_installed "foo 1.0"
286
+
287
+ should_be_installed "foo 1.0"
288
+ end
289
+
290
+ it "installs executable stubs" do
291
+ build_lib "foo" do |s|
292
+ s.executables = ['foo']
293
+ end
294
+
295
+ install_gemfile <<-G
296
+ gem "foo", :path => "#{lib_path('foo-1.0')}"
297
+ G
298
+
299
+ bundle "exec foo"
300
+ expect(out).to eq("1.0")
301
+ end
302
+
303
+ describe "when the gem version in the path is updated" do
304
+ before :each do
305
+ build_lib "foo", "1.0", :path => lib_path("foo") do |s|
306
+ s.add_dependency "bar"
307
+ end
308
+ build_lib "bar", "1.0", :path => lib_path("foo/bar")
309
+
310
+ install_gemfile <<-G
311
+ gem "foo", :path => "#{lib_path('foo')}"
312
+ G
313
+ end
314
+
315
+ it "unlocks all gems when the top level gem is updated" do
316
+ build_lib "foo", "2.0", :path => lib_path("foo") do |s|
317
+ s.add_dependency "bar"
318
+ end
319
+
320
+ bundle "install"
321
+
322
+ should_be_installed "foo 2.0", "bar 1.0"
323
+ end
324
+
325
+ it "unlocks all gems when a child dependency gem is updated" do
326
+ build_lib "bar", "2.0", :path => lib_path("foo/bar")
327
+
328
+ bundle "install"
329
+
330
+ should_be_installed "foo 1.0", "bar 2.0"
331
+ end
332
+ end
333
+
334
+ describe "when dependencies in the path are updated" do
335
+ before :each do
336
+ build_lib "foo", "1.0", :path => lib_path("foo")
337
+
338
+ install_gemfile <<-G
339
+ source "file://#{gem_repo1}"
340
+ gem "foo", :path => "#{lib_path('foo')}"
341
+ G
342
+ end
343
+
344
+ it "gets dependencies that are updated in the path" do
345
+ build_lib "foo", "1.0", :path => lib_path("foo") do |s|
346
+ s.add_dependency "rack"
347
+ end
348
+
349
+ bundle "install"
350
+
351
+ should_be_installed "rack 1.0.0"
352
+ end
353
+ end
354
+
355
+ describe "switching sources" do
356
+ it "doesn't switch pinned git sources to rubygems when pinning the parent gem to a path source" do
357
+ build_gem "foo", "1.0", :to_system => true do |s|
358
+ s.write "lib/foo.rb", "raise 'fail'"
359
+ end
360
+ build_lib "foo", "1.0", :path => lib_path('bar/foo')
361
+ build_git "bar", "1.0", :path => lib_path('bar') do |s|
362
+ s.add_dependency 'foo'
363
+ end
364
+
365
+ install_gemfile <<-G
366
+ source "file://#{gem_repo1}"
367
+ gem "bar", :git => "#{lib_path('bar')}"
368
+ G
369
+
370
+ install_gemfile <<-G
371
+ source "file://#{gem_repo1}"
372
+ gem "bar", :path => "#{lib_path('bar')}"
373
+ G
374
+
375
+ should_be_installed "foo 1.0", "bar 1.0"
376
+ end
377
+
378
+ it "switches the source when the gem existed in rubygems and the path was already being used for another gem" do
379
+ build_lib "foo", "1.0", :path => lib_path("foo")
380
+ build_gem "bar", "1.0", :to_system => true do |s|
381
+ s.write "lib/bar.rb", "raise 'fail'"
382
+ end
383
+
384
+ install_gemfile <<-G
385
+ source "file://#{gem_repo1}"
386
+ gem "bar"
387
+ path "#{lib_path('foo')}" do
388
+ gem "foo"
389
+ end
390
+ G
391
+
392
+ build_lib "bar", "1.0", :path => lib_path("foo/bar")
393
+
394
+ install_gemfile <<-G
395
+ source "file://#{gem_repo1}"
396
+ path "#{lib_path('foo')}" do
397
+ gem "foo"
398
+ gem "bar"
399
+ end
400
+ G
401
+
402
+ should_be_installed "bar 1.0"
403
+ end
404
+ end
405
+
406
+ describe "gem install hooks" do
407
+ it "runs pre-install hooks" do
408
+ build_git "foo"
409
+ gemfile <<-G
410
+ gem "foo", :git => "#{lib_path('foo-1.0')}"
411
+ G
412
+
413
+ File.open(lib_path("install_hooks.rb"), "w") do |h|
414
+ h.write <<-H
415
+ require 'rubygems'
416
+ Gem.pre_install_hooks << lambda do |inst|
417
+ STDERR.puts "Ran pre-install hook: \#{inst.spec.full_name}"
418
+ end
419
+ H
420
+ end
421
+
422
+ bundle :install, :expect_err => true,
423
+ :requires => [lib_path('install_hooks.rb')]
424
+ expect(err).to eq("Ran pre-install hook: foo-1.0")
425
+ end
426
+
427
+ it "runs post-install hooks" do
428
+ build_git "foo"
429
+ gemfile <<-G
430
+ gem "foo", :git => "#{lib_path('foo-1.0')}"
431
+ G
432
+
433
+ File.open(lib_path("install_hooks.rb"), "w") do |h|
434
+ h.write <<-H
435
+ require 'rubygems'
436
+ Gem.post_install_hooks << lambda do |inst|
437
+ STDERR.puts "Ran post-install hook: \#{inst.spec.full_name}"
438
+ end
439
+ H
440
+ end
441
+
442
+ bundle :install, :expect_err => true,
443
+ :requires => [lib_path('install_hooks.rb')]
444
+ expect(err).to eq("Ran post-install hook: foo-1.0")
445
+ end
446
+
447
+ it "complains if the install hook fails" do
448
+ build_git "foo"
449
+ gemfile <<-G
450
+ gem "foo", :git => "#{lib_path('foo-1.0')}"
451
+ G
452
+
453
+ File.open(lib_path("install_hooks.rb"), "w") do |h|
454
+ h.write <<-H
455
+ require 'rubygems'
456
+ Gem.pre_install_hooks << lambda do |inst|
457
+ false
458
+ end
459
+ H
460
+ end
461
+
462
+ bundle :install, :expect_err => true,
463
+ :requires => [lib_path('install_hooks.rb')]
464
+ expect(out).to include("failed for foo-1.0")
465
+ end
466
+ end
467
+
468
+ end