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,17 @@
1
+ require "spec_helper"
2
+
3
+ describe "bundle install with deprecated features" do
4
+ before :each do
5
+ in_app_root
6
+ end
7
+
8
+ it "reports that lib is an invalid option" do
9
+ gemfile <<-G
10
+ gem "rack", :lib => "rack"
11
+ G
12
+
13
+ bundle :install
14
+ out.should =~ /You passed :lib as an option for gem 'rack', but it is invalid/
15
+ end
16
+
17
+ end
@@ -0,0 +1,353 @@
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
+ exitstatus.should == 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
+ out.should == '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 "raises if there are multiple gemspecs" do
145
+ build_lib "foo", "1.0", :path => lib_path("foo") do |s|
146
+ s.write "bar.gemspec"
147
+ end
148
+
149
+ install_gemfile <<-G, :exitstatus => true
150
+ gemspec :path => "#{lib_path("foo")}"
151
+ G
152
+
153
+ check exitstatus.should == 15
154
+ out.should =~ /There are multiple gemspecs/
155
+ end
156
+
157
+ it "allows :name to be specified to resolve ambiguity" do
158
+ build_lib "foo", "1.0", :path => lib_path("foo") do |s|
159
+ s.write "bar.gemspec"
160
+ end
161
+
162
+ install_gemfile <<-G, :exitstatus => true
163
+ gemspec :path => "#{lib_path("foo")}", :name => "foo"
164
+ G
165
+
166
+ should_be_installed "foo 1.0"
167
+ end
168
+
169
+ it "sets up executables" do
170
+ pending_jruby_shebang_fix
171
+
172
+ build_lib "foo" do |s|
173
+ s.executables = "foobar"
174
+ end
175
+
176
+ install_gemfile <<-G
177
+ path "#{lib_path('foo-1.0')}"
178
+ gem 'foo'
179
+ G
180
+
181
+ bundle "exec foobar"
182
+ out.should == "1.0"
183
+ end
184
+
185
+ it "removes the .gem file after installing" do
186
+ build_lib "foo"
187
+
188
+ install_gemfile <<-G
189
+ gem 'foo', :path => "#{lib_path('foo-1.0')}"
190
+ G
191
+
192
+ lib_path('foo-1.0').join('foo-1.0.gem').should_not exist
193
+ end
194
+
195
+ describe "block syntax" do
196
+ it "pulls all gems from a path block" do
197
+ build_lib "omg"
198
+ build_lib "hi2u"
199
+
200
+ install_gemfile <<-G
201
+ path "#{lib_path}" do
202
+ gem "omg"
203
+ gem "hi2u"
204
+ end
205
+ G
206
+
207
+ should_be_installed "omg 1.0", "hi2u 1.0"
208
+ end
209
+ end
210
+
211
+ it "keeps source pinning" do
212
+ build_lib "foo", "1.0", :path => lib_path('foo')
213
+ build_lib "omg", "1.0", :path => lib_path('omg')
214
+ build_lib "foo", "1.0", :path => lib_path('omg/foo') do |s|
215
+ s.write "lib/foo.rb", "puts 'FAIL'"
216
+ end
217
+
218
+ install_gemfile <<-G
219
+ gem "foo", :path => "#{lib_path('foo')}"
220
+ gem "omg", :path => "#{lib_path('omg')}"
221
+ G
222
+
223
+ should_be_installed "foo 1.0"
224
+ end
225
+
226
+ it "works when the path does not have a gemspec" do
227
+ build_lib "foo", :gemspec => false
228
+
229
+ gemfile <<-G
230
+ gem "foo", "1.0", :path => "#{lib_path('foo-1.0')}"
231
+ G
232
+
233
+ should_be_installed "foo 1.0"
234
+
235
+ should_be_installed "foo 1.0"
236
+ end
237
+
238
+ it "installs executable stubs" do
239
+ build_lib "foo" do |s|
240
+ s.executables = ['foo']
241
+ end
242
+
243
+ install_gemfile <<-G
244
+ gem "foo", :path => "#{lib_path('foo-1.0')}"
245
+ G
246
+
247
+ bundle "exec foo"
248
+ out.should == "1.0"
249
+ end
250
+
251
+ describe "when the gem version in the path is updated" do
252
+ before :each do
253
+ build_lib "foo", "1.0", :path => lib_path("foo") do |s|
254
+ s.add_dependency "bar"
255
+ end
256
+ build_lib "bar", "1.0", :path => lib_path("foo/bar")
257
+
258
+ install_gemfile <<-G
259
+ gem "foo", :path => "#{lib_path('foo')}"
260
+ G
261
+ end
262
+
263
+ it "unlocks all gems when the top level gem is updated" do
264
+ build_lib "foo", "2.0", :path => lib_path("foo") do |s|
265
+ s.add_dependency "bar"
266
+ end
267
+
268
+ bundle "install"
269
+
270
+ should_be_installed "foo 2.0", "bar 1.0"
271
+ end
272
+
273
+ it "unlocks all gems when a child dependency gem is updated" do
274
+ build_lib "bar", "2.0", :path => lib_path("foo/bar")
275
+
276
+ bundle "install"
277
+
278
+ should_be_installed "foo 1.0", "bar 2.0"
279
+ end
280
+ end
281
+
282
+ describe "when dependencies in the path are updated" do
283
+ before :each do
284
+ build_lib "foo", "1.0", :path => lib_path("foo")
285
+
286
+ install_gemfile <<-G
287
+ source "file://#{gem_repo1}"
288
+ gem "foo", :path => "#{lib_path('foo')}"
289
+ G
290
+ end
291
+
292
+ it "gets dependencies that are updated in the path" do
293
+ build_lib "foo", "1.0", :path => lib_path("foo") do |s|
294
+ s.add_dependency "rack"
295
+ end
296
+
297
+ bundle "install"
298
+
299
+ should_be_installed "rack 1.0.0"
300
+ end
301
+ end
302
+
303
+ describe "switching sources" do
304
+ it "doesn't switch pinned git sources to rubygems when pinning the parent gem to a path source" do
305
+ build_gem "foo", "1.0", :to_system => true do |s|
306
+ s.write "lib/foo.rb", "raise 'fail'"
307
+ end
308
+ build_lib "foo", "1.0", :path => lib_path('bar/foo')
309
+ build_git "bar", "1.0", :path => lib_path('bar') do |s|
310
+ s.add_dependency 'foo'
311
+ end
312
+
313
+ install_gemfile <<-G
314
+ source "file://#{gem_repo1}"
315
+ gem "bar", :git => "#{lib_path('bar')}"
316
+ G
317
+
318
+ install_gemfile <<-G
319
+ source "file://#{gem_repo1}"
320
+ gem "bar", :path => "#{lib_path('bar')}"
321
+ G
322
+
323
+ should_be_installed "foo 1.0", "bar 1.0"
324
+ end
325
+
326
+ it "switches the source when the gem existed in rubygems and the path was already being used for another gem" do
327
+ build_lib "foo", "1.0", :path => lib_path("foo")
328
+ build_gem "bar", "1.0", :to_system => true do |s|
329
+ s.write "lib/bar.rb", "raise 'fail'"
330
+ end
331
+
332
+ install_gemfile <<-G
333
+ source "file://#{gem_repo1}"
334
+ gem "bar"
335
+ path "#{lib_path('foo')}" do
336
+ gem "foo"
337
+ end
338
+ G
339
+
340
+ build_lib "bar", "1.0", :path => lib_path("foo/bar")
341
+
342
+ install_gemfile <<-G
343
+ source "file://#{gem_repo1}"
344
+ path "#{lib_path('foo')}" do
345
+ gem "foo"
346
+ gem "bar"
347
+ end
348
+ G
349
+
350
+ should_be_installed "bar 1.0"
351
+ end
352
+ end
353
+ end
@@ -0,0 +1,26 @@
1
+ require "spec_helper"
2
+
3
+ describe "bundle install for the first time with v1.0" do
4
+ before :each do
5
+ in_app_root
6
+
7
+ gemfile <<-G
8
+ source "file://#{gem_repo1}"
9
+ gem "rack"
10
+ G
11
+ end
12
+
13
+ it "removes lockfiles in 0.9 YAML format" do
14
+ File.open("Gemfile.lock", "w"){|f| YAML.dump({}, f) }
15
+ bundle :install
16
+ File.read("Gemfile.lock").should_not =~ /^---/
17
+ end
18
+
19
+ it "removes env.rb if it exists" do
20
+ bundled_app.join(".bundle").mkdir
21
+ bundled_app.join(".bundle/environment.rb").open("w"){|f| f.write("raise 'nooo'") }
22
+ bundle :install
23
+ bundled_app.join(".bundle/environment.rb").should_not exist
24
+ end
25
+
26
+ end
@@ -0,0 +1,35 @@
1
+ require "spec_helper"
2
+
3
+ describe "bundle lock with git gems" do
4
+ before :each do
5
+ build_git "foo"
6
+
7
+ install_gemfile <<-G
8
+ gem 'foo', :git => "#{lib_path('foo-1.0')}"
9
+ G
10
+ end
11
+
12
+ it "doesn't break right after running lock" do
13
+ should_be_installed "foo 1.0.0"
14
+ end
15
+
16
+ it "locks a git source to the current ref" do
17
+ update_git "foo"
18
+ bundle :install
19
+
20
+ run <<-RUBY
21
+ require 'foo'
22
+ puts "WIN" unless defined?(FOO_PREV_REF)
23
+ RUBY
24
+
25
+ out.should == "WIN"
26
+ end
27
+
28
+ it "provides correct #full_gem_path" do
29
+ run <<-RUBY
30
+ puts Gem.source_index.find_name('foo').first.full_gem_path
31
+ RUBY
32
+ out.should == bundle("show foo")
33
+ end
34
+
35
+ end
@@ -0,0 +1,683 @@
1
+ require "spec_helper"
2
+
3
+ describe "the lockfile format" do
4
+ include Bundler::GemHelpers
5
+
6
+ it "generates a simple lockfile for a single source, gem" do
7
+ install_gemfile <<-G
8
+ source "file://#{gem_repo1}"
9
+
10
+ gem "rack"
11
+ G
12
+
13
+ lockfile_should_be <<-G
14
+ GEM
15
+ remote: file:#{gem_repo1}/
16
+ specs:
17
+ rack (1.0.0)
18
+
19
+ PLATFORMS
20
+ #{generic(Gem::Platform.local)}
21
+
22
+ DEPENDENCIES
23
+ rack
24
+ G
25
+ end
26
+
27
+ it "generates a simple lockfile for a single source, gem with dependencies" do
28
+ install_gemfile <<-G
29
+ source "file://#{gem_repo1}"
30
+
31
+ gem "rack-obama"
32
+ G
33
+
34
+ lockfile_should_be <<-G
35
+ GEM
36
+ remote: file:#{gem_repo1}/
37
+ specs:
38
+ rack (1.0.0)
39
+ rack-obama (1.0)
40
+ rack
41
+
42
+ PLATFORMS
43
+ #{generic(Gem::Platform.local)}
44
+
45
+ DEPENDENCIES
46
+ rack-obama
47
+ G
48
+ end
49
+
50
+ it "generates a simple lockfile for a single source, gem with a version requirement" do
51
+ install_gemfile <<-G
52
+ source "file://#{gem_repo1}"
53
+
54
+ gem "rack-obama", ">= 1.0"
55
+ G
56
+
57
+ lockfile_should_be <<-G
58
+ GEM
59
+ remote: file:#{gem_repo1}/
60
+ specs:
61
+ rack (1.0.0)
62
+ rack-obama (1.0)
63
+ rack
64
+
65
+ PLATFORMS
66
+ #{generic(Gem::Platform.local)}
67
+
68
+ DEPENDENCIES
69
+ rack-obama (>= 1.0)
70
+ G
71
+ end
72
+
73
+ it "parses lockfiles w/ crazy shit" do
74
+ install_gemfile <<-G
75
+ source "file://#{gem_repo1}"
76
+
77
+ gem "net-sftp"
78
+ G
79
+
80
+ lockfile_should_be <<-G
81
+ GEM
82
+ remote: file:#{gem_repo1}/
83
+ specs:
84
+ net-sftp (1.1.1)
85
+ net-ssh (>= 1.0.0, < 1.99.0)
86
+ net-ssh (1.0)
87
+
88
+ PLATFORMS
89
+ ruby
90
+
91
+ DEPENDENCIES
92
+ net-sftp
93
+ G
94
+
95
+ should_be_installed "net-sftp 1.1.1", "net-ssh 1.0.0"
96
+ end
97
+
98
+ it "generates a simple lockfile for a single pinned source, gem with a version requirement" do
99
+ git = build_git "foo"
100
+
101
+ install_gemfile <<-G
102
+ gem "foo", :git => "#{lib_path("foo-1.0")}"
103
+ G
104
+
105
+ lockfile_should_be <<-G
106
+ GIT
107
+ remote: #{lib_path("foo-1.0")}
108
+ revision: #{git.ref_for('master')}
109
+ specs:
110
+ foo (1.0)
111
+
112
+ GEM
113
+ specs:
114
+
115
+ PLATFORMS
116
+ #{generic(Gem::Platform.local)}
117
+
118
+ DEPENDENCIES
119
+ foo!
120
+ G
121
+ end
122
+
123
+ it "does not assplode when a platform specific dependency is present and the Gemfile has not been resolved on that platform" do
124
+ build_lib "omg", :path => lib_path('omg')
125
+
126
+ gemfile <<-G
127
+ source "file://#{gem_repo1}"
128
+
129
+ platforms :#{not_local_tag} do
130
+ gem "omg", :path => "#{lib_path('omg')}"
131
+ end
132
+
133
+ gem "rack"
134
+ G
135
+
136
+ lockfile <<-L
137
+ GIT
138
+ remote: git://github.com/nex3/haml.git
139
+ revision: 8a2271f
140
+ specs:
141
+
142
+ GEM
143
+ remote: file://#{gem_repo1}/
144
+ specs:
145
+ rack (1.0.0)
146
+
147
+ PLATFORMS
148
+ #{not_local}
149
+
150
+ DEPENDENCIES
151
+ omg!
152
+ rack
153
+ L
154
+
155
+ bundle "install"
156
+ should_be_installed "rack 1.0.0"
157
+ end
158
+
159
+ it "serializes global git sources" do
160
+ git = build_git "foo"
161
+
162
+ install_gemfile <<-G
163
+ git "#{lib_path('foo-1.0')}" do
164
+ gem "foo"
165
+ end
166
+ G
167
+
168
+ lockfile_should_be <<-G
169
+ GIT
170
+ remote: #{lib_path('foo-1.0')}
171
+ revision: #{git.ref_for('master')}
172
+ specs:
173
+ foo (1.0)
174
+
175
+ GEM
176
+ specs:
177
+
178
+ PLATFORMS
179
+ #{generic(Gem::Platform.local)}
180
+
181
+ DEPENDENCIES
182
+ foo!
183
+ G
184
+ end
185
+
186
+ it "generates a lockfile with a ref for a single pinned source, git gem with a branch requirement" do
187
+ git = build_git "foo"
188
+ update_git "foo", :branch => "omg"
189
+
190
+ install_gemfile <<-G
191
+ gem "foo", :git => "#{lib_path("foo-1.0")}", :branch => "omg"
192
+ G
193
+
194
+ lockfile_should_be <<-G
195
+ GIT
196
+ remote: #{lib_path("foo-1.0")}
197
+ revision: #{git.ref_for('omg')}
198
+ branch: omg
199
+ specs:
200
+ foo (1.0)
201
+
202
+ GEM
203
+ specs:
204
+
205
+ PLATFORMS
206
+ #{generic(Gem::Platform.local)}
207
+
208
+ DEPENDENCIES
209
+ foo!
210
+ G
211
+ end
212
+
213
+ it "generates a lockfile with a ref for a single pinned source, git gem with a tag requirement" do
214
+ git = build_git "foo"
215
+ update_git "foo", :tag => "omg"
216
+
217
+ install_gemfile <<-G
218
+ gem "foo", :git => "#{lib_path("foo-1.0")}", :tag => "omg"
219
+ G
220
+
221
+ lockfile_should_be <<-G
222
+ GIT
223
+ remote: #{lib_path("foo-1.0")}
224
+ revision: #{git.ref_for('omg')}
225
+ tag: omg
226
+ specs:
227
+ foo (1.0)
228
+
229
+ GEM
230
+ specs:
231
+
232
+ PLATFORMS
233
+ #{generic(Gem::Platform.local)}
234
+
235
+ DEPENDENCIES
236
+ foo!
237
+ G
238
+ end
239
+
240
+ it "serializes pinned path sources to the lockfile" do
241
+ build_lib "foo"
242
+
243
+ install_gemfile <<-G
244
+ gem "foo", :path => "#{lib_path("foo-1.0")}"
245
+ G
246
+
247
+ lockfile_should_be <<-G
248
+ PATH
249
+ remote: #{lib_path("foo-1.0")}
250
+ specs:
251
+ foo (1.0)
252
+
253
+ GEM
254
+ specs:
255
+
256
+ PLATFORMS
257
+ #{generic(Gem::Platform.local)}
258
+
259
+ DEPENDENCIES
260
+ foo!
261
+ G
262
+ end
263
+
264
+ it "lists gems alphabetically" do
265
+ install_gemfile <<-G
266
+ source "file://#{gem_repo1}"
267
+
268
+ gem "thin"
269
+ gem "actionpack"
270
+ gem "rack-obama"
271
+ G
272
+
273
+ lockfile_should_be <<-G
274
+ GEM
275
+ remote: file:#{gem_repo1}/
276
+ specs:
277
+ actionpack (2.3.2)
278
+ activesupport (= 2.3.2)
279
+ activesupport (2.3.2)
280
+ rack (1.0.0)
281
+ rack-obama (1.0)
282
+ rack
283
+ thin (1.0)
284
+ rack
285
+
286
+ PLATFORMS
287
+ #{generic(Gem::Platform.local)}
288
+
289
+ DEPENDENCIES
290
+ actionpack
291
+ rack-obama
292
+ thin
293
+ G
294
+ end
295
+
296
+ it "order dependencies of dependencies in alphabetical order" do
297
+ install_gemfile <<-G
298
+ source "file://#{gem_repo1}"
299
+
300
+ gem "rails"
301
+ G
302
+
303
+ lockfile_should_be <<-G
304
+ GEM
305
+ remote: file:#{gem_repo1}/
306
+ specs:
307
+ actionmailer (2.3.2)
308
+ activesupport (= 2.3.2)
309
+ actionpack (2.3.2)
310
+ activesupport (= 2.3.2)
311
+ activerecord (2.3.2)
312
+ activesupport (= 2.3.2)
313
+ activeresource (2.3.2)
314
+ activesupport (= 2.3.2)
315
+ activesupport (2.3.2)
316
+ rails (2.3.2)
317
+ actionmailer (= 2.3.2)
318
+ actionpack (= 2.3.2)
319
+ activerecord (= 2.3.2)
320
+ activeresource (= 2.3.2)
321
+ rake
322
+ rake (0.8.7)
323
+
324
+ PLATFORMS
325
+ #{generic(Gem::Platform.local)}
326
+
327
+ DEPENDENCIES
328
+ rails
329
+ G
330
+ end
331
+
332
+ it "does not add the :require option to the lockfile" do
333
+ install_gemfile <<-G
334
+ source "file://#{gem_repo1}"
335
+
336
+ gem "rack-obama", ">= 1.0", :require => "rack/obama"
337
+ G
338
+
339
+ lockfile_should_be <<-G
340
+ GEM
341
+ remote: file:#{gem_repo1}/
342
+ specs:
343
+ rack (1.0.0)
344
+ rack-obama (1.0)
345
+ rack
346
+
347
+ PLATFORMS
348
+ #{generic(Gem::Platform.local)}
349
+
350
+ DEPENDENCIES
351
+ rack-obama (>= 1.0)
352
+ G
353
+ end
354
+
355
+ it "does not add the :group option to the lockfile" do
356
+ install_gemfile <<-G
357
+ source "file://#{gem_repo1}"
358
+
359
+ gem "rack-obama", ">= 1.0", :group => :test
360
+ G
361
+
362
+ lockfile_should_be <<-G
363
+ GEM
364
+ remote: file:#{gem_repo1}/
365
+ specs:
366
+ rack (1.0.0)
367
+ rack-obama (1.0)
368
+ rack
369
+
370
+ PLATFORMS
371
+ #{generic(Gem::Platform.local)}
372
+
373
+ DEPENDENCIES
374
+ rack-obama (>= 1.0)
375
+ G
376
+ end
377
+
378
+ it "stores relative paths when the path is provided in a relative fashion and in Gemfile dir" do
379
+ build_lib "foo", :path => bundled_app('foo')
380
+
381
+ install_gemfile <<-G
382
+ path "foo"
383
+ gem "foo"
384
+ G
385
+
386
+ lockfile_should_be <<-G
387
+ PATH
388
+ remote: foo
389
+ specs:
390
+ foo (1.0)
391
+
392
+ GEM
393
+ specs:
394
+
395
+ PLATFORMS
396
+ #{generic(Gem::Platform.local)}
397
+
398
+ DEPENDENCIES
399
+ foo
400
+ G
401
+ end
402
+
403
+ it "stores relative paths when the path is provided in a relative fashion and is above Gemfile dir" do
404
+ build_lib "foo", :path => bundled_app(File.join('..', 'foo'))
405
+
406
+ install_gemfile <<-G
407
+ path "../foo"
408
+ gem "foo"
409
+ G
410
+
411
+ lockfile_should_be <<-G
412
+ PATH
413
+ remote: ../foo
414
+ specs:
415
+ foo (1.0)
416
+
417
+ GEM
418
+ specs:
419
+
420
+ PLATFORMS
421
+ #{generic(Gem::Platform.local)}
422
+
423
+ DEPENDENCIES
424
+ foo
425
+ G
426
+ end
427
+
428
+ it "stores relative paths when the path is provided in an absolute fashion but is relative" do
429
+ build_lib "foo", :path => bundled_app('foo')
430
+
431
+ install_gemfile <<-G
432
+ path File.expand_path("../foo", __FILE__)
433
+ gem "foo"
434
+ G
435
+
436
+ lockfile_should_be <<-G
437
+ PATH
438
+ remote: foo
439
+ specs:
440
+ foo (1.0)
441
+
442
+ GEM
443
+ specs:
444
+
445
+ PLATFORMS
446
+ #{generic(Gem::Platform.local)}
447
+
448
+ DEPENDENCIES
449
+ foo
450
+ G
451
+ end
452
+
453
+ it "keeps existing platforms in the lockfile" do
454
+ lockfile <<-G
455
+ GEM
456
+ remote: file:#{gem_repo1}/
457
+ specs:
458
+ rack (1.0.0)
459
+
460
+ PLATFORMS
461
+ java
462
+
463
+ DEPENDENCIES
464
+ rack
465
+ G
466
+
467
+ install_gemfile <<-G
468
+ source "file://#{gem_repo1}"
469
+
470
+ gem "rack"
471
+ G
472
+
473
+ platforms = ['java', generic(Gem::Platform.local).to_s].sort
474
+
475
+ lockfile_should_be <<-G
476
+ GEM
477
+ remote: file:#{gem_repo1}/
478
+ specs:
479
+ rack (1.0.0)
480
+
481
+ PLATFORMS
482
+ #{platforms[0]}
483
+ #{platforms[1]}
484
+
485
+ DEPENDENCIES
486
+ rack
487
+ G
488
+ end
489
+
490
+ it "persists the spec's platform to the lockfile" do
491
+ build_gem "platform_specific", "1.0.0", :to_system => true do |s|
492
+ s.platform = Gem::Platform.new('universal-java-16')
493
+ end
494
+
495
+ simulate_platform "universal-java-16"
496
+
497
+ install_gemfile <<-G
498
+ source "file://#{gem_repo1}"
499
+ gem "platform_specific"
500
+ G
501
+
502
+ lockfile_should_be <<-G
503
+ GEM
504
+ remote: file:#{gem_repo1}/
505
+ specs:
506
+ platform_specific (1.0-java)
507
+
508
+ PLATFORMS
509
+ java
510
+
511
+ DEPENDENCIES
512
+ platform_specific
513
+ G
514
+ end
515
+
516
+ it "does not add duplicate gems" do
517
+ install_gemfile <<-G
518
+ source "file://#{gem_repo1}"
519
+ gem "rack"
520
+ G
521
+
522
+ install_gemfile <<-G
523
+ source "file://#{gem_repo1}"
524
+ gem "rack"
525
+ gem "activesupport"
526
+ G
527
+
528
+ lockfile_should_be <<-G
529
+ GEM
530
+ remote: file:#{gem_repo1}/
531
+ specs:
532
+ activesupport (2.3.5)
533
+ rack (1.0.0)
534
+
535
+ PLATFORMS
536
+ ruby
537
+
538
+ DEPENDENCIES
539
+ activesupport
540
+ rack
541
+ G
542
+ end
543
+
544
+ it "does not add duplicate dependencies" do
545
+ install_gemfile <<-G
546
+ source "file://#{gem_repo1}"
547
+ gem "rack"
548
+ gem "rack"
549
+ G
550
+
551
+ lockfile_should_be <<-G
552
+ GEM
553
+ remote: file:#{gem_repo1}/
554
+ specs:
555
+ rack (1.0.0)
556
+
557
+ PLATFORMS
558
+ ruby
559
+
560
+ DEPENDENCIES
561
+ rack
562
+ G
563
+ end
564
+
565
+ it "does not add duplicate dependencies with versions" do
566
+ install_gemfile <<-G
567
+ source "file://#{gem_repo1}"
568
+ gem "rack", "1.0"
569
+ gem "rack", "1.0"
570
+ G
571
+
572
+ lockfile_should_be <<-G
573
+ GEM
574
+ remote: file:#{gem_repo1}/
575
+ specs:
576
+ rack (1.0.0)
577
+
578
+ PLATFORMS
579
+ ruby
580
+
581
+ DEPENDENCIES
582
+ rack (= 1.0)
583
+ G
584
+ end
585
+
586
+ it "does not add duplicate dependencies in different groups" do
587
+ install_gemfile <<-G
588
+ source "file://#{gem_repo1}"
589
+ gem "rack", "1.0", :group => :one
590
+ gem "rack", "1.0", :group => :two
591
+ G
592
+
593
+ lockfile_should_be <<-G
594
+ GEM
595
+ remote: file:#{gem_repo1}/
596
+ specs:
597
+ rack (1.0.0)
598
+
599
+ PLATFORMS
600
+ ruby
601
+
602
+ DEPENDENCIES
603
+ rack (= 1.0)
604
+ G
605
+ end
606
+
607
+ it "raises if two different versions are used" do
608
+ install_gemfile <<-G
609
+ source "file://#{gem_repo1}"
610
+ gem "rack", "1.0"
611
+ gem "rack", "1.1"
612
+ G
613
+
614
+ bundled_app("Gemfile.lock").should_not exist
615
+ out.should include "rack (= 1.0) and rack (= 1.1)"
616
+ end
617
+
618
+
619
+ it "raises if two different versions are used" do
620
+ install_gemfile <<-G
621
+ source "file://#{gem_repo1}"
622
+ gem "rack"
623
+ gem "rack", :git => "git://hubz.com"
624
+ G
625
+
626
+ bundled_app("Gemfile.lock").should_not exist
627
+ out.should include "rack (>= 0) should come from an unspecfied source and git://hubz.com (at master)"
628
+ end
629
+
630
+ it "works correctly with multiple version dependencies" do
631
+ install_gemfile <<-G
632
+ source "file://#{gem_repo1}"
633
+ gem "rack", "> 0.9", "< 1.0"
634
+ G
635
+
636
+ lockfile_should_be <<-G
637
+ GEM
638
+ remote: file:#{gem_repo1}/
639
+ specs:
640
+ rack (0.9.1)
641
+
642
+ PLATFORMS
643
+ ruby
644
+
645
+ DEPENDENCIES
646
+ rack (> 0.9, < 1.0)
647
+ G
648
+
649
+ end
650
+
651
+ context "line endings" do
652
+ before(:each) do
653
+ build_repo2
654
+ install_gemfile <<-G
655
+ source "file://#{gem_repo2}"
656
+ gem "rack"
657
+ G
658
+ end
659
+
660
+ it "generates Gemfile.lock with \\n line endings" do
661
+ File.read(bundled_app("Gemfile.lock")).should_not match("\r\n")
662
+ should_be_installed "rack 1.0"
663
+ end
664
+
665
+ it "preserves Gemfile.lock \\n line endings" do
666
+ update_repo2
667
+
668
+ bundle "update"
669
+ File.read(bundled_app("Gemfile.lock")).should_not match("\r\n")
670
+ should_be_installed "rack 1.2"
671
+ end
672
+
673
+ it "preserves Gemfile.lock \\n\\r line endings" do
674
+ update_repo2
675
+ win_lock = File.read(bundled_app("Gemfile.lock")).gsub(/\n/, "\r\n")
676
+ File.open(bundled_app("Gemfile.lock"), "wb"){|f| f.puts(win_lock) }
677
+
678
+ bundle "update"
679
+ File.read(bundled_app("Gemfile.lock")).should match("\r\n")
680
+ should_be_installed "rack 1.2"
681
+ end
682
+ end
683
+ end