bowline-bundler 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/LICENSE +20 -0
- data/README.markdown +291 -0
- data/Rakefile +45 -0
- data/VERSION +1 -0
- data/bin/bowline-bundle +59 -0
- data/lib/bowline/bundler/bundle.rb +323 -0
- data/lib/bowline/bundler/cli.rb +87 -0
- data/lib/bowline/bundler/dependency.rb +62 -0
- data/lib/bowline/bundler/dsl.rb +182 -0
- data/lib/bowline/bundler/environment.rb +87 -0
- data/lib/bowline/bundler/finder.rb +51 -0
- data/lib/bowline/bundler/gem_bundle.rb +11 -0
- data/lib/bowline/bundler/gem_ext.rb +34 -0
- data/lib/bowline/bundler/remote_specification.rb +53 -0
- data/lib/bowline/bundler/resolver.rb +250 -0
- data/lib/bowline/bundler/runtime.rb +2 -0
- data/lib/bowline/bundler/source.rb +361 -0
- data/lib/bowline/bundler/templates/app_script.erb +3 -0
- data/lib/bowline/bundler/templates/environment.erb +156 -0
- data/lib/bowline/bundler/templates/environment_picker.erb +4 -0
- data/lib/bowline/bundler.rb +35 -0
- data/spec/bundler/cli_spec.rb +558 -0
- data/spec/bundler/directory_spec.rb +255 -0
- data/spec/bundler/dsl_spec.rb +126 -0
- data/spec/bundler/fetcher_spec.rb +138 -0
- data/spec/bundler/git_spec.rb +266 -0
- data/spec/bundler/installer_spec.rb +155 -0
- data/spec/bundler/manifest_file_spec.rb +105 -0
- data/spec/bundler/manifest_spec.rb +257 -0
- data/spec/bundler/runtime_spec.rb +141 -0
- data/spec/bundler/system_gems_spec.rb +42 -0
- data/spec/quality_spec.rb +57 -0
- data/spec/resolver/engine_spec.rb +112 -0
- data/spec/resolver/error_spec.rb +50 -0
- data/spec/resolver/fake_source_index_spec.rb +43 -0
- data/spec/resolver/prerelease_spec.rb +113 -0
- data/spec/spec_helper.rb +46 -0
- data/spec/support/builders.rb +257 -0
- data/spec/support/core_ext.rb +18 -0
- data/spec/support/helpers.rb +126 -0
- data/spec/support/matchers.rb +201 -0
- data/spec/support/path_utils.rb +63 -0
- metadata +126 -0
@@ -0,0 +1,257 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
+
|
3
|
+
describe "Bundler::Environment" do
|
4
|
+
|
5
|
+
describe "Manifest with dependencies" do
|
6
|
+
|
7
|
+
before :each do
|
8
|
+
@manifest = build_manifest <<-Gemfile
|
9
|
+
clear_sources
|
10
|
+
source "file://#{gem_repo1}"
|
11
|
+
gem "rails", "2.3.2"
|
12
|
+
gem "rack", "0.9.1"
|
13
|
+
Gemfile
|
14
|
+
end
|
15
|
+
|
16
|
+
it "bundles itself (running all of the steps)" do
|
17
|
+
@manifest.install
|
18
|
+
|
19
|
+
gems = %w(rack-0.9.1 actionmailer-2.3.2
|
20
|
+
activerecord-2.3.2 activesupport-2.3.2
|
21
|
+
rake-0.8.7 actionpack-2.3.2
|
22
|
+
activeresource-2.3.2 rails-2.3.2)
|
23
|
+
|
24
|
+
bundled_path.should have_cached_gems(*gems)
|
25
|
+
bundled_path.should have_installed_gems(*gems)
|
26
|
+
end
|
27
|
+
|
28
|
+
it "skips fetching the source index if all gems are present" do
|
29
|
+
Dir.chdir(bundled_app) do
|
30
|
+
gem_command :bundle
|
31
|
+
lambda { sleep 0.1 ; gem_command :bundle }.should_not change { File.stat(gem_repo1.join("Marshal.4.8.Z")).atime }
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
it "logs 'Done' when done" do
|
36
|
+
@manifest.install
|
37
|
+
@log_output.should have_log_message("Done.")
|
38
|
+
end
|
39
|
+
|
40
|
+
it "does the full fetching if a gem in the cache does not match the manifest" do
|
41
|
+
@manifest.install
|
42
|
+
|
43
|
+
m = build_manifest <<-Gemfile
|
44
|
+
clear_sources
|
45
|
+
source "file://#{gem_repo1}"
|
46
|
+
gem "rails", "2.3.2"
|
47
|
+
gem "rack", "1.0.0"
|
48
|
+
Gemfile
|
49
|
+
|
50
|
+
m.install
|
51
|
+
|
52
|
+
gems = %w(rack-1.0.0 actionmailer-2.3.2
|
53
|
+
activerecord-2.3.2 activesupport-2.3.2
|
54
|
+
rake-0.8.7 actionpack-2.3.2
|
55
|
+
activeresource-2.3.2 rails-2.3.2)
|
56
|
+
|
57
|
+
# Keeps cached gems
|
58
|
+
tmp_gem_path.should have_cached_gems(*(gems + ["rack-0.9.1"]))
|
59
|
+
tmp_gem_path.should have_installed_gems(*gems)
|
60
|
+
end
|
61
|
+
|
62
|
+
it "removes gems that are not needed anymore" do
|
63
|
+
@manifest.install
|
64
|
+
tmp_gem_path.should include_cached_gem("rack-0.9.1")
|
65
|
+
tmp_gem_path.should include_installed_gem("rack-0.9.1")
|
66
|
+
tmp_bindir("rackup").should exist
|
67
|
+
|
68
|
+
m = build_manifest <<-Gemfile
|
69
|
+
clear_sources
|
70
|
+
source "file://#{gem_repo1}"
|
71
|
+
gem "rails", "2.3.2"
|
72
|
+
Gemfile
|
73
|
+
|
74
|
+
m.install
|
75
|
+
|
76
|
+
# Gem caches are not removed
|
77
|
+
tmp_gem_path.should include_cached_gem("rack-0.9.1")
|
78
|
+
tmp_gem_path.should_not include_installed_gem("rack-0.9.1")
|
79
|
+
tmp_bindir("rackup").should_not exist
|
80
|
+
@log_output.should have_log_message("Deleting gem: rack (0.9.1)")
|
81
|
+
@log_output.should have_log_message("Deleting bin file: rackup")
|
82
|
+
end
|
83
|
+
|
84
|
+
it "raises a friendly exception if the manifest doesn't resolve" do
|
85
|
+
pending
|
86
|
+
build_manifest <<-Gemfile
|
87
|
+
clear_sources
|
88
|
+
source "file://#{gem_repo1}"
|
89
|
+
source "file://#{gem_repo2}"
|
90
|
+
gem "rails", "2.3.2"
|
91
|
+
gem "rack", "0.9.1"
|
92
|
+
gem "active_support", "2.0"
|
93
|
+
Gemfile
|
94
|
+
Dir.chdir(tmp_dir)
|
95
|
+
|
96
|
+
lambda do
|
97
|
+
Bundler::CLI.run(:bundle)
|
98
|
+
end.should raise_error(SystemExit)
|
99
|
+
|
100
|
+
@log_output.should have_log_message(/rails \(= 2\.3\.2.*rack \(= 0\.9\.1.*active_support \(= 2\.0/m)
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
describe "runtime" do
|
105
|
+
|
106
|
+
it "is able to work system gems" do
|
107
|
+
system_gems "rake-0.8.7" do
|
108
|
+
install_manifest <<-Gemfile
|
109
|
+
clear_sources
|
110
|
+
source "file://#{gem_repo1}"
|
111
|
+
gem "rack"
|
112
|
+
Gemfile
|
113
|
+
|
114
|
+
out = run_in_context "require 'rake' ; puts RAKE"
|
115
|
+
out.should == "0.8.7"
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
it "it does not work with system gems if system gems have been disabled" do
|
120
|
+
system_gems 'rspec-1.2.7' do
|
121
|
+
m = build_manifest <<-Gemfile
|
122
|
+
clear_sources
|
123
|
+
source "file://#{gem_repo1}"
|
124
|
+
gem "rack"
|
125
|
+
disable_system_gems
|
126
|
+
Gemfile
|
127
|
+
|
128
|
+
m.install
|
129
|
+
out = run_in_context "begin ; require 'spec' ; rescue LoadError ; puts('WIN') ; end"
|
130
|
+
out.should == "WIN"
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
["Running with system gems", "Running without system gems"].each_with_index do |desc, i|
|
135
|
+
describe desc do
|
136
|
+
before(:each) do
|
137
|
+
m = build_manifest <<-Gemfile
|
138
|
+
clear_sources
|
139
|
+
source "file://#{gem_repo1}"
|
140
|
+
gem "rake"
|
141
|
+
#{'disable_system_gems' if i == 1}
|
142
|
+
Gemfile
|
143
|
+
m.install
|
144
|
+
end
|
145
|
+
|
146
|
+
it "sets loaded_from on the specs" do
|
147
|
+
out = run_in_context "puts(Gem.loaded_specs['rake'].loaded_from || 'FAIL')"
|
148
|
+
out.should_not == "FAIL"
|
149
|
+
end
|
150
|
+
|
151
|
+
it "finds the gems in the source_index" do
|
152
|
+
out = run_in_context "puts Gem.source_index.find_name('rake').length"
|
153
|
+
out.should == "1"
|
154
|
+
end
|
155
|
+
|
156
|
+
it "still finds the gems in the source_index even if refresh! is called" do
|
157
|
+
out = run_in_context "Gem.source_index.refresh! ; puts Gem.source_index.find_name('rake').length"
|
158
|
+
out.should == "1"
|
159
|
+
end
|
160
|
+
end
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
describe "environments" do
|
165
|
+
before(:each) do
|
166
|
+
@manifest = build_manifest <<-Gemfile
|
167
|
+
clear_sources
|
168
|
+
source "file://#{gem_repo1}"
|
169
|
+
gem "rake", :only => "testing"
|
170
|
+
gem "rack", "1.0.0"
|
171
|
+
Gemfile
|
172
|
+
|
173
|
+
@manifest.install
|
174
|
+
end
|
175
|
+
|
176
|
+
it "requires the Rubygems library" do
|
177
|
+
out = run_in_context "puts 'Gem'"
|
178
|
+
out.should == "Gem"
|
179
|
+
end
|
180
|
+
|
181
|
+
it "Gem.loaded_specs has the gems that are included" do
|
182
|
+
out = run_in_context %'puts Gem.loaded_specs.map{|k,v|"\#{k} - \#{v.version}"}'
|
183
|
+
out.should include("rack - 1.0.0")
|
184
|
+
end
|
185
|
+
|
186
|
+
it "Gem.loaded_specs has the gems that are included in the testing environment" do
|
187
|
+
out = run_in_context %'puts Gem.loaded_specs.map{|k,v|"\#{k} - \#{v.version}"}'
|
188
|
+
out.should include("rack - 1.0.0")
|
189
|
+
out.should include("rake - 0.8.7")
|
190
|
+
end
|
191
|
+
end
|
192
|
+
|
193
|
+
describe "YAML description" do
|
194
|
+
before :each do
|
195
|
+
pending
|
196
|
+
build_repo2
|
197
|
+
end
|
198
|
+
|
199
|
+
it "it does not pull remote updates if the Gemfile did not change" do
|
200
|
+
install_manifest <<-Gemfile
|
201
|
+
clear_sources
|
202
|
+
source "file://#{gem_repo2}"
|
203
|
+
gem "rack", ">= 1.0"
|
204
|
+
Gemfile
|
205
|
+
|
206
|
+
update_repo2
|
207
|
+
|
208
|
+
Dir.chdir bundled_app
|
209
|
+
gem_command :bundle
|
210
|
+
out = run_in_context "Bundler.require_env ; puts RACK"
|
211
|
+
out.should == "1.0"
|
212
|
+
end
|
213
|
+
|
214
|
+
it "it does not pull remote updates if the Gemfile did not *significantly* change" do
|
215
|
+
install_manifest <<-Gemfile
|
216
|
+
clear_sources
|
217
|
+
source "file://#{gem_repo2}"
|
218
|
+
gem "rack", ">= 1.0"
|
219
|
+
Gemfile
|
220
|
+
|
221
|
+
update_repo2
|
222
|
+
|
223
|
+
install_manifest <<-Gemfile
|
224
|
+
clear_sources
|
225
|
+
source "file://#{gem_repo2}"
|
226
|
+
# Save this newline kthx
|
227
|
+
gem "rack"
|
228
|
+
Gemfile
|
229
|
+
|
230
|
+
Dir.chdir bundled_app
|
231
|
+
gem_command :bundle
|
232
|
+
out = run_in_context "Bundler.require_env ; puts RACK"
|
233
|
+
out.should == "1.0"
|
234
|
+
end
|
235
|
+
|
236
|
+
it "it does pull remote updates if the Gemfile changed" do
|
237
|
+
install_manifest <<-Gemfile
|
238
|
+
clear_sources
|
239
|
+
source "file://#{gem_repo2}"
|
240
|
+
gem "rack", ">= 1.0"
|
241
|
+
Gemfile
|
242
|
+
|
243
|
+
update_repo2
|
244
|
+
|
245
|
+
install_manifest <<-Gemfile
|
246
|
+
clear_sources
|
247
|
+
source "file://#{gem_repo2}"
|
248
|
+
gem "rack"
|
249
|
+
Gemfile
|
250
|
+
|
251
|
+
Dir.chdir bundled_app
|
252
|
+
gem_command :bundle
|
253
|
+
out = run_in_context "Bundler.require_env ; puts RACK"
|
254
|
+
out.should == "1.2"
|
255
|
+
end
|
256
|
+
end
|
257
|
+
end
|
@@ -0,0 +1,141 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
+
|
3
|
+
describe "Bundler runtime" do
|
4
|
+
|
5
|
+
describe "basic runtime options" do
|
6
|
+
it "requires files for all gems" do
|
7
|
+
install_manifest <<-Gemfile
|
8
|
+
clear_sources
|
9
|
+
source "file://#{gem_repo1}"
|
10
|
+
gem "very-simple"
|
11
|
+
Gemfile
|
12
|
+
|
13
|
+
out = run_in_context <<-RUBY
|
14
|
+
Bundler.require_env
|
15
|
+
puts VERYSIMPLE
|
16
|
+
RUBY
|
17
|
+
|
18
|
+
out.should == "1.0"
|
19
|
+
end
|
20
|
+
|
21
|
+
it "correctly requires the specified files" do
|
22
|
+
install_manifest <<-Gemfile
|
23
|
+
clear_sources
|
24
|
+
source "file://#{gem_repo1}"
|
25
|
+
gem "rspec", :require_as => %w(spec)
|
26
|
+
Gemfile
|
27
|
+
|
28
|
+
out = run_in_context <<-RUBY
|
29
|
+
Bundler.require_env
|
30
|
+
puts SPEC
|
31
|
+
RUBY
|
32
|
+
|
33
|
+
out.should == "1.2.7"
|
34
|
+
end
|
35
|
+
|
36
|
+
it "executes blocks at require time" do
|
37
|
+
install_manifest <<-Gemfile
|
38
|
+
clear_sources
|
39
|
+
source "file://#{gem_repo1}"
|
40
|
+
gem "very-simple" do
|
41
|
+
puts "Requiring"
|
42
|
+
end
|
43
|
+
Gemfile
|
44
|
+
|
45
|
+
out = run_in_context <<-RUBY
|
46
|
+
puts "Before"
|
47
|
+
Bundler.require_env
|
48
|
+
puts "After"
|
49
|
+
RUBY
|
50
|
+
|
51
|
+
out.should == "Before\nRequiring\nAfter"
|
52
|
+
end
|
53
|
+
|
54
|
+
it "does not raise an exception if the gem does not have a default file to require" do
|
55
|
+
install_manifest <<-Gemfile
|
56
|
+
clear_sources
|
57
|
+
source "file://#{gem_repo1}"
|
58
|
+
gem "rack-test"
|
59
|
+
Gemfile
|
60
|
+
|
61
|
+
out = run_in_context <<-RUBY
|
62
|
+
Bundler.require_env ; puts "Hello"
|
63
|
+
RUBY
|
64
|
+
|
65
|
+
out.should == "Hello"
|
66
|
+
end
|
67
|
+
|
68
|
+
it "raises an error if an explicitly specified require does not exist" do
|
69
|
+
install_manifest <<-Gemfile
|
70
|
+
clear_sources
|
71
|
+
source "file://#{gem_repo1}"
|
72
|
+
gem "rack-test", :require_as => 'rack-test'
|
73
|
+
Gemfile
|
74
|
+
|
75
|
+
out = run_in_context <<-RUBY
|
76
|
+
begin
|
77
|
+
Bundler.require_env
|
78
|
+
rescue LoadError => e
|
79
|
+
puts e.message
|
80
|
+
end
|
81
|
+
RUBY
|
82
|
+
|
83
|
+
out.should include("no such file to load -- rack-test")
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
describe "with environments" do
|
88
|
+
it "requires specific environments" do
|
89
|
+
install_manifest <<-Gemfile
|
90
|
+
clear_sources
|
91
|
+
source "file://#{gem_repo1}"
|
92
|
+
gem "very-simple"
|
93
|
+
Gemfile
|
94
|
+
|
95
|
+
out = run_in_context <<-RUBY
|
96
|
+
Bundler.require_env :test
|
97
|
+
puts VERYSIMPLE
|
98
|
+
RUBY
|
99
|
+
|
100
|
+
out.should == "1.0"
|
101
|
+
end
|
102
|
+
|
103
|
+
it "only requires gems in the environments they are exclusive to" do
|
104
|
+
install_manifest <<-Gemfile
|
105
|
+
clear_sources
|
106
|
+
source "file://#{gem_repo1}"
|
107
|
+
gem "very-simple", :only => :bar
|
108
|
+
Gemfile
|
109
|
+
|
110
|
+
out = run_in_context <<-RUBY
|
111
|
+
Bundler.require_env ; puts defined?(VERYSIMPLE).inspect
|
112
|
+
Bundler.require_env :foo ; puts defined?(VERYSIMPLE).inspect
|
113
|
+
Bundler.require_env :bar ; puts defined?(VERYSIMPLE)
|
114
|
+
RUBY
|
115
|
+
|
116
|
+
out.should == "nil\nnil\nconstant"
|
117
|
+
end
|
118
|
+
|
119
|
+
it "does not require gems in environments that they are excluded from" do
|
120
|
+
install_manifest <<-Gemfile
|
121
|
+
clear_sources
|
122
|
+
source "file://#{gem_repo1}"
|
123
|
+
gem "very-simple", :except => :bar
|
124
|
+
Gemfile
|
125
|
+
|
126
|
+
out = run_in_context <<-RUBY
|
127
|
+
Bundler.require_env :bar ; puts defined?(VERYSIMPLE).inspect
|
128
|
+
Bundler.require_env :foo ; puts defined?(VERYSIMPLE)
|
129
|
+
RUBY
|
130
|
+
|
131
|
+
out.should == "nil\nconstant"
|
132
|
+
|
133
|
+
out = run_in_context <<-RUBY
|
134
|
+
Bundler.require_env ; puts defined?(VERYSIMPLE)
|
135
|
+
RUBY
|
136
|
+
|
137
|
+
out.should == "constant"
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
+
|
3
|
+
describe "Using Bundler with system gems" do
|
4
|
+
def bundle_rake_with_system_rack
|
5
|
+
system_gems 'rack-0.9.1' do
|
6
|
+
build_manifest_file <<-Gemfile
|
7
|
+
clear_sources
|
8
|
+
source "file://#{gem_repo1}"
|
9
|
+
gem "rack", :bundle => false
|
10
|
+
gem "rake"
|
11
|
+
Gemfile
|
12
|
+
|
13
|
+
Dir.chdir(bundled_app) do
|
14
|
+
gem_command :bundle
|
15
|
+
end
|
16
|
+
|
17
|
+
yield
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
it "does not download gems that are not in the bundle" do
|
22
|
+
bundle_rake_with_system_rack do
|
23
|
+
tmp_gem_path.should have_cached_gems('rake-0.8.7')
|
24
|
+
tmp_gem_path.should have_installed_gems('rake-0.8.7')
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
it "sets the load path to the system gem" do
|
29
|
+
bundle_rake_with_system_rack do
|
30
|
+
load_paths = run_in_context("puts $:").split("\n")
|
31
|
+
load_paths.should include("#{system_gem_path}/gems/rack-0.9.1/lib")
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
it "activates the correct version for the bundle even if new gems are installed" do
|
36
|
+
bundle_rake_with_system_rack do
|
37
|
+
install_gem("rack-1.0.0")
|
38
|
+
load_paths = run_in_context("puts $:").split("\n")
|
39
|
+
load_paths.should include("#{system_gem_path}/gems/rack-0.9.1/lib")
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
|
3
|
+
describe "The library itself" do
|
4
|
+
|
5
|
+
# match do |filename|
|
6
|
+
# @failing_lines = []
|
7
|
+
# File.readlines(filename).each_with_index do |line,number|
|
8
|
+
# @failing_lines << number + 1 if line =~ /\t/
|
9
|
+
# end
|
10
|
+
# @failing_lines.empty?
|
11
|
+
# end
|
12
|
+
#
|
13
|
+
# failure_message_for_should do |filename|
|
14
|
+
# "The file #{filename} has tab characters on lines #{@failing_lines.join(', ')}"
|
15
|
+
# end
|
16
|
+
def check_for_tab_characters(filename)
|
17
|
+
failing_lines = []
|
18
|
+
File.readlines(filename).each_with_index do |line,number|
|
19
|
+
failing_lines << number + 1 if line =~ /\t/
|
20
|
+
end
|
21
|
+
|
22
|
+
unless failing_lines.empty?
|
23
|
+
"#{filename} has tab characters on lines #{failing_lines.join(', ')}"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def check_for_extra_spaces(filename)
|
28
|
+
failing_lines = []
|
29
|
+
File.readlines(filename).each_with_index do |line,number|
|
30
|
+
next if line =~ /^\s+#.*\s+\n$/
|
31
|
+
failing_lines << number + 1 if line =~ /\s+\n$/
|
32
|
+
end
|
33
|
+
|
34
|
+
unless failing_lines.empty?
|
35
|
+
"#{filename} has spaces on the EOL on lines #{failing_lines.join(', ')}"
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def be_well_formed
|
40
|
+
simple_matcher("be well formed") do |given, matcher|
|
41
|
+
matcher.failure_message = given.join("\n")
|
42
|
+
given.empty?
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
it "has no malformed whitespace" do
|
47
|
+
error_messages = []
|
48
|
+
Dir.chdir(File.dirname(__FILE__) + '/..') do
|
49
|
+
`git ls-files`.split("\n").each do |filename|
|
50
|
+
next if filename =~ /\.gitmodules|fixtures/
|
51
|
+
error_messages << check_for_tab_characters(filename)
|
52
|
+
error_messages << check_for_extra_spaces(filename)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
error_messages.compact.should be_well_formed
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,112 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
+
|
3
|
+
describe "Resolving specs" do
|
4
|
+
it "supports a single dependency" do
|
5
|
+
index = build_index do
|
6
|
+
add_spec "bar", "2.0.0"
|
7
|
+
end
|
8
|
+
|
9
|
+
deps = [
|
10
|
+
build_dep("bar", ">= 1.2.3"),
|
11
|
+
]
|
12
|
+
|
13
|
+
solution = Bundler::Resolver.resolve(deps, [index])
|
14
|
+
solution.should match_gems(
|
15
|
+
"bar" => ["2.0.0"]
|
16
|
+
)
|
17
|
+
end
|
18
|
+
|
19
|
+
it "prefers JRuby gems" do
|
20
|
+
index = build_index do
|
21
|
+
add_spec "bar", "2.0.0", [nil, "jruby", nil]
|
22
|
+
add_spec "bar", "2.0.0", [nil, "ruby", nil]
|
23
|
+
end
|
24
|
+
|
25
|
+
deps = [
|
26
|
+
build_dep("bar", ">= 1.2.3"),
|
27
|
+
]
|
28
|
+
|
29
|
+
solution = Bundler::Resolver.resolve(deps, [index])
|
30
|
+
solution.first.platform.should == Gem::Platform.new([nil, "jruby", nil])
|
31
|
+
end
|
32
|
+
|
33
|
+
it "supports a crazy case" do
|
34
|
+
index = build_index do
|
35
|
+
add_spec "activemerchant", "1.4.1" do
|
36
|
+
runtime "activesupport", ">= 1.4.1"
|
37
|
+
end
|
38
|
+
add_spec "activesupport", "3.0.0"
|
39
|
+
add_spec "activesupport", "2.3.2"
|
40
|
+
add_spec "action_pack", "2.3.2" do
|
41
|
+
runtime "activesupport", "= 2.3.2"
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
deps = [
|
46
|
+
build_dep("activemerchant", ">= 0"),
|
47
|
+
build_dep("action_pack", "= 2.3.2")
|
48
|
+
]
|
49
|
+
|
50
|
+
solution = Bundler::Resolver.resolve(deps, [index])
|
51
|
+
solution.should match_gems(
|
52
|
+
"activemerchant" => ["1.4.1"],
|
53
|
+
"action_pack" => ["2.3.2"],
|
54
|
+
"activesupport" => ["2.3.2"]
|
55
|
+
)
|
56
|
+
end
|
57
|
+
|
58
|
+
it "supports nested dependencies" do
|
59
|
+
index = build_index do
|
60
|
+
add_spec "bar", "2.0.0" do
|
61
|
+
runtime "foo", ">= 1"
|
62
|
+
end
|
63
|
+
add_spec "foo", "1.1"
|
64
|
+
end
|
65
|
+
|
66
|
+
deps = [
|
67
|
+
build_dep("bar", ">= 1.2.3"),
|
68
|
+
]
|
69
|
+
|
70
|
+
solution = Bundler::Resolver.resolve(deps, [index])
|
71
|
+
solution.should match_gems(
|
72
|
+
"bar" => ["2.0.0"],
|
73
|
+
"foo" => ["1.1"]
|
74
|
+
)
|
75
|
+
end
|
76
|
+
|
77
|
+
it "supports locked dependencies" do
|
78
|
+
index = build_index do
|
79
|
+
add_spec "bar", "1.0" do
|
80
|
+
runtime "foo", "= 1.0"
|
81
|
+
end
|
82
|
+
add_spec "bar", "1.1" do
|
83
|
+
runtime "foo", "= 1.1"
|
84
|
+
end
|
85
|
+
add_spec "foo", "1.0"
|
86
|
+
add_spec "foo", "1.1"
|
87
|
+
end
|
88
|
+
|
89
|
+
deps = [
|
90
|
+
build_dep("bar", ">= 1.0"),
|
91
|
+
build_dep("foo", "= 1.0"),
|
92
|
+
]
|
93
|
+
|
94
|
+
solution = Bundler::Resolver.resolve(deps, [index])
|
95
|
+
solution.should match_gems(
|
96
|
+
"bar" => ["1.0"],
|
97
|
+
"foo" => ["1.0"]
|
98
|
+
)
|
99
|
+
end
|
100
|
+
|
101
|
+
it "supports impossible situations" do
|
102
|
+
index = build_index do
|
103
|
+
add_spec "a", "1.0"
|
104
|
+
end
|
105
|
+
|
106
|
+
deps = [
|
107
|
+
build_dep("a", "= 1.1"),
|
108
|
+
]
|
109
|
+
|
110
|
+
lambda { Bundler::Resolver.resolve(deps, [index]) }.should raise_error(Bundler::GemNotFound)
|
111
|
+
end
|
112
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
+
|
3
|
+
describe "Bundler error reporting" do
|
4
|
+
|
5
|
+
it "reports an error when a root level dependency is not found in the index" do
|
6
|
+
index = build_index do
|
7
|
+
add_spec "bar", "2.0.0"
|
8
|
+
end
|
9
|
+
|
10
|
+
deps = [build_dep("foo")]
|
11
|
+
lambda { Bundler::Resolver.resolve(deps, [index]) }.should raise_error(Bundler::GemNotFound)
|
12
|
+
end
|
13
|
+
|
14
|
+
it "outputs a warning if a child dependency is not found but the dependency graph can be resolved" do
|
15
|
+
index = build_index do
|
16
|
+
add_spec "foo", "1.0" do
|
17
|
+
runtime "missing", ">= 0"
|
18
|
+
end
|
19
|
+
add_spec "foo", "0.5" do
|
20
|
+
runtime "present", ">= 0"
|
21
|
+
end
|
22
|
+
add_spec "present", "1.0"
|
23
|
+
end
|
24
|
+
|
25
|
+
deps = [build_dep("foo")]
|
26
|
+
Bundler::Resolver.resolve(deps, [index]).should_not be_nil
|
27
|
+
@log_output.should have_log_message("Could not find gem 'missing (>= 0, runtime)' (required by 'foo (>= 0, runtime)') in any of the sources")
|
28
|
+
end
|
29
|
+
|
30
|
+
it "reports a helpful error when a VersionConflict is encountered" do
|
31
|
+
index = build_index do
|
32
|
+
add_spec "rails", "2.0" do
|
33
|
+
runtime "actionpack", "= 2.0"
|
34
|
+
end
|
35
|
+
add_spec "actionpack", "2.0" do
|
36
|
+
runtime "activesupport", "= 2.0"
|
37
|
+
end
|
38
|
+
add_spec "activesupport", "2.0"
|
39
|
+
add_spec "activesupport", "1.5"
|
40
|
+
add_spec "activemerchant", "1.5" do
|
41
|
+
runtime "activesupport", "= 1.5"
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
deps = [build_dep("rails"), build_dep("activemerchant")]
|
46
|
+
|
47
|
+
lambda { Bundler::Resolver.resolve(deps, [index]) }.
|
48
|
+
should raise_error(Bundler::VersionConflict, /No compatible versions could be found for required dependencies/)
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
+
|
3
|
+
describe "Bundler::Resolver" do
|
4
|
+
describe "with a single gem" do
|
5
|
+
before(:each) do
|
6
|
+
@index = build_index do
|
7
|
+
add_spec "foo", "0.2.2"
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
it "can search for that gem" do
|
12
|
+
specs = @index.find_name("foo", "=0.2.2")
|
13
|
+
specs.should match_gems(
|
14
|
+
"foo" => ["0.2.2"]
|
15
|
+
)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
describe "with a lots of gems" do
|
20
|
+
before(:each) do
|
21
|
+
@index = build_index do
|
22
|
+
add_spec "foo", "0.2.1"
|
23
|
+
add_spec "foo", "0.2.2"
|
24
|
+
add_spec "foo", "0.3.0"
|
25
|
+
add_spec "foo", "1.1.0"
|
26
|
+
|
27
|
+
add_spec "bar", "0.2.2"
|
28
|
+
add_spec "bar", "0.2.3"
|
29
|
+
add_spec "bar", "0.2.4"
|
30
|
+
add_spec "bar", "0.2.5"
|
31
|
+
add_spec "bar", "0.3.5"
|
32
|
+
add_spec "bar", "0.4.5"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
it "can search for 'foo', '>= 0.2.2'" do
|
37
|
+
specs = @index.find_name("foo", ">= 0.2.2")
|
38
|
+
specs.should match_gems(
|
39
|
+
"foo" => ["0.2.2", "0.3.0", "1.1.0"]
|
40
|
+
)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|