forked from rubygems/bundler
-
Notifications
You must be signed in to change notification settings - Fork 1
/
flex_spec.rb
272 lines (219 loc) · 5.98 KB
/
flex_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
require "spec_helper"
describe "bundle flex_install" do
it "installs the gems as expected" do
install_gemfile <<-G
source "file://#{gem_repo1}"
gem 'rack'
G
should_be_installed "rack 1.0.0"
should_be_locked
end
it "installs even when the lockfile is invalid" do
install_gemfile <<-G
source "file://#{gem_repo1}"
gem 'rack'
G
should_be_installed "rack 1.0.0"
should_be_locked
gemfile <<-G
source "file://#{gem_repo1}"
gem 'rack', '1.0'
G
bundle :install
should_be_installed "rack 1.0.0"
should_be_locked
end
it "keeps child dependencies at the same version" do
build_repo2
install_gemfile <<-G
source "file://#{gem_repo2}"
gem "rack-obama"
G
should_be_installed "rack 1.0.0", "rack-obama 1.0.0"
update_repo2
install_gemfile <<-G
source "file://#{gem_repo2}"
gem "rack-obama", "1.0"
G
should_be_installed "rack 1.0.0", "rack-obama 1.0.0"
end
describe "adding new gems" do
it "installs added gems without updating previously installed gems" do
build_repo2
install_gemfile <<-G
source "file://#{gem_repo2}"
gem 'rack'
G
update_repo2
install_gemfile <<-G
source "file://#{gem_repo2}"
gem 'rack'
gem 'activesupport', '2.3.5'
G
should_be_installed "rack 1.0.0", 'activesupport 2.3.5'
end
it "keeps child dependencies pinned" do
build_repo2
install_gemfile <<-G
source "file://#{gem_repo2}"
gem "rack-obama"
G
update_repo2
install_gemfile <<-G
source "file://#{gem_repo2}"
gem "rack-obama"
gem "thin"
G
should_be_installed "rack 1.0.0", 'rack-obama 1.0', 'thin 1.0'
end
end
describe "removing gems" do
it "removes gems without changing the versions of remaining gems" do
build_repo2
install_gemfile <<-G
source "file://#{gem_repo2}"
gem 'rack'
gem 'activesupport', '2.3.5'
G
update_repo2
install_gemfile <<-G
source "file://#{gem_repo2}"
gem 'rack'
G
should_be_installed "rack 1.0.0"
should_not_be_installed "activesupport 2.3.5"
install_gemfile <<-G
source "file://#{gem_repo2}"
gem 'rack'
gem 'activesupport', '2.3.2'
G
should_be_installed "rack 1.0.0", 'activesupport 2.3.2'
end
it "removes top level dependencies when removed from the Gemfile while leaving other dependencies intact" do
build_repo2
install_gemfile <<-G
source "file://#{gem_repo2}"
gem 'rack'
gem 'activesupport', '2.3.5'
G
update_repo2
install_gemfile <<-G
source "file://#{gem_repo2}"
gem 'rack'
G
should_not_be_installed "activesupport 2.3.5"
end
it "removes child dependencies" do
build_repo2
install_gemfile <<-G
source "file://#{gem_repo2}"
gem 'rack-obama'
gem 'activesupport'
G
should_be_installed "rack 1.0.0", "rack-obama 1.0.0", "activesupport 2.3.5"
update_repo2
install_gemfile <<-G
source "file://#{gem_repo2}"
gem 'activesupport'
G
should_be_installed 'activesupport 2.3.5'
should_not_be_installed "rack-obama", "rack"
end
end
describe "when Gemfile conflicts with lockfile" do
before(:each) do
build_repo2
install_gemfile <<-G
source "file://#{gem_repo2}"
gem "rack_middleware"
G
should_be_installed "rack_middleware 1.0", "rack 0.9.1"
build_repo2
update_repo2 do
build_gem "rack-obama", "2.0" do |s|
s.add_dependency "rack", "=1.2"
end
build_gem "rack_middleware", "2.0" do |s|
s.add_dependency "rack", ">=1.0"
end
end
gemfile <<-G
source "file://#{gem_repo2}"
gem "rack-obama", "2.0"
gem "rack_middleware"
G
end
it "does not install gems whose dependencies are not met" do
bundle :install
ruby <<-RUBY
require 'bundler/setup'
RUBY
out.should =~ /could not find gem 'rack-obama/i
end
it "suggests bundle update when the Gemfile requires different versions than the lock" do
nice_error = <<-E.strip.gsub(/^ {8}/, '')
Fetching source index for file:#{gem_repo2}/
Bundler could not find compatible versions for gem "rack":
In snapshot (Gemfile.lock):
rack (0.9.1)
In Gemfile:
rack-obama (= 2.0) depends on
rack (= 1.2)
Running `bundle update` will rebuild your snapshot from scratch, using only
the gems in your Gemfile, which may resolve the conflict.
E
bundle :install
out.should == nice_error
end
end
describe "subtler cases" do
before :each do
install_gemfile <<-G
source "file://#{gem_repo1}"
gem "rack"
gem "rack-obama"
G
gemfile <<-G
source "file://#{gem_repo1}"
gem "rack", "0.9.1"
gem "rack-obama"
G
end
it "does something" do
lambda {
bundle "install"
}.should_not change { File.read(bundled_app('Gemfile.lock')) }
out.should include('rack = 0.9.1')
out.should include('locked at 1.0.0')
out.should include('bundle update rack')
end
it "should work when you update" do
bundle "update rack"
end
end
describe "when adding a new source" do
it "updates the lockfile" do
build_repo2
install_gemfile <<-G
source "file://#{gem_repo1}"
gem "rack"
G
install_gemfile <<-G
source "file://#{gem_repo1}"
source "file://#{gem_repo2}"
gem "rack"
G
lockfile_should_be <<-L
GEM
remote: file:#{gem_repo1}/
remote: file:#{gem_repo2}/
specs:
rack (1.0.0)
PLATFORMS
ruby
DEPENDENCIES
rack
L
end
end
end