rkh-bundler 1.2.0.pre

Sign up to get free protection for your applications and to get access to all the features.
Files changed (176) hide show
  1. data/.gitignore +22 -0
  2. data/.travis.yml +42 -0
  3. data/CHANGELOG.md +1105 -0
  4. data/ISSUES.md +67 -0
  5. data/LICENSE +23 -0
  6. data/README.md +31 -0
  7. data/Rakefile +208 -0
  8. data/UPGRADING.md +103 -0
  9. data/bin/bundle +31 -0
  10. data/bundler.gemspec +31 -0
  11. data/lib/bundler.rb +353 -0
  12. data/lib/bundler/capistrano.rb +11 -0
  13. data/lib/bundler/cli.rb +693 -0
  14. data/lib/bundler/definition.rb +568 -0
  15. data/lib/bundler/dep_proxy.rb +43 -0
  16. data/lib/bundler/dependency.rb +134 -0
  17. data/lib/bundler/deployment.rb +58 -0
  18. data/lib/bundler/dsl.rb +256 -0
  19. data/lib/bundler/endpoint_specification.rb +78 -0
  20. data/lib/bundler/environment.rb +47 -0
  21. data/lib/bundler/fetcher.rb +225 -0
  22. data/lib/bundler/gem_helper.rb +162 -0
  23. data/lib/bundler/gem_helpers.rb +23 -0
  24. data/lib/bundler/gem_installer.rb +9 -0
  25. data/lib/bundler/gem_tasks.rb +2 -0
  26. data/lib/bundler/graph.rb +148 -0
  27. data/lib/bundler/index.rb +187 -0
  28. data/lib/bundler/installer.rb +190 -0
  29. data/lib/bundler/lazy_specification.rb +79 -0
  30. data/lib/bundler/lockfile_parser.rb +127 -0
  31. data/lib/bundler/match_platform.rb +13 -0
  32. data/lib/bundler/psyched_yaml.rb +15 -0
  33. data/lib/bundler/remote_specification.rb +57 -0
  34. data/lib/bundler/resolver.rb +486 -0
  35. data/lib/bundler/ruby_version.rb +94 -0
  36. data/lib/bundler/rubygems_ext.rb +153 -0
  37. data/lib/bundler/rubygems_integration.rb +394 -0
  38. data/lib/bundler/runtime.rb +233 -0
  39. data/lib/bundler/settings.rb +128 -0
  40. data/lib/bundler/setup.rb +23 -0
  41. data/lib/bundler/shared_helpers.rb +71 -0
  42. data/lib/bundler/source.rb +869 -0
  43. data/lib/bundler/spec_set.rb +137 -0
  44. data/lib/bundler/templates/Executable +16 -0
  45. data/lib/bundler/templates/Executable.standalone +12 -0
  46. data/lib/bundler/templates/Gemfile +4 -0
  47. data/lib/bundler/templates/newgem/Gemfile.tt +4 -0
  48. data/lib/bundler/templates/newgem/LICENSE.tt +22 -0
  49. data/lib/bundler/templates/newgem/README.md.tt +29 -0
  50. data/lib/bundler/templates/newgem/Rakefile.tt +2 -0
  51. data/lib/bundler/templates/newgem/bin/newgem.tt +3 -0
  52. data/lib/bundler/templates/newgem/gitignore.tt +17 -0
  53. data/lib/bundler/templates/newgem/lib/newgem.rb.tt +9 -0
  54. data/lib/bundler/templates/newgem/lib/newgem/version.rb.tt +7 -0
  55. data/lib/bundler/templates/newgem/newgem.gemspec.tt +17 -0
  56. data/lib/bundler/ui.rb +88 -0
  57. data/lib/bundler/vendor/net/http/faster.rb +27 -0
  58. data/lib/bundler/vendor/net/http/persistent.rb +468 -0
  59. data/lib/bundler/vendor/thor.rb +358 -0
  60. data/lib/bundler/vendor/thor/actions.rb +314 -0
  61. data/lib/bundler/vendor/thor/actions/create_file.rb +105 -0
  62. data/lib/bundler/vendor/thor/actions/create_link.rb +57 -0
  63. data/lib/bundler/vendor/thor/actions/directory.rb +93 -0
  64. data/lib/bundler/vendor/thor/actions/empty_directory.rb +134 -0
  65. data/lib/bundler/vendor/thor/actions/file_manipulation.rb +270 -0
  66. data/lib/bundler/vendor/thor/actions/inject_into_file.rb +109 -0
  67. data/lib/bundler/vendor/thor/base.rb +576 -0
  68. data/lib/bundler/vendor/thor/core_ext/file_binary_read.rb +9 -0
  69. data/lib/bundler/vendor/thor/core_ext/hash_with_indifferent_access.rb +75 -0
  70. data/lib/bundler/vendor/thor/core_ext/ordered_hash.rb +100 -0
  71. data/lib/bundler/vendor/thor/error.rb +30 -0
  72. data/lib/bundler/vendor/thor/group.rb +273 -0
  73. data/lib/bundler/vendor/thor/invocation.rb +168 -0
  74. data/lib/bundler/vendor/thor/parser.rb +4 -0
  75. data/lib/bundler/vendor/thor/parser/argument.rb +67 -0
  76. data/lib/bundler/vendor/thor/parser/arguments.rb +161 -0
  77. data/lib/bundler/vendor/thor/parser/option.rb +120 -0
  78. data/lib/bundler/vendor/thor/parser/options.rb +172 -0
  79. data/lib/bundler/vendor/thor/rake_compat.rb +66 -0
  80. data/lib/bundler/vendor/thor/runner.rb +309 -0
  81. data/lib/bundler/vendor/thor/shell.rb +88 -0
  82. data/lib/bundler/vendor/thor/shell/basic.rb +302 -0
  83. data/lib/bundler/vendor/thor/shell/color.rb +108 -0
  84. data/lib/bundler/vendor/thor/shell/html.rb +121 -0
  85. data/lib/bundler/vendor/thor/task.rb +113 -0
  86. data/lib/bundler/vendor/thor/util.rb +229 -0
  87. data/lib/bundler/vendor/thor/version.rb +3 -0
  88. data/lib/bundler/vendored_thor.rb +7 -0
  89. data/lib/bundler/version.rb +6 -0
  90. data/lib/bundler/vlad.rb +11 -0
  91. data/man/bundle-config.ronn +130 -0
  92. data/man/bundle-exec.ronn +111 -0
  93. data/man/bundle-install.ronn +335 -0
  94. data/man/bundle-package.ronn +59 -0
  95. data/man/bundle-update.ronn +176 -0
  96. data/man/bundle.ronn +83 -0
  97. data/man/gemfile.5.ronn +324 -0
  98. data/man/index.txt +6 -0
  99. data/spec/bundler/dsl_spec.rb +48 -0
  100. data/spec/bundler/gem_helper_spec.rb +174 -0
  101. data/spec/bundler/source_spec.rb +25 -0
  102. data/spec/cache/gems_spec.rb +239 -0
  103. data/spec/cache/git_spec.rb +124 -0
  104. data/spec/cache/path_spec.rb +103 -0
  105. data/spec/cache/platform_spec.rb +57 -0
  106. data/spec/install/deploy_spec.rb +211 -0
  107. data/spec/install/gems/c_ext_spec.rb +48 -0
  108. data/spec/install/gems/dependency_api_spec.rb +402 -0
  109. data/spec/install/gems/env_spec.rb +107 -0
  110. data/spec/install/gems/flex_spec.rb +313 -0
  111. data/spec/install/gems/groups_spec.rb +268 -0
  112. data/spec/install/gems/packed_spec.rb +84 -0
  113. data/spec/install/gems/platform_spec.rb +208 -0
  114. data/spec/install/gems/post_install_spec.rb +47 -0
  115. data/spec/install/gems/resolving_spec.rb +72 -0
  116. data/spec/install/gems/simple_case_spec.rb +814 -0
  117. data/spec/install/gems/standalone_spec.rb +260 -0
  118. data/spec/install/gems/sudo_spec.rb +74 -0
  119. data/spec/install/gems/win32_spec.rb +26 -0
  120. data/spec/install/gemspec_spec.rb +170 -0
  121. data/spec/install/git_spec.rb +796 -0
  122. data/spec/install/invalid_spec.rb +35 -0
  123. data/spec/install/path_spec.rb +405 -0
  124. data/spec/install/upgrade_spec.rb +26 -0
  125. data/spec/lock/git_spec.rb +35 -0
  126. data/spec/lock/lockfile_spec.rb +809 -0
  127. data/spec/other/check_spec.rb +265 -0
  128. data/spec/other/clean_spec.rb +492 -0
  129. data/spec/other/config_spec.rb +138 -0
  130. data/spec/other/console_spec.rb +54 -0
  131. data/spec/other/exec_spec.rb +229 -0
  132. data/spec/other/ext_spec.rb +37 -0
  133. data/spec/other/help_spec.rb +39 -0
  134. data/spec/other/init_spec.rb +40 -0
  135. data/spec/other/newgem_spec.rb +87 -0
  136. data/spec/other/open_spec.rb +35 -0
  137. data/spec/other/outdated_spec.rb +93 -0
  138. data/spec/other/platform_spec.rb +881 -0
  139. data/spec/other/show_spec.rb +88 -0
  140. data/spec/quality_spec.rb +62 -0
  141. data/spec/realworld/edgecases_spec.rb +177 -0
  142. data/spec/resolver/basic_spec.rb +20 -0
  143. data/spec/resolver/platform_spec.rb +82 -0
  144. data/spec/runtime/executable_spec.rb +120 -0
  145. data/spec/runtime/load_spec.rb +107 -0
  146. data/spec/runtime/platform_spec.rb +90 -0
  147. data/spec/runtime/require_spec.rb +261 -0
  148. data/spec/runtime/setup_spec.rb +755 -0
  149. data/spec/runtime/with_clean_env_spec.rb +80 -0
  150. data/spec/spec_helper.rb +98 -0
  151. data/spec/support/artifice/endopint_marshal_fail_basic_authentication.rb +13 -0
  152. data/spec/support/artifice/endpoint.rb +54 -0
  153. data/spec/support/artifice/endpoint_500.rb +37 -0
  154. data/spec/support/artifice/endpoint_api_missing.rb +16 -0
  155. data/spec/support/artifice/endpoint_basic_authentication.rb +13 -0
  156. data/spec/support/artifice/endpoint_extra.rb +27 -0
  157. data/spec/support/artifice/endpoint_extra_missing.rb +15 -0
  158. data/spec/support/artifice/endpoint_fallback.rb +18 -0
  159. data/spec/support/artifice/endpoint_marshal_fail.rb +11 -0
  160. data/spec/support/artifice/endpoint_redirect.rb +15 -0
  161. data/spec/support/builders.rb +604 -0
  162. data/spec/support/fakeweb/rack-1.0.0.marshal +2 -0
  163. data/spec/support/fakeweb/windows.rb +23 -0
  164. data/spec/support/helpers.rb +317 -0
  165. data/spec/support/indexes.rb +112 -0
  166. data/spec/support/matchers.rb +77 -0
  167. data/spec/support/path.rb +73 -0
  168. data/spec/support/platforms.rb +86 -0
  169. data/spec/support/ruby_ext.rb +20 -0
  170. data/spec/support/rubygems_ext.rb +37 -0
  171. data/spec/support/rubygems_hax/platform.rb +22 -0
  172. data/spec/support/sudo.rb +21 -0
  173. data/spec/update/gems_spec.rb +134 -0
  174. data/spec/update/git_spec.rb +196 -0
  175. data/spec/update/source_spec.rb +51 -0
  176. metadata +338 -0
