bundler_package_git 1.1.pre.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (149) hide show
  1. data/.gitignore +22 -0
  2. data/.rvmrc +1 -0
  3. data/CHANGELOG.md +659 -0
  4. data/ISSUES.md +47 -0
  5. data/LICENSE +23 -0
  6. data/README.md +29 -0
  7. data/Rakefile +167 -0
  8. data/UPGRADING.md +103 -0
  9. data/bin/bundle +22 -0
  10. data/bundler.gemspec +30 -0
  11. data/lib/bundler.rb +283 -0
  12. data/lib/bundler/capistrano.rb +11 -0
  13. data/lib/bundler/cli.rb +490 -0
  14. data/lib/bundler/definition.rb +429 -0
  15. data/lib/bundler/dependency.rb +130 -0
  16. data/lib/bundler/deployment.rb +53 -0
  17. data/lib/bundler/dsl.rb +243 -0
  18. data/lib/bundler/environment.rb +47 -0
  19. data/lib/bundler/fetcher.rb +101 -0
  20. data/lib/bundler/gem_helper.rb +146 -0
  21. data/lib/bundler/graph.rb +130 -0
  22. data/lib/bundler/index.rb +131 -0
  23. data/lib/bundler/installer.rb +117 -0
  24. data/lib/bundler/lazy_specification.rb +71 -0
  25. data/lib/bundler/lockfile_parser.rb +108 -0
  26. data/lib/bundler/remote_specification.rb +57 -0
  27. data/lib/bundler/resolver.rb +470 -0
  28. data/lib/bundler/rubygems_ext.rb +226 -0
  29. data/lib/bundler/runtime.rb +201 -0
  30. data/lib/bundler/settings.rb +117 -0
  31. data/lib/bundler/setup.rb +16 -0
  32. data/lib/bundler/shared_helpers.rb +167 -0
  33. data/lib/bundler/source.rb +675 -0
  34. data/lib/bundler/spec_set.rb +134 -0
  35. data/lib/bundler/templates/Executable +16 -0
  36. data/lib/bundler/templates/Gemfile +4 -0
  37. data/lib/bundler/templates/newgem/Gemfile.tt +4 -0
  38. data/lib/bundler/templates/newgem/Rakefile.tt +2 -0
  39. data/lib/bundler/templates/newgem/bin/newgem.tt +3 -0
  40. data/lib/bundler/templates/newgem/gitignore.tt +4 -0
  41. data/lib/bundler/templates/newgem/lib/newgem.rb.tt +7 -0
  42. data/lib/bundler/templates/newgem/lib/newgem/version.rb.tt +7 -0
  43. data/lib/bundler/templates/newgem/newgem.gemspec.tt +21 -0
  44. data/lib/bundler/ui.rb +73 -0
  45. data/lib/bundler/vendor/net/http/faster.rb +27 -0
  46. data/lib/bundler/vendor/net/http/persistent.rb +464 -0
  47. data/lib/bundler/vendor/thor.rb +319 -0
  48. data/lib/bundler/vendor/thor/actions.rb +297 -0
  49. data/lib/bundler/vendor/thor/actions/create_file.rb +105 -0
  50. data/lib/bundler/vendor/thor/actions/directory.rb +93 -0
  51. data/lib/bundler/vendor/thor/actions/empty_directory.rb +134 -0
  52. data/lib/bundler/vendor/thor/actions/file_manipulation.rb +229 -0
  53. data/lib/bundler/vendor/thor/actions/inject_into_file.rb +104 -0
  54. data/lib/bundler/vendor/thor/base.rb +556 -0
  55. data/lib/bundler/vendor/thor/core_ext/file_binary_read.rb +9 -0
  56. data/lib/bundler/vendor/thor/core_ext/hash_with_indifferent_access.rb +75 -0
  57. data/lib/bundler/vendor/thor/core_ext/ordered_hash.rb +100 -0
  58. data/lib/bundler/vendor/thor/error.rb +30 -0
  59. data/lib/bundler/vendor/thor/invocation.rb +168 -0
  60. data/lib/bundler/vendor/thor/parser.rb +4 -0
  61. data/lib/bundler/vendor/thor/parser/argument.rb +67 -0
  62. data/lib/bundler/vendor/thor/parser/arguments.rb +161 -0
  63. data/lib/bundler/vendor/thor/parser/option.rb +120 -0
  64. data/lib/bundler/vendor/thor/parser/options.rb +174 -0
  65. data/lib/bundler/vendor/thor/shell.rb +88 -0
  66. data/lib/bundler/vendor/thor/shell/basic.rb +275 -0
  67. data/lib/bundler/vendor/thor/shell/color.rb +108 -0
  68. data/lib/bundler/vendor/thor/shell/html.rb +121 -0
  69. data/lib/bundler/vendor/thor/task.rb +114 -0
  70. data/lib/bundler/vendor/thor/util.rb +229 -0
  71. data/lib/bundler/vendor/thor/version.rb +3 -0
  72. data/lib/bundler/version.rb +6 -0
  73. data/lib/bundler/vlad.rb +9 -0
  74. data/man/bundle-config.ronn +90 -0
  75. data/man/bundle-exec.ronn +111 -0
  76. data/man/bundle-install.ronn +314 -0
  77. data/man/bundle-package.ronn +59 -0
  78. data/man/bundle-update.ronn +176 -0
  79. data/man/bundle.ronn +80 -0
  80. data/man/gemfile.5.ronn +279 -0
  81. data/man/index.txt +6 -0
  82. data/spec/cache/gems_spec.rb +219 -0
  83. data/spec/cache/git_spec.rb +9 -0
  84. data/spec/cache/path_spec.rb +27 -0
  85. data/spec/cache/platform_spec.rb +57 -0
  86. data/spec/install/deploy_spec.rb +197 -0
  87. data/spec/install/deprecated_spec.rb +37 -0
  88. data/spec/install/gems/c_ext_spec.rb +48 -0
  89. data/spec/install/gems/dependency_api_spec.rb +85 -0
  90. data/spec/install/gems/env_spec.rb +107 -0
  91. data/spec/install/gems/flex_spec.rb +313 -0
  92. data/spec/install/gems/groups_spec.rb +245 -0
  93. data/spec/install/gems/packed_spec.rb +84 -0
  94. data/spec/install/gems/platform_spec.rb +208 -0
  95. data/spec/install/gems/resolving_spec.rb +72 -0
  96. data/spec/install/gems/simple_case_spec.rb +715 -0
  97. data/spec/install/gems/standalone_spec.rb +162 -0
  98. data/spec/install/gems/sudo_spec.rb +73 -0
  99. data/spec/install/gems/win32_spec.rb +26 -0
  100. data/spec/install/gemspec_spec.rb +108 -0
  101. data/spec/install/git_spec.rb +571 -0
  102. data/spec/install/invalid_spec.rb +17 -0
  103. data/spec/install/path_spec.rb +353 -0
  104. data/spec/install/upgrade_spec.rb +26 -0
  105. data/spec/lock/git_spec.rb +35 -0
  106. data/spec/lock/lockfile_spec.rb +683 -0
  107. data/spec/other/check_spec.rb +221 -0
  108. data/spec/other/clean_spec.rb +202 -0
  109. data/spec/other/config_spec.rb +40 -0
  110. data/spec/other/console_spec.rb +54 -0
  111. data/spec/other/exec_spec.rb +241 -0
  112. data/spec/other/ext_spec.rb +16 -0
  113. data/spec/other/gem_helper_spec.rb +128 -0
  114. data/spec/other/help_spec.rb +38 -0
  115. data/spec/other/init_spec.rb +40 -0
  116. data/spec/other/newgem_spec.rb +24 -0
  117. data/spec/other/open_spec.rb +35 -0
  118. data/spec/other/show_spec.rb +82 -0
  119. data/spec/pack/gems_spec.rb +54 -0
  120. data/spec/quality_spec.rb +58 -0
  121. data/spec/resolver/basic_spec.rb +20 -0
  122. data/spec/resolver/platform_spec.rb +82 -0
  123. data/spec/runtime/executable_spec.rb +110 -0
  124. data/spec/runtime/load_spec.rb +107 -0
  125. data/spec/runtime/platform_spec.rb +90 -0
  126. data/spec/runtime/require_spec.rb +231 -0
  127. data/spec/runtime/setup_spec.rb +688 -0
  128. data/spec/runtime/with_clean_env_spec.rb +15 -0
  129. data/spec/spec_helper.rb +85 -0
  130. data/spec/support/artifice/endpoint.rb +50 -0
  131. data/spec/support/artifice/endpoint_fallback.rb +22 -0
  132. data/spec/support/artifice/endpoint_marshal_fail.rb +11 -0
  133. data/spec/support/artifice/endpoint_redirect.rb +11 -0
  134. data/spec/support/builders.rb +574 -0
  135. data/spec/support/fakeweb/rack-1.0.0.marshal +2 -0
  136. data/spec/support/fakeweb/windows.rb +23 -0
  137. data/spec/support/helpers.rb +246 -0
  138. data/spec/support/indexes.rb +112 -0
  139. data/spec/support/matchers.rb +89 -0
  140. data/spec/support/path.rb +73 -0
  141. data/spec/support/platforms.rb +53 -0
  142. data/spec/support/ruby_ext.rb +20 -0
  143. data/spec/support/rubygems_ext.rb +35 -0
  144. data/spec/support/rubygems_hax/platform.rb +11 -0
  145. data/spec/support/sudo.rb +21 -0
  146. data/spec/update/gems_spec.rb +121 -0
  147. data/spec/update/git_spec.rb +196 -0
  148. data/spec/update/source_spec.rb +51 -0
  149. metadata +294 -0
