This repository has been archived by the owner on Apr 14, 2021. It is now read-only.
/
update_spec.rb
244 lines (202 loc) · 6.14 KB
/
update_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
require "spec_helper"
describe "bundle update" do
before :each do
build_repo2
install_gemfile <<-G
source "file://#{gem_repo2}"
gem "activesupport"
gem "rack-obama"
G
end
describe "with no arguments" do
it "updates the entire bundle" do
update_repo2 do
build_gem "activesupport", "3.0"
end
bundle "update"
should_be_installed "rack 1.2", "rack-obama 1.0", "activesupport 3.0"
end
it "doesn't delete the Gemfile.lock file if something goes wrong" do
gemfile <<-G
source "file://#{gem_repo2}"
gem "activesupport"
gem "rack-obama"
exit!
G
bundle "update"
expect(bundled_app("Gemfile.lock")).to exist
end
end
describe "--quiet argument" do
it "shows UI messages without --quiet argument" do
bundle "update"
expect(out).to include("Fetching source")
end
it "does not show UI messages with --quiet argument" do
bundle "update --quiet"
expect(out).not_to include("Fetching source")
end
end
describe "with a top level dependency" do
it "unlocks all child dependencies that are unrelated to other locked dependencies" do
update_repo2 do
build_gem "activesupport", "3.0"
end
bundle "update rack-obama"
should_be_installed "rack 1.2", "rack-obama 1.0", "activesupport 2.3.5"
end
end
describe "with an unknown dependency" do
it "should inform the user" do
bundle "update halting-problem-solver", :expect_err => true
expect(out).to include "Could not find gem 'halting-problem-solver'"
end
it "should suggest alternatives" do
bundle "update active-support", :expect_err => true
expect(out).to include "Did you mean activesupport?"
end
end
describe "with a child dependency" do
it "should update the child dependency" do
update_repo2
bundle "update rack"
should_be_installed "rack 1.2"
end
end
describe "with --local option" do
it "doesn't hit repo2" do
FileUtils.rm_rf(gem_repo2)
bundle "update --local"
expect(out).not_to match(/Fetching source index/)
end
end
describe "with --group option" do
it "should update only specifed group gems" do
install_gemfile <<-G
source "file://#{gem_repo2}"
gem "activesupport", :group => :development
gem "rack"
G
update_repo2 do
build_gem "activesupport", "3.0"
end
bundle "update --group development"
should_be_installed "activesupport 3.0"
should_not_be_installed "rack 1.2"
end
context "when there is a source with the same name as a gem in a group" do
before :each do
build_git "foo", :path => lib_path("activesupport")
install_gemfile <<-G
source "file://#{gem_repo2}"
gem "activesupport", :group => :development
gem "foo", :git => "#{lib_path("activesupport")}"
G
end
it "should not update the gems from that source" do
update_repo2 { build_gem "activesupport", "3.0" }
update_git "foo", "2.0", :path => lib_path("activesupport")
bundle "update --group development"
should_be_installed "activesupport 3.0"
should_not_be_installed "foo 2.0"
end
end
end
describe "in a frozen bundle" do
it "should fail loudly" do
bundle "install --deployment"
bundle "update"
expect(out).to match(/You are trying to install in deployment mode after changing.your Gemfile/m)
expect(exitstatus).not_to eq(0) if exitstatus
end
end
describe "with --source option" do
it "should not update gems not included in the source that happen to have the same name" do
install_gemfile <<-G
source "file://#{gem_repo2}"
gem "activesupport"
G
update_repo2 { build_gem "activesupport", "3.0" }
bundle "update --source activesupport"
should_not_be_installed "activesupport 3.0"
end
end
end
describe "bundle update in more complicated situations" do
before :each do
build_repo2
end
it "will eagerly unlock dependencies of a specified gem" do
install_gemfile <<-G
source "file://#{gem_repo2}"
gem "thin"
gem "rack-obama"
G
update_repo2 do
build_gem "thin", "2.0" do |s|
s.add_dependency "rack"
end
end
bundle "update thin"
should_be_installed "thin 2.0", "rack 1.2", "rack-obama 1.0"
end
end
describe "bundle update without a Gemfile.lock" do
it "should not explode" do
build_repo2
gemfile <<-G
source "file://#{gem_repo2}"
gem "rack", "1.0"
G
bundle "update"
should_be_installed "rack 1.0.0"
end
end
describe "bundle update when a gem depends on a newer version of bundler" do
before(:each) do
build_repo2 do
build_gem "rails", "3.0.1" do |s|
s.add_dependency "bundler", Bundler::VERSION.succ
end
end
gemfile <<-G
source "file://#{gem_repo2}"
gem "rails", "3.0.1"
G
end
it "should not explode" do
bundle "update"
expect(err).to be_empty
end
it "should explain that bundler conflicted" do
bundle "update"
expect(out).not_to match(/in snapshot/i)
expect(out).to match(/current Bundler version/i)
expect(out).to match(/perhaps you need to update bundler/i)
end
end
describe "bundle update" do
it "shows the previous version of the gem when updated from rubygems source" do
build_repo2
install_gemfile <<-G
source "file://#{gem_repo2}"
gem "activesupport"
G
bundle "update"
expect(out).to include("Using activesupport 2.3.5")
update_repo2 do
build_gem "activesupport", "3.0"
end
bundle "update"
expect(out).to include("Installing activesupport 3.0 (was 2.3.5)")
end
it "shows error message when Gemfile.lock is not preset and gem is specified" do
install_gemfile <<-G
source "file://#{gem_repo2}"
gem "activesupport"
G
bundle "update nonexisting"
expect(out).to include("This Bundle hasn't been installed yet. Run `bundle install` to update and install the bundled gems.")
expect(exitstatus).to eq(22) if exitstatus
end
end