@@ -0,0 +1,6 @@
1
+ Gemfile(5) gemfile.5
2
+ bundle-install bundle-install.1
3
+ bundle-update bundle-update.1
4
+ bundle-package bundle-package.1
5
+ bundle-exec bundle-exec.1
6
+ bundle-config bundle-config.1
@@ -0,0 +1,48 @@
1
+ require 'spec_helper'
2
+
3
+ describe Bundler::Dsl do
4
+ before do
5
+ @rubygems = mock("rubygems")
6
+ Bundler::Source::Rubygems.stub(:new){ @rubygems }
7
+ end
8
+
9
+ describe '#_normalize_options' do
10
+ it "should convert :github to :git" do
11
+ subject.gem("sparks", :github => "indirect/sparks")
12
+ github_uri = "git://github.com/indirect/sparks.git"
13
+ subject.dependencies.first.source.uri.should == github_uri
14
+ end
15
+
16
+ it "should convert 'rails' to 'rails/rails'" do
17
+ subject.gem("rails", :github => "rails")
18
+ github_uri = "git://github.com/rails/rails.git"
19
+ subject.dependencies.first.source.uri.should == github_uri
20
+ end
21
+ end
22
+
23
+ describe '#method_missing' do
24
+ it 'should raise an error for unknown DSL methods' do
25
+ Bundler.should_receive(:read_file).with("Gemfile").and_return("unknown")
26
+ error_msg = "Undefined local variable or method `unknown'" \
27
+ " for Gemfile\\s+from Gemfile:1"
28
+ lambda{ subject.eval_gemfile("Gemfile") }.
29
+ should raise_error(Bundler::GemfileError, Regexp.new(error_msg))
30
+ end
31
+ end
32
+
33
+ describe "#eval_gemfile" do
34
+ it "handles syntax errors with a useful message" do
35
+ Bundler.should_receive(:read_file).with("Gemfile").and_return("}")
36
+ lambda{ subject.eval_gemfile("Gemfile") }.
37
+ should raise_error(Bundler::GemfileError, /Gemfile syntax error/)
38
+ end
39
+ end
40
+
41
+ describe "syntax errors" do
42
+ it "should raise a Bundler::GemfileError" do
43
+ gemfile "gem 'foo', :path => /unquoted/string/syntax/error"
44
+ lambda { Bundler::Dsl.evaluate(bundled_app("Gemfile"), nil, true) }.
45
+ should raise_error(Bundler::GemfileError)
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,174 @@
1
+ require "spec_helper"
2
+ require 'rake'
3
+ require 'bundler/gem_helper'
4
+
5
+ describe "Bundler::GemHelper tasks" do
6
+ context "determining gemspec" do
7
+ it "interpolates the name when there is only one gemspec" do
8
+ bundle 'gem test'
9
+ app = bundled_app("test")
10
+ helper = Bundler::GemHelper.new(app.to_s)
11
+ helper.gemspec.name.should == 'test'
12
+ end
13
+
14
+ it "interpolates the name for a hidden gemspec" do
15
+ bundle 'gem test'
16
+ app = bundled_app("test")
17
+ FileUtils.mv app.join('test.gemspec'), app.join('.gemspec')
18
+ helper = Bundler::GemHelper.new(app.to_s)
19
+ helper.gemspec.name.should == 'test'
20
+ end
21
+
22
+ it "should fail when there is no gemspec" do
23
+ bundle 'gem test'
24
+ app = bundled_app("test")
25
+ FileUtils.rm(File.join(app.to_s, 'test.gemspec'))
26
+ proc { Bundler::GemHelper.new(app.to_s) }.should raise_error(/Unable to determine name/)
27
+ end
28
+
29
+ it "should fail when there are two gemspecs and the name isn't specified" do
30
+ bundle 'gem test'
31
+ app = bundled_app("test")
32
+ File.open(File.join(app.to_s, 'test2.gemspec'), 'w') {|f| f << ''}
33
+ proc { Bundler::GemHelper.new(app.to_s) }.should raise_error(/Unable to determine name/)
34
+ end
35
+
36
+ it "handles namespaces and converting to CamelCase" do
37
+ bundle 'gem test-foo_bar'
38
+ lib = bundled_app('test-foo_bar').join('lib/test-foo_bar.rb').read
39
+ lib.should include("module Test")
40
+ lib.should include("module FooBar")
41
+ end
42
+ end
43
+
44
+ context "gem management" do
45
+ def mock_confirm_message(message)
46
+ Bundler.ui.should_receive(:confirm).with(message)
47
+ end
48
+
49
+ def mock_build_message
50
+ mock_confirm_message "test 0.0.1 built to pkg/test-0.0.1.gem"
51
+ end
52
+
53
+ before(:each) do
54
+ bundle 'gem test'
55
+ @app = bundled_app("test")
56
+ @gemspec = File.read("#{@app.to_s}/test.gemspec")
57
+ File.open("#{@app.to_s}/test.gemspec", 'w'){|f| f << @gemspec.gsub('TODO: ', '') }
58
+ @helper = Bundler::GemHelper.new(@app.to_s)
59
+ end
60
+
61
+ it "uses a shell UI for output" do
62
+ Bundler.ui.should be_a(Bundler::UI::Shell)
63
+ end
64
+
65
+ describe 'install_tasks' do
66
+ before(:each) do
67
+ @saved, Rake.application = Rake.application, Rake::Application.new
68
+ end
69
+
70
+ after(:each) do
71
+ Rake.application = @saved
72
+ end
73
+
74
+ it "defines Rake tasks" do
75
+ names = %w[build install release]
76
+
77
+ names.each { |name|
78
+ proc { Rake.application[name] }.should raise_error(/Don't know how to build task/)
79
+ }
80
+
81
+ @helper.install
82
+
83
+ names.each { |name|
84
+ proc { Rake.application[name] }.should_not raise_error
85
+ Rake.application[name].should be_instance_of Rake::Task
86
+ }
87
+ end
88
+
89
+ it "provides a way to access the gemspec object" do
90
+ @helper.install
91
+ Bundler::GemHelper.gemspec.name.should == 'test'
92
+ end
93
+ end
94
+
95
+ describe 'build' do
96
+ it "builds" do
97
+ mock_build_message
98
+ @helper.build_gem
99
+ bundled_app('test/pkg/test-0.0.1.gem').should exist
100
+ end
101
+
102
+ it "raises an appropriate error when the build fails" do
103
+ # break the gemspec by adding back the TODOs...
104
+ File.open("#{@app.to_s}/test.gemspec", 'w'){|f| f << @gemspec }
105
+ proc { @helper.build_gem }.should raise_error(/TODO/)
106
+ end
107
+ end
108
+
109
+ describe 'install' do
110
+ it "installs" do
111
+ mock_build_message
112
+ mock_confirm_message "test (0.0.1) installed"
113
+ @helper.install_gem
114
+ bundled_app('test/pkg/test-0.0.1.gem').should exist
115
+ %x{gem list}.should include("test (0.0.1)")
116
+ end
117
+
118
+ it "raises an appropriate error when the install fails" do
119
+ @helper.should_receive(:build_gem) do
120
+ # write an invalid gem file, so we can simulate install failure...
121
+ FileUtils.mkdir_p(File.join(@app.to_s, 'pkg'))
122
+ path = "#{@app.to_s}/pkg/test-0.0.1.gem"
123
+ File.open(path, 'w'){|f| f << "not actually a gem"}
124
+ path
125
+ end
126
+ proc { @helper.install_gem }.should raise_error
127
+ end
128
+ end
129
+
130
+ describe 'release' do
131
+ it "shouldn't push if there are uncommitted files" do
132
+ proc { @helper.release_gem }.should raise_error(/files that need to be committed/)
133
+ end
134
+
135
+ it 'raises an appropriate error if there is no git remote' do
136
+ Bundler.ui.stub(:confirm => nil, :error => nil) # silence messages
137
+
138
+ Dir.chdir(gem_repo1) {
139
+ `git init --bare`
140
+ }
141
+ Dir.chdir(@app) {
142
+ `git init`
143
+ `git config user.email "you@example.com"`
144
+ `git config user.name "name"`
145
+ `git commit -a -m "initial commit"`
146
+ }
147
+
148
+ proc { @helper.release_gem }.should raise_error
149
+ end
150
+
151
+ it "releases" do
152
+ mock_build_message
153
+ mock_confirm_message(/Tagged v0.0.1/)
154
+ mock_confirm_message("Pushed git commits and tags")
155
+
156
+ @helper.should_receive(:rubygem_push).with(bundled_app('test/pkg/test-0.0.1.gem').to_s)
157
+
158
+ Dir.chdir(gem_repo1) {
159
+ `git init --bare`
160
+ }
161
+ Dir.chdir(@app) {
162
+ `git init`
163
+ `git config user.email "you@example.com"`
164
+ `git config user.name "name"`
165
+ `git remote add origin file://#{gem_repo1}`
166
+ `git commit -a -m "initial commit"`
167
+ sys_exec("git push origin master", true)
168
+ `git commit -a -m "another commit"`
169
+ }
170
+ @helper.release_gem
171
+ end
172
+ end
173
+ end
174
+ end
@@ -0,0 +1,25 @@
1
+ require 'spec_helper'
2
+
3
+ describe Bundler::Source::Rubygems do
4
+ before do
5
+ Bundler.stub(:root){ Pathname.new("root") }
6
+ end
7
+
8
+ describe "caches" do
9
+ it "should include Bundler.app_cache" do
10
+ subject.caches.should include(Bundler.app_cache)
11
+ end
12
+
13
+ it "should include GEM_PATH entries" do
14
+ Gem.path.each do |path|
15
+ subject.caches.should include(File.expand_path("#{path}/cache"))
16
+ end
17
+ end
18
+
19
+ it "should be an array of strings or pathnames" do
20
+ subject.caches.each do |cache|
21
+ [String, Pathname].should include(cache.class)
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,239 @@
1
+ require "spec_helper"
2
+
3
+ describe "bundle cache" do
4
+
5
+ describe "when there are only gemsources" do
6
+ before :each do
7
+ gemfile <<-G
8
+ gem 'rack'
9
+ G
10
+
11
+ system_gems "rack-1.0.0"
12
+ bundle :cache
13
+ end
14
+
15
+ it "copies the .gem file to vendor/cache" do
16
+ bundled_app("vendor/cache/rack-1.0.0.gem").should exist
17
+ end
18
+
19
+ it "uses the cache as a source when installing gems" do
20
+ build_gem "omg", :path => bundled_app('vendor/cache')
21
+
22
+ install_gemfile <<-G
23
+ source "file://#{gem_repo1}"
24
+ gem "omg"
25
+ G
26
+
27
+ should_be_installed "omg 1.0.0"
28
+ end
29
+
30
+ it "uses the cache as a source when installing gems with --local" do
31
+ system_gems []
32
+ bundle "install --local"
33
+
34
+ should_be_installed("rack 1.0.0")
35
+ end
36
+
37
+ it "does not reinstall gems from the cache if they exist on the system" do
38
+ build_gem "rack", "1.0.0", :path => bundled_app('vendor/cache') do |s|
39
+ s.write "lib/rack.rb", "RACK = 'FAIL'"
40
+ end
41
+
42
+ install_gemfile <<-G
43
+ gem "rack"
44
+ G
45
+
46
+ should_be_installed("rack 1.0.0")
47
+ end
48
+
49
+ it "does not reinstall gems from the cache if they exist in the bundle" do
50
+ system_gems "rack-1.0.0"
51
+
52
+ gemfile <<-G
53
+ gem "rack"
54
+ G
55
+
56
+ build_gem "rack", "1.0.0", :path => bundled_app('vendor/cache') do |s|
57
+ s.write "lib/rack.rb", "RACK = 'FAIL'"
58
+ end
59
+
60
+ bundle "install --local"
61
+ should_be_installed("rack 1.0.0")
62
+ end
63
+
64
+ it "creates a lockfile" do
65
+ cache_gems "rack-1.0.0"
66
+
67
+ gemfile <<-G
68
+ gem "rack"
69
+ G
70
+
71
+ bundle "cache"
72
+
73
+ bundled_app("Gemfile.lock").should exist
74
+ end
75
+ end
76
+
77
+ describe "when there are also git sources" do
78
+ before do
79
+ build_git "foo"
80
+ system_gems "rack-1.0.0"
81
+
82
+ install_gemfile <<-G
83
+ source "file://#{gem_repo1}"
84
+ git "#{lib_path("foo-1.0")}" do
85
+ gem 'foo'
86
+ end
87
+ gem 'rack'
88
+ G
89
+ end
90
+
91
+ it "still works" do
92
+ bundle :cache
93
+
94
+ system_gems []
95
+ bundle "install --local"
96
+
97
+ should_be_installed("rack 1.0.0", "foo 1.0")
98
+ end
99
+
100
+ it "should not explode if the lockfile is not present" do
101
+ FileUtils.rm(bundled_app("Gemfile.lock"))
102
+
103
+ bundle :cache
104
+
105
+ bundled_app("Gemfile.lock").should exist
106
+ end
107
+ end
108
+
109
+ describe "when previously cached" do
110
+ before :each do
111
+ build_repo2
112
+ install_gemfile <<-G
113
+ source "file://#{gem_repo2}"
114
+ gem "rack"
115
+ gem "actionpack"
116
+ G
117
+ bundle :cache
118
+ cached_gem("rack-1.0.0").should exist
119
+ cached_gem("actionpack-2.3.2").should exist
120
+ cached_gem("activesupport-2.3.2").should exist
121
+ end
122
+
123
+ it "re-caches during install" do
124
+ cached_gem("rack-1.0.0").rmtree
125
+ bundle :install
126
+ out.should include("Updating files in vendor/cache")
127
+ cached_gem("rack-1.0.0").should exist
128
+ end
129
+
130
+ it "adds and removes when gems are updated" do
131
+ update_repo2
132
+ bundle 'update'
133
+ cached_gem("rack-1.2").should exist
134
+ cached_gem("rack-1.0.0").should_not exist
135
+ end
136
+
137
+ it "adds new gems and dependencies" do
138
+ install_gemfile <<-G
139
+ source "file://#{gem_repo2}"
140
+ gem "rails"
141
+ G
142
+ cached_gem("rails-2.3.2").should exist
143
+ cached_gem("activerecord-2.3.2").should exist
144
+ end
145
+
146
+ it "removes .gems for removed gems and dependencies" do
147
+ install_gemfile <<-G
148
+ source "file://#{gem_repo2}"
149
+ gem "rack"
150
+ G
151
+ cached_gem("rack-1.0.0").should exist
152
+ cached_gem("actionpack-2.3.2").should_not exist
153
+ cached_gem("activesupport-2.3.2").should_not exist
154
+ end
155
+
156
+ it "removes .gems when gem changes to git source" do
157
+ build_git "rack"
158
+
159
+ install_gemfile <<-G
160
+ source "file://#{gem_repo2}"
161
+ gem "rack", :git => "#{lib_path("rack-1.0")}"
162
+ gem "actionpack"
163
+ G
164
+ cached_gem("rack-1.0.0").should_not exist
165
+ cached_gem("actionpack-2.3.2").should exist
166
+ cached_gem("activesupport-2.3.2").should exist
167
+ end
168
+
169
+
170
+ it "doesn't remove gems that are for another platform" do
171
+ simulate_platform "java" do
172
+ install_gemfile <<-G
173
+ source "file://#{gem_repo1}"
174
+ gem "platform_specific"
175
+ G
176
+
177
+ bundle :cache
178
+ cached_gem("platform_specific-1.0-java").should exist
179
+ end
180
+
181
+ simulate_new_machine
182
+ install_gemfile <<-G
183
+ source "file://#{gem_repo1}"
184
+ gem "platform_specific"
185
+ G
186
+
187
+ cached_gem("platform_specific-1.0-#{Gem::Platform.local}").should exist
188
+ cached_gem("platform_specific-1.0-java").should exist
189
+ end
190
+
191
+ it "doesn't remove gems with mismatched :rubygems_version or :date" do
192
+ cached_gem("rack-1.0.0").rmtree
193
+ build_gem "rack", "1.0.0",
194
+ :path => bundled_app('vendor/cache'),
195
+ :rubygems_version => "1.3.2"
196
+ simulate_new_machine
197
+
198
+ bundle :install
199
+ cached_gem("rack-1.0.0").should exist
200
+ end
201
+
202
+ it "handles directories and non .gem files in the cache" do
203
+ bundled_app("vendor/cache/foo").mkdir
204
+ File.open(bundled_app("vendor/cache/bar"), 'w'){|f| f.write("not a gem") }
205
+ bundle :cache
206
+ end
207
+
208
+ it "does not say that it is removing gems when it isn't actually doing so" do
209
+ install_gemfile <<-G
210
+ source "file://#{gem_repo1}"
211
+ gem "rack"
212
+ G
213
+ bundle "cache"
214
+ bundle "install"
215
+ out.should_not =~ /removing/i
216
+ end
217
+
218
+ it "does not warn about all if it doesn't have any git/path dependency" do
219
+ install_gemfile <<-G
220
+ source "file://#{gem_repo1}"
221
+ gem "rack"
222
+ G
223
+ bundle "cache"
224
+ out.should_not =~ /\-\-all/
225
+ end
226
+
227
+ it "should install gems with the name bundler in them (that aren't bundler)" do
228
+ build_gem "foo-bundler", "1.0",
229
+ :path => bundled_app('vendor/cache')
230
+
231
+ install_gemfile <<-G
232
+ gem "foo-bundler"
233
+ G
234
+
235
+ should_be_installed "foo-bundler 1.0"
236
+ end
237
+ end
238
+
239
+ end