@@ -0,0 +1,162 @@
1
+ require "spec_helper"
2
+
3
+ describe "bundle install --standalone" do
4
+ describe "with simple gems" do
5
+ before do
6
+ install_gemfile <<-G, :standalone => true
7
+ source "file://#{gem_repo1}"
8
+ gem "rails"
9
+ G
10
+ end
11
+
12
+ it "still makes the gems available to normal bundler" do
13
+ should_be_installed "actionpack 2.3.2", "rails 2.3.2"
14
+ end
15
+
16
+ it "generates a bundle/bundler/setup.rb" do
17
+ bundled_app("bundle/bundler/setup.rb").should exist
18
+ end
19
+
20
+ it "makes the gems available without bundler" do
21
+ ruby <<-RUBY, :no_lib => true
22
+ $:.unshift File.expand_path("bundle")
23
+ require "bundler/setup"
24
+
25
+ require "actionpack"
26
+ puts ACTIONPACK
27
+ RUBY
28
+
29
+ out.should == "2.3.2"
30
+ end
31
+
32
+ it "works on a different system" do
33
+ FileUtils.mv(bundled_app, "#{bundled_app}2")
34
+ Dir.chdir("#{bundled_app}2")
35
+
36
+ ruby <<-RUBY, :no_lib => true
37
+ $:.unshift File.expand_path("bundle")
38
+ require "bundler/setup"
39
+
40
+ require "actionpack"
41
+ puts ACTIONPACK
42
+ RUBY
43
+
44
+ out.should == "2.3.2"
45
+ end
46
+ end
47
+
48
+ describe "with a combination of gems and git repos" do
49
+ before do
50
+ build_git "devise", "1.0"
51
+
52
+ install_gemfile <<-G, :standalone => true
53
+ source "file://#{gem_repo1}"
54
+ gem "rails"
55
+ gem "devise", :git => "#{lib_path('devise-1.0')}"
56
+ G
57
+ end
58
+
59
+ it "still makes the gems available to normal bundler" do
60
+ should_be_installed "actionpack 2.3.2", "rails 2.3.2", "devise 1.0"
61
+ end
62
+
63
+ it "generates a bundle/bundler/setup.rb" do
64
+ bundled_app("bundle/bundler/setup.rb").should exist
65
+ end
66
+
67
+ it "makes the gems available without bundler" do
68
+ ruby <<-RUBY, :no_lib => true
69
+ $:.unshift File.expand_path("bundle")
70
+ require "bundler/setup"
71
+
72
+ require "devise"
73
+ require "actionpack"
74
+ puts DEVISE
75
+ puts ACTIONPACK
76
+ RUBY
77
+
78
+ out.should == "1.0\n2.3.2"
79
+ end
80
+ end
81
+
82
+ describe "with groups" do
83
+ before do
84
+ build_git "devise", "1.0"
85
+
86
+ install_gemfile <<-G, :standalone => true
87
+ source "file://#{gem_repo1}"
88
+ gem "rails"
89
+
90
+ group :test do
91
+ gem "rspec"
92
+ gem "rack-test"
93
+ end
94
+ G
95
+ end
96
+
97
+ it "makes the gems available without bundler" do
98
+ ruby <<-RUBY, :no_lib => true
99
+ $:.unshift File.expand_path("bundle")
100
+ require "bundler/setup"
101
+
102
+ require "actionpack"
103
+ require "spec"
104
+ require "rack/test"
105
+ puts ACTIONPACK
106
+ puts SPEC
107
+ puts RACK_TEST
108
+ RUBY
109
+
110
+ out.should == "2.3.2\n1.2.7\n1.0"
111
+ end
112
+
113
+ it "allows creating a standalone file with limited groups" do
114
+ bundle "install --standalone default"
115
+
116
+ ruby <<-RUBY, :no_lib => true, :expect_err => true
117
+ $:.unshift File.expand_path("bundle")
118
+ require "bundler/setup"
119
+
120
+ require "actionpack"
121
+ puts ACTIONPACK
122
+ require "spec"
123
+ RUBY
124
+
125
+ out.should == "2.3.2"
126
+ err.should =~ /no such file to load.*spec/
127
+ end
128
+
129
+ it "allows --without to limit the groups used in a standalone" do
130
+ bundle "install --standalone --without test"
131
+
132
+ ruby <<-RUBY, :no_lib => true, :expect_err => true
133
+ $:.unshift File.expand_path("bundle")
134
+ require "bundler/setup"
135
+
136
+ require "actionpack"
137
+ puts ACTIONPACK
138
+ require "spec"
139
+ RUBY
140
+
141
+ out.should == "2.3.2"
142
+ err.should =~ /no such file to load.*spec/
143
+ end
144
+
145
+ it "allows remembered --without to limit the groups used in a standalone" do
146
+ bundle "install --without test"
147
+ bundle "install --standalone"
148
+
149
+ ruby <<-RUBY, :no_lib => true, :expect_err => true
150
+ $:.unshift File.expand_path("bundle")
151
+ require "bundler/setup"
152
+
153
+ require "actionpack"
154
+ puts ACTIONPACK
155
+ require "spec"
156
+ RUBY
157
+
158
+ out.should == "2.3.2"
159
+ err.should =~ /no such file to load.*spec/
160
+ end
161
+ end
162
+ end
@@ -0,0 +1,73 @@
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
+ G
14
+
15
+ system_gem_path("gems/rack-1.0.0").should exist
16
+ check system_gem_path("gems/rack-1.0.0").stat.uid.should == 0
17
+ should_be_installed "rack 1.0"
18
+ end
19
+
20
+ it "installs when BUNDLE_PATH is owned by root" do
21
+ bundle_path = tmp("owned_by_root")
22
+ FileUtils.mkdir_p bundle_path
23
+ sudo "chown -R root #{bundle_path}"
24
+
25
+ ENV['BUNDLE_PATH'] = bundle_path.to_s
26
+ install_gemfile <<-G
27
+ source "file://#{gem_repo1}"
28
+ gem "rack", '1.0'
29
+ G
30
+
31
+ bundle_path.join("gems/rack-1.0.0").should exist
32
+ check bundle_path.join("gems/rack-1.0.0").stat.uid.should == 0
33
+ should_be_installed "rack 1.0"
34
+ end
35
+
36
+ it "installs when BUNDLE_PATH does not exist"
37
+ end
38
+
39
+ describe "and BUNDLE_PATH is not writable" do
40
+ it "installs" do
41
+ sudo "chmod ugo-w #{default_bundle_path}"
42
+ install_gemfile <<-G
43
+ source "file://#{gem_repo1}"
44
+ gem "rack", '1.0'
45
+ G
46
+
47
+ default_bundle_path("gems/rack-1.0.0").should exist
48
+ should_be_installed "rack 1.0"
49
+ end
50
+ end
51
+
52
+ describe "and BUNDLE_PATH is not writable" do
53
+ it "installs" do
54
+ begin
55
+ gem_home = tmp('sudo_gem_home')
56
+
57
+ sudo "mkdir -p #{gem_home}"
58
+ sudo "chmod ugo-w #{gem_home}"
59
+ ENV['GEM_HOME'] = gem_home.to_s
60
+ ENV['GEM_PATH'] = nil
61
+
62
+ install_gemfile <<-G
63
+ source "file://#{gem_repo1}"
64
+ gem "rack", '1.0'
65
+ G
66
+
67
+ gem_home.join('bin/rackup').should exist
68
+ should_be_installed "rack 1.0"
69
+ end
70
+ end
71
+ end
72
+
73
+ 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,108 @@
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
+ it "should evaluate the gemspec in its directory" do
97
+ build_lib("foo", :path => tmp.join("foo"))
98
+ File.open(tmp.join("foo/foo.gemspec"), "w") do |s|
99
+ s.write "raise 'ahh' unless Dir.pwd == '#{tmp.join("foo")}'"
100
+ end
101
+
102
+ install_gemfile <<-G, :expect_err => true
103
+ gemspec :path => '#{tmp.join("foo")}'
104
+ G
105
+ @err.should_not match(/ahh/)
106
+ end
107
+
108
+ end
@@ -0,0 +1,571 @@
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
+ check err.should == ""
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("An error has occurred in git")
352
+ err.should include("fatal")
353
+ err.should include("omgomg")
354
+ err.should include("fatal: The remote end hung up unexpectedly")
355
+ end
356
+
357
+ it "works when the gem path has spaces in it" do
358
+ build_git "foo", :path => lib_path('foo space-1.0')
359
+
360
+ install_gemfile <<-G
361
+ gem "foo", :git => "#{lib_path('foo space-1.0')}"
362
+ G
363
+
364
+ should_be_installed "foo 1.0"
365
+ end
366
+
367
+ it "handles repos that have been force-pushed" do
368
+ build_git "forced", "1.0"
369
+
370
+ install_gemfile <<-G
371
+ git "#{lib_path('forced-1.0')}" do
372
+ gem 'forced'
373
+ end
374
+ G
375
+ should_be_installed "forced 1.0"
376
+
377
+ update_git "forced" do |s|
378
+ s.write "lib/forced.rb", "FORCED = '1.1'"
379
+ end
380
+
381
+ bundle "update"
382
+ should_be_installed "forced 1.1"
383
+
384
+ Dir.chdir(lib_path('forced-1.0')) do
385
+ `git reset --hard HEAD^`
386
+ end
387
+
388
+ bundle "update"
389
+ should_be_installed "forced 1.0"
390
+ end
391
+
392
+ it "ignores submodules if :submodule is not passed" do
393
+ build_git "submodule", "1.0"
394
+ build_git "has_submodule", "1.0" do |s|
395
+ s.add_dependency "submodule"
396
+ end
397
+ Dir.chdir(lib_path('has_submodule-1.0')) do
398
+ `git submodule add #{lib_path('submodule-1.0')} submodule-1.0`
399
+ `git commit -m "submodulator"`
400
+ end
401
+
402
+ install_gemfile <<-G, :expect_err => true
403
+ git "#{lib_path('has_submodule-1.0')}" do
404
+ gem "has_submodule"
405
+ end
406
+ G
407
+ out.should =~ /Could not find gem 'submodule'/
408
+
409
+ should_not_be_installed "has_submodule 1.0", :expect_err => true
410
+ end
411
+
412
+ it "handles repos with submodules" do
413
+ build_git "submodule", "1.0"
414
+ build_git "has_submodule", "1.0" do |s|
415
+ s.add_dependency "submodule"
416
+ end
417
+ Dir.chdir(lib_path('has_submodule-1.0')) do
418
+ `git submodule add #{lib_path('submodule-1.0')} submodule-1.0`
419
+ `git commit -m "submodulator"`
420
+ end
421
+
422
+ install_gemfile <<-G
423
+ git "#{lib_path('has_submodule-1.0')}", :submodules => true do
424
+ gem "has_submodule"
425
+ end
426
+ G
427
+
428
+ should_be_installed "has_submodule 1.0"
429
+ end
430
+
431
+ it "handles implicit updates when modifying the source info" do
432
+ git = build_git "foo"
433
+
434
+ install_gemfile <<-G
435
+ git "#{lib_path('foo-1.0')}" do
436
+ gem "foo"
437
+ end
438
+ G
439
+
440
+ update_git "foo"
441
+ update_git "foo"
442
+
443
+ install_gemfile <<-G
444
+ git "#{lib_path('foo-1.0')}", :ref => "#{git.ref_for('HEAD^')}" do
445
+ gem "foo"
446
+ end
447
+ G
448
+
449
+ run <<-RUBY
450
+ require 'foo'
451
+ puts "WIN" if FOO_PREV_REF == '#{git.ref_for("HEAD^^")}'
452
+ RUBY
453
+
454
+ out.should == "WIN"
455
+ end
456
+
457
+ it "does not to a remote fetch if the revision is cached locally" do
458
+ build_git "foo"
459
+
460
+ install_gemfile <<-G
461
+ gem "foo", :git => "#{lib_path('foo-1.0')}"
462
+ G
463
+
464
+ FileUtils.rm_rf(lib_path('foo-1.0'))
465
+
466
+ bundle "install"
467
+ out.should_not =~ /updating/i
468
+ end
469
+
470
+ it "doesn't blow up if bundle install is run twice in a row" do
471
+ build_git "foo"
472
+
473
+ gemfile <<-G
474
+ gem "foo", :git => "#{lib_path('foo-1.0')}"
475
+ G
476
+
477
+ bundle "install"
478
+ bundle "install", :exitstatus => true
479
+ exitstatus.should == 0
480
+ end
481
+
482
+ describe "switching sources" do
483
+ it "doesn't explode when switching Path to Git sources" do
484
+ build_gem "foo", "1.0", :to_system => true do |s|
485
+ s.write "lib/foo.rb", "raise 'fail'"
486
+ end
487
+ build_lib "foo", "1.0", :path => lib_path('bar/foo')
488
+ build_git "bar", "1.0", :path => lib_path('bar') do |s|
489
+ s.add_dependency 'foo'
490
+ end
491
+
492
+ install_gemfile <<-G
493
+ source "file://#{gem_repo1}"
494
+ gem "bar", :path => "#{lib_path('bar')}"
495
+ G
496
+
497
+ install_gemfile <<-G
498
+ source "file://#{gem_repo1}"
499
+ gem "bar", :git => "#{lib_path('bar')}"
500
+ G
501
+
502
+ should_be_installed "foo 1.0", "bar 1.0"
503
+ end
504
+
505
+ it "doesn't explode when switching Gem to Git source" do
506
+ install_gemfile <<-G
507
+ source "file://#{gem_repo1}"
508
+ gem "rack-obama"
509
+ gem "rack", "1.0.0"
510
+ G
511
+
512
+ build_git "rack", "1.0" do |s|
513
+ s.write "lib/new_file.rb", "puts 'USING GIT'"
514
+ end
515
+
516
+ install_gemfile <<-G
517
+ source "file://#{gem_repo1}"
518
+ gem "rack-obama"
519
+ gem "rack", "1.0.0", :git => "#{lib_path("rack-1.0")}"
520
+ G
521
+
522
+ run "require 'new_file'"
523
+ out.should == "USING GIT"
524
+ end
525
+ end
526
+
527
+ describe "bundle install after the remote has been updated" do
528
+ it "installs" do
529
+ build_git "valim"
530
+
531
+ install_gemfile <<-G
532
+ gem "valim", :git => "file://#{lib_path("valim-1.0")}"
533
+ G
534
+
535
+ old_revision = revision_for(lib_path("valim-1.0"))
536
+ update_git "valim"
537
+ new_revision = revision_for(lib_path("valim-1.0"))
538
+
539
+ lockfile = File.read(bundled_app("Gemfile.lock"))
540
+ File.open(bundled_app("Gemfile.lock"), "w") do |file|
541
+ file.puts lockfile.gsub(/revision: #{old_revision}/, "revision: #{new_revision}")
542
+ end
543
+
544
+ bundle "install"
545
+
546
+ run <<-R
547
+ require "valim"
548
+ puts VALIM_PREV_REF
549
+ R
550
+
551
+ out.should == old_revision
552
+ end
553
+ end
554
+
555
+ describe "bundle install --deployment with git sources" do
556
+ it "works" do
557
+ build_git "valim", :path => lib_path('valim')
558
+
559
+ install_gemfile <<-G
560
+ source "file://#{gem_repo1}"
561
+
562
+ gem "valim", "= 1.0", :git => "#{lib_path('valim')}"
563
+ G
564
+
565
+ simulate_new_machine
566
+
567
+ bundle "install --deployment", :exitstatus => true
568
+ exitstatus.should == 0
569
+ end
570
+ end
571
+ end