vim-flavor 0.0.0
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/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.asciidoc +142 -0
- data/Rakefile +2 -0
- data/bin/vim-flavor +3 -0
- data/lib/vim-flavor.rb +471 -0
- data/lib/vim-flavor/version.rb +5 -0
- data/spec/cli_spec.rb +15 -0
- data/spec/facade_spec.rb +563 -0
- data/spec/flavor_spec.rb +246 -0
- data/spec/flavorfile_spec.rb +121 -0
- data/spec/lockfile_spec.rb +94 -0
- data/spec/spec_helper.rb +40 -0
- data/spec/stringextension_spec.rb +11 -0
- data/spec/versionconstraint_spec.rb +137 -0
- data/vim-flavor.gemspec +20 -0
- metadata +102 -0
data/spec/cli_spec.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'bundler/setup'
|
2
|
+
require 'spec_helper'
|
3
|
+
require 'vim-flavor'
|
4
|
+
|
5
|
+
describe Vim::Flavor::CLI do
|
6
|
+
describe '#install' do
|
7
|
+
it 'should use the default vimfiles path', :pending => true do end
|
8
|
+
it 'should use a given vimfiles path', :pending => true do end
|
9
|
+
end
|
10
|
+
|
11
|
+
describe '#upgrade' do
|
12
|
+
it 'should use the default vimfiles path', :pending => true do end
|
13
|
+
it 'should use a given vimfiles path', :pending => true do end
|
14
|
+
end
|
15
|
+
end
|
data/spec/facade_spec.rb
ADDED
@@ -0,0 +1,563 @@
|
|
1
|
+
require 'bundler/setup'
|
2
|
+
require 'fileutils'
|
3
|
+
require 'spec_helper'
|
4
|
+
require 'vim-flavor'
|
5
|
+
|
6
|
+
describe Vim::Flavor::Facade do
|
7
|
+
describe '#initialize' do
|
8
|
+
it 'should have proper values by default' do
|
9
|
+
facade = described_class.new()
|
10
|
+
facade.flavorfile.should == nil
|
11
|
+
facade.flavorfile_path.should == "#{Dir.getwd()}/VimFlavor"
|
12
|
+
facade.lockfile.should == nil
|
13
|
+
facade.lockfile_path.should == "#{Dir.getwd()}/VimFlavor.lock"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe '#load' do
|
18
|
+
before :each do
|
19
|
+
@tmp_path = "#{Vim::Flavor::DOT_PATH}/tmp"
|
20
|
+
@facade = described_class.new()
|
21
|
+
@facade.flavorfile_path = "#{@tmp_path}/VimFlavor"
|
22
|
+
@facade.lockfile_path = "#{@tmp_path}/VimFlavor.lock"
|
23
|
+
|
24
|
+
@flavor1 = Vim::Flavor::Flavor.new()
|
25
|
+
@flavor1.groups = [:default]
|
26
|
+
@flavor1.repo_name = 'kana/vim-smartinput'
|
27
|
+
@flavor1.repo_uri = 'git://github.com/kana/vim-smartinput.git'
|
28
|
+
@flavor1.version_contraint =
|
29
|
+
Vim::Flavor::VersionConstraint.new('>= 0')
|
30
|
+
@flavor1d = @flavor1.dup()
|
31
|
+
@flavor1d.locked_version = Gem::Version.create('1.2.3')
|
32
|
+
@flavor2 = Vim::Flavor::Flavor.new()
|
33
|
+
@flavor2.groups = [:default]
|
34
|
+
@flavor2.repo_name = 'kana/vim-smarttill'
|
35
|
+
@flavor2.repo_uri = 'git://github.com/kana/vim-smarttill.git'
|
36
|
+
@flavor2.version_contraint =
|
37
|
+
Vim::Flavor::VersionConstraint.new('>= 0')
|
38
|
+
@flavor2d = @flavor2.dup()
|
39
|
+
@flavor2d.locked_version = Gem::Version.create('4.5.6')
|
40
|
+
|
41
|
+
FileUtils.mkdir_p(@tmp_path)
|
42
|
+
File.open(@facade.flavorfile_path, 'w') do |f|
|
43
|
+
f.write(<<-'END')
|
44
|
+
flavor 'kana/vim-smartinput'
|
45
|
+
flavor 'kana/vim-smarttill'
|
46
|
+
END
|
47
|
+
end
|
48
|
+
File.open(@facade.lockfile_path, 'w') do |f|
|
49
|
+
f.write(<<-'END')
|
50
|
+
:flavors:
|
51
|
+
git://github.com/kana/vim-smartinput.git:
|
52
|
+
:groups:
|
53
|
+
- :default
|
54
|
+
:locked_version: 1.2.3
|
55
|
+
:repo_name: kana/vim-smartinput
|
56
|
+
:version_contraint: >= 0
|
57
|
+
END
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
after :each do
|
62
|
+
FileUtils.rm_rf([Vim::Flavor::DOT_PATH], :secure => true)
|
63
|
+
end
|
64
|
+
|
65
|
+
it 'should load both files' do
|
66
|
+
@facade.load()
|
67
|
+
|
68
|
+
@facade.flavorfile_path.should == "#{@tmp_path}/VimFlavor"
|
69
|
+
@facade.lockfile_path.should == "#{@tmp_path}/VimFlavor.lock"
|
70
|
+
@facade.flavorfile.flavors.keys.length == 2
|
71
|
+
@facade.flavorfile.flavors[@flavor1.repo_uri].should == @flavor1
|
72
|
+
@facade.flavorfile.flavors[@flavor2.repo_uri].should == @flavor2
|
73
|
+
@facade.lockfile.flavors.should == {
|
74
|
+
@flavor1d.repo_uri => @flavor1d,
|
75
|
+
}
|
76
|
+
end
|
77
|
+
|
78
|
+
it 'should load a lockfile if it exists' do
|
79
|
+
@facade.load()
|
80
|
+
|
81
|
+
@facade.lockfile.flavors.should == {
|
82
|
+
@flavor1d.repo_uri => @flavor1d,
|
83
|
+
}
|
84
|
+
|
85
|
+
@facade.lockfile_path = "#{@tmp_path}/VimFlavor.lock.xxx"
|
86
|
+
@facade.load()
|
87
|
+
|
88
|
+
@facade.lockfile.flavors.should == {}
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
describe '#make_new_flavors' do
|
93
|
+
before :each do
|
94
|
+
@facade = described_class.new()
|
95
|
+
|
96
|
+
@f0 = Vim::Flavor::Flavor.new()
|
97
|
+
@f0.repo_name = 'kana/vim-textobj-entire'
|
98
|
+
@f0.repo_uri = 'git://github.com/kana/vim-textobj-entire.git'
|
99
|
+
@f0.version_contraint = Vim::Flavor::VersionConstraint.new('>= 0')
|
100
|
+
@f0.locked_version = Gem::Version.create('0')
|
101
|
+
|
102
|
+
@f1 = @f0.dup()
|
103
|
+
@f1.locked_version = Gem::Version.create('2')
|
104
|
+
|
105
|
+
@f1d = @f1.dup()
|
106
|
+
@f1d.version_contraint = Vim::Flavor::VersionConstraint.new('>= 1')
|
107
|
+
end
|
108
|
+
|
109
|
+
it 'should keep current locked_version for newly added flavors' do
|
110
|
+
@facade.make_new_flavors(
|
111
|
+
{
|
112
|
+
@f0.repo_uri => @f0,
|
113
|
+
},
|
114
|
+
{
|
115
|
+
},
|
116
|
+
:install
|
117
|
+
).should == {
|
118
|
+
@f0.repo_uri => @f0,
|
119
|
+
}
|
120
|
+
end
|
121
|
+
|
122
|
+
it 'should keep current locked_version for flavors with new constraint' do
|
123
|
+
@facade.make_new_flavors(
|
124
|
+
{
|
125
|
+
@f1d.repo_uri => @f1d,
|
126
|
+
},
|
127
|
+
{
|
128
|
+
@f0.repo_uri => @f0,
|
129
|
+
},
|
130
|
+
:install
|
131
|
+
).should == {
|
132
|
+
@f1d.repo_uri => @f1d,
|
133
|
+
}
|
134
|
+
end
|
135
|
+
|
136
|
+
it 'should keep current locked_version for :update mode' do
|
137
|
+
@facade.make_new_flavors(
|
138
|
+
{
|
139
|
+
@f1.repo_uri => @f1,
|
140
|
+
},
|
141
|
+
{
|
142
|
+
@f0.repo_uri => @f0,
|
143
|
+
},
|
144
|
+
:update
|
145
|
+
).should == {
|
146
|
+
@f1.repo_uri => @f1,
|
147
|
+
}
|
148
|
+
end
|
149
|
+
|
150
|
+
it 'should keep locked flavors otherwise' do
|
151
|
+
@facade.make_new_flavors(
|
152
|
+
{
|
153
|
+
@f1.repo_uri => @f1,
|
154
|
+
},
|
155
|
+
{
|
156
|
+
@f0.repo_uri => @f0,
|
157
|
+
},
|
158
|
+
:install
|
159
|
+
).should == {
|
160
|
+
@f0.repo_uri => @f0,
|
161
|
+
}
|
162
|
+
end
|
163
|
+
|
164
|
+
it 'should always use current groups even if locked version is updated' do
|
165
|
+
f0 = @f0.dup()
|
166
|
+
f0.groups = [:default]
|
167
|
+
f1 = @f1.dup()
|
168
|
+
f1.groups = [:default, :development]
|
169
|
+
f1d = f1.dup()
|
170
|
+
f1d.locked_version = f0.locked_version
|
171
|
+
|
172
|
+
@facade.make_new_flavors(
|
173
|
+
{
|
174
|
+
f1.repo_uri => f1,
|
175
|
+
},
|
176
|
+
{
|
177
|
+
f0.repo_uri => f0,
|
178
|
+
},
|
179
|
+
:install
|
180
|
+
).should == {
|
181
|
+
f1d.repo_uri => f1d,
|
182
|
+
}
|
183
|
+
end
|
184
|
+
end
|
185
|
+
|
186
|
+
describe '#create_vim_script_for_bootstrap' do
|
187
|
+
before :each do
|
188
|
+
@facade = described_class.new()
|
189
|
+
@home_path = "#{Vim::Flavor::DOT_PATH}"
|
190
|
+
@vimfiles_path = "#{@home_path}/.vim"
|
191
|
+
end
|
192
|
+
|
193
|
+
after :each do
|
194
|
+
FileUtils.rm_rf([Vim::Flavor::DOT_PATH], :secure => true)
|
195
|
+
end
|
196
|
+
|
197
|
+
it 'should create a bootstrap script into a given vimfiles path' do
|
198
|
+
bootstrap_path = "#{@vimfiles_path.to_flavors_path()}/bootstrap.vim"
|
199
|
+
|
200
|
+
File.exists?(bootstrap_path).should be_false
|
201
|
+
@facade.create_vim_script_for_bootstrap(@vimfiles_path)
|
202
|
+
File.exists?(bootstrap_path).should be_true
|
203
|
+
end
|
204
|
+
|
205
|
+
it 'should create a valid bootstrap script' do
|
206
|
+
@facade.create_vim_script_for_bootstrap(@vimfiles_path)
|
207
|
+
|
208
|
+
_rtp = %x{
|
209
|
+
HOME='#{@home_path}'
|
210
|
+
for plugin_name in 'foo' 'bar' 'baz'
|
211
|
+
do
|
212
|
+
mkdir -p "#{@vimfiles_path.to_flavors_path()}/$plugin_name"
|
213
|
+
done
|
214
|
+
vim -u NONE -i NONE -e -s -c '
|
215
|
+
set nocompatible verbose=1
|
216
|
+
source #{@vimfiles_path}/flavors/bootstrap.vim
|
217
|
+
verbose echo &runtimepath
|
218
|
+
qall!
|
219
|
+
' 2>&1
|
220
|
+
}
|
221
|
+
rtps =
|
222
|
+
_rtp.
|
223
|
+
gsub(/[\r\n]/, '').
|
224
|
+
split(/,/).
|
225
|
+
select {|p| p.start_with?(@home_path)}
|
226
|
+
rtps.should == [
|
227
|
+
"#{@home_path}/.vim",
|
228
|
+
"#{@home_path}/.vim/flavors/bar",
|
229
|
+
"#{@home_path}/.vim/flavors/baz",
|
230
|
+
"#{@home_path}/.vim/flavors/foo",
|
231
|
+
"#{@home_path}/.vim/flavors/foo/after",
|
232
|
+
"#{@home_path}/.vim/flavors/baz/after",
|
233
|
+
"#{@home_path}/.vim/flavors/bar/after",
|
234
|
+
"#{@home_path}/.vim/after",
|
235
|
+
]
|
236
|
+
end
|
237
|
+
end
|
238
|
+
|
239
|
+
describe '#deploy_flavors' do
|
240
|
+
before :each do
|
241
|
+
@facade = described_class.new()
|
242
|
+
|
243
|
+
@test_repo_path = "#{Vim::Flavor::DOT_PATH}/test/origin"
|
244
|
+
|
245
|
+
@flavor = Vim::Flavor::Flavor.new()
|
246
|
+
@flavor.repo_name = '@test_repo_path'
|
247
|
+
@flavor.repo_uri = @test_repo_path
|
248
|
+
@flavor.locked_version = '1.0.0'
|
249
|
+
|
250
|
+
@flavors = [@flavor]
|
251
|
+
|
252
|
+
@vimfiles_path = "#{Vim::Flavor::DOT_PATH}/vimfiles"
|
253
|
+
@bootstrap_path = "#{@vimfiles_path.to_flavors_path()}/bootstrap.vim"
|
254
|
+
end
|
255
|
+
|
256
|
+
after :each do
|
257
|
+
FileUtils.rm_rf([Vim::Flavor::DOT_PATH], :secure => true)
|
258
|
+
end
|
259
|
+
|
260
|
+
it 'should replace a given path with given flavors' do
|
261
|
+
create_a_test_repo(@test_repo_path)
|
262
|
+
@flavors.each do |f|
|
263
|
+
f.clone()
|
264
|
+
end
|
265
|
+
|
266
|
+
File.exists?(@vimfiles_path).should be_false
|
267
|
+
File.exists?(@bootstrap_path).should be_false
|
268
|
+
@flavors.each do |f|
|
269
|
+
File.exists?(f.make_deploy_path(@vimfiles_path)).should be_false
|
270
|
+
end
|
271
|
+
|
272
|
+
@facade.deploy_flavors(@flavors, @vimfiles_path)
|
273
|
+
|
274
|
+
File.exists?(@vimfiles_path).should be_true
|
275
|
+
File.exists?(@bootstrap_path).should be_true
|
276
|
+
@flavors.each do |f|
|
277
|
+
File.exists?(f.make_deploy_path(@vimfiles_path)).should be_true
|
278
|
+
end
|
279
|
+
|
280
|
+
system(<<-"END")
|
281
|
+
touch '#{@vimfiles_path}/foo'
|
282
|
+
touch '#{@vimfiles_path.to_flavors_path()}/foo'
|
283
|
+
END
|
284
|
+
|
285
|
+
File.exists?("#{@vimfiles_path}/foo").should be_true
|
286
|
+
File.exists?("#{@vimfiles_path.to_flavors_path()}/foo").should be_true
|
287
|
+
|
288
|
+
@facade.deploy_flavors(@flavors, @vimfiles_path)
|
289
|
+
|
290
|
+
File.exists?("#{@vimfiles_path}/foo").should be_true
|
291
|
+
File.exists?("#{@vimfiles_path.to_flavors_path()}/foo").should be_false
|
292
|
+
end
|
293
|
+
end
|
294
|
+
|
295
|
+
describe '#save_lockfile' do
|
296
|
+
before :each do
|
297
|
+
@tmp_path = "#{Vim::Flavor::DOT_PATH}/tmp"
|
298
|
+
@facade = described_class.new()
|
299
|
+
@facade.flavorfile_path = "#{@tmp_path}/VimFlavor"
|
300
|
+
@facade.lockfile_path = "#{@tmp_path}/VimFlavor.lock"
|
301
|
+
|
302
|
+
FileUtils.mkdir_p(@tmp_path)
|
303
|
+
File.open(@facade.flavorfile_path, 'w') do |f|
|
304
|
+
f.write(<<-'END')
|
305
|
+
END
|
306
|
+
end
|
307
|
+
end
|
308
|
+
|
309
|
+
after :each do
|
310
|
+
clean_up_stashed_stuffs()
|
311
|
+
end
|
312
|
+
|
313
|
+
it 'should save locked flavors' do
|
314
|
+
@facade.load()
|
315
|
+
|
316
|
+
@facade.lockfile.flavors.should == {}
|
317
|
+
|
318
|
+
flavor1 = Vim::Flavor::Flavor.new()
|
319
|
+
flavor1.groups = [:default]
|
320
|
+
flavor1.locked_version = Gem::Version.create('1.2.3')
|
321
|
+
flavor1.repo_name = 'kana/vim-smartinput'
|
322
|
+
flavor1.repo_uri = 'git://github.com/kana/vim-smartinput.git'
|
323
|
+
flavor1.version_contraint = Vim::Flavor::VersionConstraint.new('>= 0')
|
324
|
+
@facade.lockfile.instance_eval do
|
325
|
+
@flavors = {
|
326
|
+
flavor1.repo_uri => flavor1,
|
327
|
+
}
|
328
|
+
end
|
329
|
+
@facade.save_lockfile()
|
330
|
+
@facade.lockfile.instance_eval do
|
331
|
+
@flavors = nil
|
332
|
+
end
|
333
|
+
|
334
|
+
@facade.lockfile.flavors.should == nil
|
335
|
+
|
336
|
+
@facade.load()
|
337
|
+
|
338
|
+
@facade.lockfile.flavors.should == {
|
339
|
+
flavor1.repo_uri => flavor1,
|
340
|
+
}
|
341
|
+
end
|
342
|
+
end
|
343
|
+
|
344
|
+
describe '#complete_locked_flavors' do
|
345
|
+
before :each do
|
346
|
+
@test_repo_path = "#{Vim::Flavor::DOT_PATH}/test/origin"
|
347
|
+
@tmp_path = "#{Vim::Flavor::DOT_PATH}/tmp"
|
348
|
+
@facade = described_class.new()
|
349
|
+
@facade.flavorfile_path = "#{@tmp_path}/VimFlavor"
|
350
|
+
@facade.lockfile_path = "#{@tmp_path}/VimFlavor.lock"
|
351
|
+
|
352
|
+
create_a_test_repo(@test_repo_path)
|
353
|
+
FileUtils.mkdir_p(@tmp_path)
|
354
|
+
File.open(@facade.flavorfile_path, 'w') do |f|
|
355
|
+
f.write(<<-"END")
|
356
|
+
flavor 'file://#{@test_repo_path}', '~> 1.1.1'
|
357
|
+
END
|
358
|
+
end
|
359
|
+
end
|
360
|
+
|
361
|
+
after :each do
|
362
|
+
clean_up_stashed_stuffs()
|
363
|
+
end
|
364
|
+
|
365
|
+
it 'should complete flavors if they are not locked' do
|
366
|
+
@facade.load()
|
367
|
+
|
368
|
+
cf1 = @facade.flavorfile.flavors.values[0]
|
369
|
+
cf1.locked_version.should be_nil
|
370
|
+
File.exists?(cf1.cached_repo_path).should be_false
|
371
|
+
@facade.lockfile.flavors.should == {}
|
372
|
+
|
373
|
+
@facade.complete_locked_flavors(:upgrade_if_necessary)
|
374
|
+
|
375
|
+
lf1 = @facade.lockfile.flavors.values[0]
|
376
|
+
lf1.locked_version.should == Gem::Version.create('1.1.2')
|
377
|
+
File.exists?(lf1.cached_repo_path).should be_true
|
378
|
+
@facade.lockfile.flavors.should == {
|
379
|
+
lf1.repo_uri => lf1,
|
380
|
+
}
|
381
|
+
|
382
|
+
@facade.complete_locked_flavors(:upgrade_if_necessary)
|
383
|
+
|
384
|
+
lf1d = @facade.lockfile.flavors.values[0]
|
385
|
+
lf1d.locked_version.should == Gem::Version.create('1.1.2')
|
386
|
+
File.exists?(lf1d.cached_repo_path).should be_true
|
387
|
+
@facade.lockfile.flavors.should == {
|
388
|
+
lf1d.repo_uri => lf1d,
|
389
|
+
}
|
390
|
+
end
|
391
|
+
|
392
|
+
it 'should complete flavors if their constraint are changed' do
|
393
|
+
@facade.load()
|
394
|
+
|
395
|
+
cf1 = @facade.flavorfile.flavors.values[0]
|
396
|
+
cf1.locked_version.should be_nil
|
397
|
+
File.exists?(cf1.cached_repo_path).should be_false
|
398
|
+
@facade.lockfile.flavors.should == {}
|
399
|
+
|
400
|
+
@facade.complete_locked_flavors(:upgrade_if_necessary)
|
401
|
+
|
402
|
+
lf1 = @facade.lockfile.flavors.values[0]
|
403
|
+
lf1.locked_version.should == Gem::Version.create('1.1.2')
|
404
|
+
File.exists?(lf1.cached_repo_path).should be_true
|
405
|
+
@facade.lockfile.flavors.should == {
|
406
|
+
lf1.repo_uri => lf1,
|
407
|
+
}
|
408
|
+
|
409
|
+
cf1.version_contraint = Vim::Flavor::VersionConstraint.new('~> 1.1.2')
|
410
|
+
update_a_test_repo(@test_repo_path)
|
411
|
+
@facade.complete_locked_flavors(:upgrade_if_necessary)
|
412
|
+
|
413
|
+
lf1d = @facade.lockfile.flavors.values[0]
|
414
|
+
lf1d.locked_version.should == Gem::Version.create('1.1.9')
|
415
|
+
File.exists?(lf1d.cached_repo_path).should be_true
|
416
|
+
@facade.lockfile.flavors.should == {
|
417
|
+
lf1d.repo_uri => lf1d,
|
418
|
+
}
|
419
|
+
end
|
420
|
+
|
421
|
+
it 'should upgrade flavors even if their constraint are not changed' do
|
422
|
+
@facade.load()
|
423
|
+
|
424
|
+
cf1 = @facade.flavorfile.flavors.values[0]
|
425
|
+
cf1.locked_version.should be_nil
|
426
|
+
File.exists?(cf1.cached_repo_path).should be_false
|
427
|
+
@facade.lockfile.flavors.should == {}
|
428
|
+
|
429
|
+
@facade.complete_locked_flavors(:upgrade_all)
|
430
|
+
|
431
|
+
lf1 = @facade.lockfile.flavors.values[0]
|
432
|
+
lf1.locked_version.should == Gem::Version.create('1.1.2')
|
433
|
+
File.exists?(lf1.cached_repo_path).should be_true
|
434
|
+
@facade.lockfile.flavors.should == {
|
435
|
+
lf1.repo_uri => lf1,
|
436
|
+
}
|
437
|
+
|
438
|
+
update_a_test_repo(@test_repo_path)
|
439
|
+
@facade.complete_locked_flavors(:upgrade_all)
|
440
|
+
|
441
|
+
lf1d = @facade.lockfile.flavors.values[0]
|
442
|
+
lf1d.locked_version.should == Gem::Version.create('1.1.9')
|
443
|
+
File.exists?(lf1d.cached_repo_path).should be_true
|
444
|
+
@facade.lockfile.flavors.should == {
|
445
|
+
lf1d.repo_uri => lf1d,
|
446
|
+
}
|
447
|
+
end
|
448
|
+
end
|
449
|
+
|
450
|
+
describe '#get_default_vimfiles_path' do
|
451
|
+
it 'should return an appropriate value for *nix' do
|
452
|
+
# FIXME: Add proper tests depending on the current environment.
|
453
|
+
@facade = described_class.new()
|
454
|
+
@facade.get_default_vimfiles_path().should == "#{ENV['HOME']}/.vim"
|
455
|
+
end
|
456
|
+
end
|
457
|
+
|
458
|
+
describe '#install' do
|
459
|
+
before :each do
|
460
|
+
@test_repo_path = "#{Vim::Flavor::DOT_PATH}/test/origin"
|
461
|
+
@tmp_path = "#{Vim::Flavor::DOT_PATH}/tmp"
|
462
|
+
@vimfiles_path = "#{Vim::Flavor::DOT_PATH}/vimfiles"
|
463
|
+
@facade = described_class.new()
|
464
|
+
@facade.flavorfile_path = "#{@tmp_path}/VimFlavor"
|
465
|
+
@facade.lockfile_path = "#{@tmp_path}/VimFlavor.lock"
|
466
|
+
|
467
|
+
create_a_test_repo(@test_repo_path)
|
468
|
+
FileUtils.mkdir_p(@tmp_path)
|
469
|
+
File.open(@facade.flavorfile_path, 'w') do |f|
|
470
|
+
f.write(<<-"END")
|
471
|
+
flavor 'file://#{@test_repo_path}', '~> 1.1.1'
|
472
|
+
END
|
473
|
+
end
|
474
|
+
end
|
475
|
+
|
476
|
+
after :each do
|
477
|
+
clean_up_stashed_stuffs()
|
478
|
+
end
|
479
|
+
|
480
|
+
it 'should install Vim plugins according to VimFlavor' do
|
481
|
+
File.exists?(@facade.lockfile_path).should be_false
|
482
|
+
File.exists?(@vimfiles_path).should be_false
|
483
|
+
@facade.lockfile.should be_nil
|
484
|
+
|
485
|
+
@facade.install(@vimfiles_path)
|
486
|
+
|
487
|
+
File.exists?(@facade.lockfile_path).should be_true
|
488
|
+
File.exists?(@vimfiles_path).should be_true
|
489
|
+
@facade.lockfile.flavors.values.each do |f|
|
490
|
+
File.exists?(f.make_deploy_path(@vimfiles_path)).should be_true
|
491
|
+
end
|
492
|
+
end
|
493
|
+
|
494
|
+
it 'should respect existing VimFlavor.lock if possible' do
|
495
|
+
def self.install()
|
496
|
+
@facade.install(@vimfiles_path)
|
497
|
+
[
|
498
|
+
@facade.lockfile.flavors.map {|_, f| f.locked_version},
|
499
|
+
@facade.flavorfile.flavors.count(),
|
500
|
+
]
|
501
|
+
end
|
502
|
+
|
503
|
+
result1 = self.install()
|
504
|
+
update_a_test_repo(@test_repo_path)
|
505
|
+
result2 = self.install()
|
506
|
+
|
507
|
+
result2.should == result1
|
508
|
+
end
|
509
|
+
end
|
510
|
+
|
511
|
+
describe '#upgrade' do
|
512
|
+
before :each do
|
513
|
+
@test_repo_path = "#{Vim::Flavor::DOT_PATH}/test/origin"
|
514
|
+
@tmp_path = "#{Vim::Flavor::DOT_PATH}/tmp"
|
515
|
+
@vimfiles_path = "#{Vim::Flavor::DOT_PATH}/vimfiles"
|
516
|
+
@facade = described_class.new()
|
517
|
+
@facade.flavorfile_path = "#{@tmp_path}/VimFlavor"
|
518
|
+
@facade.lockfile_path = "#{@tmp_path}/VimFlavor.lock"
|
519
|
+
|
520
|
+
create_a_test_repo(@test_repo_path)
|
521
|
+
FileUtils.mkdir_p(@tmp_path)
|
522
|
+
File.open(@facade.flavorfile_path, 'w') do |f|
|
523
|
+
f.write(<<-"END")
|
524
|
+
flavor 'file://#{@test_repo_path}', '~> 1.1.1'
|
525
|
+
END
|
526
|
+
end
|
527
|
+
end
|
528
|
+
|
529
|
+
after :each do
|
530
|
+
clean_up_stashed_stuffs()
|
531
|
+
end
|
532
|
+
|
533
|
+
it 'should upgrade Vim plugins according to VimFlavor' do
|
534
|
+
File.exists?(@facade.lockfile_path).should be_false
|
535
|
+
File.exists?(@vimfiles_path).should be_false
|
536
|
+
@facade.lockfile.should be_nil
|
537
|
+
|
538
|
+
@facade.upgrade(@vimfiles_path)
|
539
|
+
|
540
|
+
File.exists?(@facade.lockfile_path).should be_true
|
541
|
+
File.exists?(@vimfiles_path).should be_true
|
542
|
+
@facade.lockfile.flavors.values.each do |f|
|
543
|
+
File.exists?(f.make_deploy_path(@vimfiles_path)).should be_true
|
544
|
+
end
|
545
|
+
end
|
546
|
+
|
547
|
+
it 'should always upgrade existing VimFlavor.lock' do
|
548
|
+
def self.upgrade()
|
549
|
+
@facade.upgrade(@vimfiles_path)
|
550
|
+
[
|
551
|
+
@facade.lockfile.flavors.map {|_, f| f.locked_version},
|
552
|
+
@facade.flavorfile.flavors.count(),
|
553
|
+
]
|
554
|
+
end
|
555
|
+
|
556
|
+
result1 = self.upgrade()
|
557
|
+
update_a_test_repo(@test_repo_path)
|
558
|
+
result2 = self.upgrade()
|
559
|
+
|
560
|
+
result2.should_not == result1
|
561
|
+
end
|
562
|
+
end
|
563
|
+
end
|