honkster-bundler 1.1.pre

Sign up to get free protection for your applications and to get access to all the features.
Files changed (137) hide show
  1. data/.gitignore +14 -0
  2. data/CHANGELOG.md +547 -0
  3. data/ISSUES.md +32 -0
  4. data/LICENSE +20 -0
  5. data/README.md +29 -0
  6. data/Rakefile +150 -0
  7. data/UPGRADING.md +103 -0
  8. data/bin/bundle +21 -0
  9. data/bundler.gemspec +30 -0
  10. data/lib/bundler.rb +268 -0
  11. data/lib/bundler/capistrano.rb +11 -0
  12. data/lib/bundler/cli.rb +515 -0
  13. data/lib/bundler/definition.rb +427 -0
  14. data/lib/bundler/dependency.rb +114 -0
  15. data/lib/bundler/deployment.rb +37 -0
  16. data/lib/bundler/dsl.rb +245 -0
  17. data/lib/bundler/environment.rb +47 -0
  18. data/lib/bundler/gem_helper.rb +145 -0
  19. data/lib/bundler/graph.rb +130 -0
  20. data/lib/bundler/index.rb +114 -0
  21. data/lib/bundler/installer.rb +84 -0
  22. data/lib/bundler/lazy_specification.rb +71 -0
  23. data/lib/bundler/lockfile_parser.rb +108 -0
  24. data/lib/bundler/remote_specification.rb +59 -0
  25. data/lib/bundler/resolver.rb +454 -0
  26. data/lib/bundler/rubygems_ext.rb +203 -0
  27. data/lib/bundler/runtime.rb +148 -0
  28. data/lib/bundler/settings.rb +117 -0
  29. data/lib/bundler/setup.rb +15 -0
  30. data/lib/bundler/shared_helpers.rb +151 -0
  31. data/lib/bundler/source.rb +662 -0
  32. data/lib/bundler/spec_set.rb +134 -0
  33. data/lib/bundler/templates/Executable +16 -0
  34. data/lib/bundler/templates/Gemfile +4 -0
  35. data/lib/bundler/templates/newgem/Gemfile.tt +4 -0
  36. data/lib/bundler/templates/newgem/Rakefile.tt +2 -0
  37. data/lib/bundler/templates/newgem/bin/newgem.tt +3 -0
  38. data/lib/bundler/templates/newgem/gitignore.tt +3 -0
  39. data/lib/bundler/templates/newgem/lib/newgem.rb.tt +7 -0
  40. data/lib/bundler/templates/newgem/lib/newgem/version.rb.tt +7 -0
  41. data/lib/bundler/templates/newgem/newgem.gemspec.tt +21 -0
  42. data/lib/bundler/ui.rb +60 -0
  43. data/lib/bundler/vendor/thor.rb +319 -0
  44. data/lib/bundler/vendor/thor/actions.rb +297 -0
  45. data/lib/bundler/vendor/thor/actions/create_file.rb +105 -0
  46. data/lib/bundler/vendor/thor/actions/directory.rb +93 -0
  47. data/lib/bundler/vendor/thor/actions/empty_directory.rb +134 -0
  48. data/lib/bundler/vendor/thor/actions/file_manipulation.rb +229 -0
  49. data/lib/bundler/vendor/thor/actions/inject_into_file.rb +104 -0
  50. data/lib/bundler/vendor/thor/base.rb +556 -0
  51. data/lib/bundler/vendor/thor/core_ext/file_binary_read.rb +9 -0
  52. data/lib/bundler/vendor/thor/core_ext/hash_with_indifferent_access.rb +75 -0
  53. data/lib/bundler/vendor/thor/core_ext/ordered_hash.rb +100 -0
  54. data/lib/bundler/vendor/thor/error.rb +30 -0
  55. data/lib/bundler/vendor/thor/invocation.rb +168 -0
  56. data/lib/bundler/vendor/thor/parser.rb +4 -0
  57. data/lib/bundler/vendor/thor/parser/argument.rb +67 -0
  58. data/lib/bundler/vendor/thor/parser/arguments.rb +161 -0
  59. data/lib/bundler/vendor/thor/parser/option.rb +120 -0
  60. data/lib/bundler/vendor/thor/parser/options.rb +174 -0
  61. data/lib/bundler/vendor/thor/shell.rb +88 -0
  62. data/lib/bundler/vendor/thor/shell/basic.rb +275 -0
  63. data/lib/bundler/vendor/thor/shell/color.rb +108 -0
  64. data/lib/bundler/vendor/thor/shell/html.rb +121 -0
  65. data/lib/bundler/vendor/thor/task.rb +114 -0
  66. data/lib/bundler/vendor/thor/util.rb +229 -0
  67. data/lib/bundler/vendor/thor/version.rb +3 -0
  68. data/lib/bundler/version.rb +6 -0
  69. data/lib/bundler/vlad.rb +9 -0
  70. data/man/bundle-config.ronn +90 -0
  71. data/man/bundle-exec.ronn +98 -0
  72. data/man/bundle-install.ronn +310 -0
  73. data/man/bundle-package.ronn +59 -0
  74. data/man/bundle-update.ronn +176 -0
  75. data/man/bundle.ronn +77 -0
  76. data/man/gemfile.5.ronn +273 -0
  77. data/man/index.txt +6 -0
  78. data/spec/cache/gems_spec.rb +205 -0
  79. data/spec/cache/git_spec.rb +9 -0
  80. data/spec/cache/path_spec.rb +27 -0
  81. data/spec/cache/platform_spec.rb +57 -0
  82. data/spec/install/deploy_spec.rb +197 -0
  83. data/spec/install/deprecated_spec.rb +43 -0
  84. data/spec/install/gems/c_ext_spec.rb +48 -0
  85. data/spec/install/gems/env_spec.rb +107 -0
  86. data/spec/install/gems/flex_spec.rb +272 -0
  87. data/spec/install/gems/groups_spec.rb +228 -0
  88. data/spec/install/gems/packed_spec.rb +72 -0
  89. data/spec/install/gems/platform_spec.rb +195 -0
  90. data/spec/install/gems/resolving_spec.rb +72 -0
  91. data/spec/install/gems/simple_case_spec.rb +749 -0
  92. data/spec/install/gems/sudo_spec.rb +77 -0
  93. data/spec/install/gems/win32_spec.rb +26 -0
  94. data/spec/install/gemspec_spec.rb +96 -0
  95. data/spec/install/git_spec.rb +553 -0
  96. data/spec/install/invalid_spec.rb +17 -0
  97. data/spec/install/path_spec.rb +329 -0
  98. data/spec/install/upgrade_spec.rb +26 -0
  99. data/spec/lock/flex_spec.rb +650 -0
  100. data/spec/lock/git_spec.rb +35 -0
  101. data/spec/other/check_spec.rb +221 -0
  102. data/spec/other/config_spec.rb +40 -0
  103. data/spec/other/console_spec.rb +54 -0
  104. data/spec/other/exec_spec.rb +241 -0
  105. data/spec/other/ext_spec.rb +16 -0
  106. data/spec/other/gem_helper_spec.rb +126 -0
  107. data/spec/other/help_spec.rb +36 -0
  108. data/spec/other/init_spec.rb +40 -0
  109. data/spec/other/newgem_spec.rb +24 -0
  110. data/spec/other/open_spec.rb +35 -0
  111. data/spec/other/show_spec.rb +82 -0
  112. data/spec/pack/gems_spec.rb +22 -0
  113. data/spec/quality_spec.rb +55 -0
  114. data/spec/resolver/basic_spec.rb +20 -0
  115. data/spec/resolver/platform_spec.rb +57 -0
  116. data/spec/runtime/environment_rb_spec.rb +162 -0
  117. data/spec/runtime/executable_spec.rb +110 -0
  118. data/spec/runtime/load_spec.rb +102 -0
  119. data/spec/runtime/platform_spec.rb +90 -0
  120. data/spec/runtime/require_spec.rb +231 -0
  121. data/spec/runtime/setup_spec.rb +412 -0
  122. data/spec/runtime/with_clean_env_spec.rb +15 -0
  123. data/spec/spec_helper.rb +82 -0
  124. data/spec/support/builders.rb +566 -0
  125. data/spec/support/helpers.rb +243 -0
  126. data/spec/support/indexes.rb +113 -0
  127. data/spec/support/matchers.rb +89 -0
  128. data/spec/support/path.rb +71 -0
  129. data/spec/support/platforms.rb +49 -0
  130. data/spec/support/ruby_ext.rb +19 -0
  131. data/spec/support/rubygems_ext.rb +30 -0
  132. data/spec/support/rubygems_hax/rubygems_plugin.rb +9 -0
  133. data/spec/support/sudo.rb +21 -0
  134. data/spec/update/gems_spec.rb +112 -0
  135. data/spec/update/git_spec.rb +159 -0
  136. data/spec/update/source_spec.rb +50 -0
  137. metadata +251 -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,329 @@
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 "installs dependencies from the path even if a newer gem is available elsewhere" do
50
+ system_gems "rack-1.0.0"
51
+
52
+ build_lib "rack", "1.0", :path => lib_path('nested/bar') do |s|
53
+ s.write "lib/rack.rb", "puts 'WIN OVERRIDE'"
54
+ end
55
+
56
+ build_lib "foo", :path => lib_path('nested') do |s|
57
+ s.add_dependency "rack", "= 1.0"
58
+ end
59
+
60
+ install_gemfile <<-G
61
+ source "file://#{gem_repo1}"
62
+ gem "foo", :path => "#{lib_path('nested')}"
63
+ G
64
+
65
+ run "require 'rack'"
66
+ out.should == 'WIN OVERRIDE'
67
+ end
68
+
69
+ it "works" do
70
+ build_gem "foo", "1.0.0", :to_system => true do |s|
71
+ s.write "lib/foo.rb", "puts 'FAIL'"
72
+ end
73
+
74
+ build_lib "omg", "1.0", :path => lib_path("omg") do |s|
75
+ s.add_dependency "foo"
76
+ end
77
+
78
+ build_lib "foo", "1.0.0", :path => lib_path("omg/foo")
79
+
80
+ install_gemfile <<-G
81
+ gem "omg", :path => "#{lib_path('omg')}"
82
+ G
83
+
84
+ should_be_installed "foo 1.0"
85
+ end
86
+
87
+ it "supports gemspec syntax" do
88
+ build_lib "foo", "1.0", :path => lib_path("foo") do |s|
89
+ s.add_dependency "rack", "1.0"
90
+ end
91
+
92
+ gemfile = <<-G
93
+ source "file://#{gem_repo1}"
94
+ gemspec
95
+ G
96
+
97
+ File.open(lib_path("foo/Gemfile"), "w") {|f| f.puts gemfile }
98
+
99
+ Dir.chdir(lib_path("foo")) do
100
+ bundle "install"
101
+ should_be_installed "foo 1.0"
102
+ should_be_installed "rack 1.0"
103
+ end
104
+ end
105
+
106
+ it "supports gemspec syntax with an alternative path" do
107
+ build_lib "foo", "1.0", :path => lib_path("foo") do |s|
108
+ s.add_dependency "rack", "1.0"
109
+ end
110
+
111
+ install_gemfile <<-G
112
+ source "file://#{gem_repo1}"
113
+ gemspec :path => "#{lib_path("foo")}"
114
+ G
115
+
116
+ should_be_installed "foo 1.0"
117
+ should_be_installed "rack 1.0"
118
+ end
119
+
120
+ it "raises if there are multiple gemspecs" do
121
+ build_lib "foo", "1.0", :path => lib_path("foo") do |s|
122
+ s.write "bar.gemspec"
123
+ end
124
+
125
+ install_gemfile <<-G, :exitstatus => true
126
+ gemspec :path => "#{lib_path("foo")}"
127
+ G
128
+
129
+ @exitstatus.should == 15
130
+ out.should =~ /There are multiple gemspecs/
131
+ end
132
+
133
+ it "allows :name to be specified to resolve ambiguity" do
134
+ build_lib "foo", "1.0", :path => lib_path("foo") do |s|
135
+ s.write "bar.gemspec"
136
+ end
137
+
138
+ install_gemfile <<-G, :exitstatus => true
139
+ gemspec :path => "#{lib_path("foo")}", :name => "foo"
140
+ G
141
+
142
+ should_be_installed "foo 1.0"
143
+ end
144
+
145
+ it "sets up executables" do
146
+ pending_jruby_shebang_fix
147
+
148
+ build_lib "foo" do |s|
149
+ s.executables = "foobar"
150
+ end
151
+
152
+ install_gemfile <<-G
153
+ path "#{lib_path('foo-1.0')}"
154
+ gem 'foo'
155
+ G
156
+
157
+ bundle "exec foobar"
158
+ out.should == "1.0"
159
+ end
160
+
161
+ it "removes the .gem file after installing" do
162
+ build_lib "foo"
163
+
164
+ install_gemfile <<-G
165
+ gem 'foo', :path => "#{lib_path('foo-1.0')}"
166
+ G
167
+
168
+ lib_path('foo-1.0').join('foo-1.0.gem').should_not exist
169
+ end
170
+
171
+ describe "block syntax" do
172
+ it "pulls all gems from a path block" do
173
+ build_lib "omg"
174
+ build_lib "hi2u"
175
+
176
+ install_gemfile <<-G
177
+ path "#{lib_path}" do
178
+ gem "omg"
179
+ gem "hi2u"
180
+ end
181
+ G
182
+
183
+ should_be_installed "omg 1.0", "hi2u 1.0"
184
+ end
185
+ end
186
+
187
+ it "keeps source pinning" do
188
+ build_lib "foo", "1.0", :path => lib_path('foo')
189
+ build_lib "omg", "1.0", :path => lib_path('omg')
190
+ build_lib "foo", "1.0", :path => lib_path('omg/foo') do |s|
191
+ s.write "lib/foo.rb", "puts 'FAIL'"
192
+ end
193
+
194
+ install_gemfile <<-G
195
+ gem "foo", :path => "#{lib_path('foo')}"
196
+ gem "omg", :path => "#{lib_path('omg')}"
197
+ G
198
+
199
+ should_be_installed "foo 1.0"
200
+ end
201
+
202
+ it "works when the path does not have a gemspec" do
203
+ build_lib "foo", :gemspec => false
204
+
205
+ gemfile <<-G
206
+ gem "foo", "1.0", :path => "#{lib_path('foo-1.0')}"
207
+ G
208
+
209
+ should_be_installed "foo 1.0"
210
+
211
+ should_be_installed "foo 1.0"
212
+ end
213
+
214
+ it "installs executable stubs" do
215
+ build_lib "foo" do |s|
216
+ s.executables = ['foo']
217
+ end
218
+
219
+ install_gemfile <<-G
220
+ gem "foo", :path => "#{lib_path('foo-1.0')}"
221
+ G
222
+
223
+ bundle "exec foo"
224
+ out.should == "1.0"
225
+ end
226
+
227
+ describe "when the gem version in the path is updated" do
228
+ before :each do
229
+ build_lib "foo", "1.0", :path => lib_path("foo") do |s|
230
+ s.add_dependency "bar"
231
+ end
232
+ build_lib "bar", "1.0", :path => lib_path("foo/bar")
233
+
234
+ install_gemfile <<-G
235
+ gem "foo", :path => "#{lib_path('foo')}"
236
+ G
237
+ end
238
+
239
+ it "unlocks all gems when the top level gem is updated" do
240
+ build_lib "foo", "2.0", :path => lib_path("foo") do |s|
241
+ s.add_dependency "bar"
242
+ end
243
+
244
+ bundle "install"
245
+
246
+ should_be_installed "foo 2.0", "bar 1.0"
247
+ end
248
+
249
+ it "unlocks all gems when a child dependency gem is updated" do
250
+ build_lib "bar", "2.0", :path => lib_path("foo/bar")
251
+
252
+ bundle "install"
253
+
254
+ should_be_installed "foo 1.0", "bar 2.0"
255
+ end
256
+ end
257
+
258
+ describe "when dependencies in the path are updated" do
259
+ before :each do
260
+ build_lib "foo", "1.0", :path => lib_path("foo")
261
+
262
+ install_gemfile <<-G
263
+ source "file://#{gem_repo1}"
264
+ gem "foo", :path => "#{lib_path('foo')}"
265
+ G
266
+ end
267
+
268
+ it "gets dependencies that are updated in the path" do
269
+ build_lib "foo", "1.0", :path => lib_path("foo") do |s|
270
+ s.add_dependency "rack"
271
+ end
272
+
273
+ bundle "install"
274
+
275
+ should_be_installed "rack 1.0.0"
276
+ end
277
+ end
278
+
279
+ describe "switching sources" do
280
+ it "doesn't switch pinned git sources to rubygems when pinning the parent gem to a path source" do
281
+ build_gem "foo", "1.0", :to_system => true do |s|
282
+ s.write "lib/foo.rb", "raise 'fail'"
283
+ end
284
+ build_lib "foo", "1.0", :path => lib_path('bar/foo')
285
+ build_git "bar", "1.0", :path => lib_path('bar') do |s|
286
+ s.add_dependency 'foo'
287
+ end
288
+
289
+ install_gemfile <<-G
290
+ source "http://#{gem_repo1}"
291
+ gem "bar", :git => "#{lib_path('bar')}"
292
+ G
293
+
294
+ install_gemfile <<-G
295
+ source "http://#{gem_repo1}"
296
+ gem "bar", :path => "#{lib_path('bar')}"
297
+ G
298
+
299
+ should_be_installed "foo 1.0", "bar 1.0"
300
+ end
301
+
302
+ it "switches the source when the gem existed in rubygems and the path was already being used for another gem" do
303
+ build_lib "foo", "1.0", :path => lib_path("foo")
304
+ build_gem "bar", "1.0", :to_system => true do |s|
305
+ s.write "lib/bar.rb", "raise 'fail'"
306
+ end
307
+
308
+ install_gemfile <<-G
309
+ source "http://#{gem_repo1}"
310
+ gem "bar"
311
+ path "#{lib_path('foo')}" do
312
+ gem "foo"
313
+ end
314
+ G
315
+
316
+ build_lib "bar", "1.0", :path => lib_path("foo/bar")
317
+
318
+ install_gemfile <<-G
319
+ source "http://#{gem_repo1}"
320
+ path "#{lib_path('foo')}" do
321
+ gem "foo"
322
+ gem "bar"
323
+ end
324
+ G
325
+
326
+ should_be_installed "bar 1.0"
327
+ end
328
+ end
329
+ 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,650 @@
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
+ end