mirror of
https://github.com/raimon49/requirements.txt.vim.git
synced 2025-12-06 10:04:23 +08:00
Add tests with 'vim-flavor'
This commit is contained in:
5
.gitignore
vendored
Normal file
5
.gitignore
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
## Environment normalisation:
|
||||
/.bundle/
|
||||
/vendor/bundle
|
||||
/lib/bundler/man/
|
||||
.vim-flavor
|
||||
5
.travis.yml
Normal file
5
.travis.yml
Normal file
@@ -0,0 +1,5 @@
|
||||
language: ruby
|
||||
rvm:
|
||||
- 2.2.3
|
||||
script:
|
||||
rake ci
|
||||
3
Gemfile
Normal file
3
Gemfile
Normal file
@@ -0,0 +1,3 @@
|
||||
source 'https://rubygems.org'
|
||||
|
||||
gem 'vim-flavor', '~> 1.1'
|
||||
19
Gemfile.lock
Normal file
19
Gemfile.lock
Normal file
@@ -0,0 +1,19 @@
|
||||
GEM
|
||||
remote: https://rubygems.org/
|
||||
specs:
|
||||
blankslate (3.1.3)
|
||||
parslet (1.7.1)
|
||||
blankslate (>= 2.0, <= 4.0)
|
||||
thor (0.19.1)
|
||||
vim-flavor (1.1.5)
|
||||
parslet (~> 1.0)
|
||||
thor (~> 0.14)
|
||||
|
||||
PLATFORMS
|
||||
ruby
|
||||
|
||||
DEPENDENCIES
|
||||
vim-flavor (~> 1.1)
|
||||
|
||||
BUNDLED WITH
|
||||
1.10.6
|
||||
11
Rakefile
Normal file
11
Rakefile
Normal file
@@ -0,0 +1,11 @@
|
||||
#!/usr/bin/env rake
|
||||
|
||||
task :ci => [:dump, :test]
|
||||
|
||||
task :dump do
|
||||
sh 'vim --version'
|
||||
end
|
||||
|
||||
task :test do
|
||||
sh 'bundle exec vim-flavor test'
|
||||
end
|
||||
4
VimFlavor
Normal file
4
VimFlavor
Normal file
@@ -0,0 +1,4 @@
|
||||
# Since flavorfile is parsed as a Ruby script,
|
||||
# you can comment out arbitrary lines like this.
|
||||
|
||||
# flavor '$foo_uri', '~> 1.0'
|
||||
1
VimFlavor.lock
Normal file
1
VimFlavor.lock
Normal file
@@ -0,0 +1 @@
|
||||
kana/vim-vspec (1.6.1)
|
||||
@@ -12,11 +12,11 @@ endif
|
||||
|
||||
|
||||
function! requirements#matched_filename(filename)
|
||||
if a:filename =~# '\v.*require(ment)?s\.(txt|in)'
|
||||
if a:filename =~# '\v.*require(ment)?s\.(txt|in)$'
|
||||
return 1
|
||||
endif
|
||||
|
||||
if a:filename =~# '\v.require(ment)?s/.*\.(txt|in)'
|
||||
if a:filename =~# '\vrequire(ment)?s/.*\.(txt|in)$'
|
||||
return 1
|
||||
endif
|
||||
|
||||
@@ -24,6 +24,8 @@ function! requirements#matched_filename(filename)
|
||||
\ && a:filename =~# g:requirements#detect_filename_pattern
|
||||
return 1
|
||||
endif
|
||||
|
||||
return 0
|
||||
endfunction
|
||||
|
||||
let &cpo = s:save_cpo
|
||||
|
||||
43
t/test_ftdetect.vim
Normal file
43
t/test_ftdetect.vim
Normal file
@@ -0,0 +1,43 @@
|
||||
filetype plugin on
|
||||
runtime! plugin/requirements.vim
|
||||
|
||||
describe 'enable: requirements#matched_filename()'
|
||||
it 'to enable file type detection: basic filename'
|
||||
Expect requirements#matched_filename('requirements.txt') to_be_true
|
||||
Expect requirements#matched_filename('requires.txt') to_be_true
|
||||
end
|
||||
|
||||
it 'to enable file type detection: pip-tools filename'
|
||||
Expect requirements#matched_filename('requirements.in') to_be_true
|
||||
Expect requirements#matched_filename('requires.in') to_be_true
|
||||
end
|
||||
|
||||
it 'to enable file type detection: directory structure'
|
||||
Expect requirements#matched_filename('requirements/dev.txt') to_be_true
|
||||
Expect requirements#matched_filename('requires/tests.in') to_be_true
|
||||
end
|
||||
end
|
||||
|
||||
describe 'disable: requirements#matched_filename()'
|
||||
it 'to enable file type detection: basic filename'
|
||||
Expect requirements#matched_filename('requirements.text') to_be_false
|
||||
end
|
||||
|
||||
it 'to enable file type detection: pip-tools filename'
|
||||
Expect requirements#matched_filename('requirements.ini') to_be_false
|
||||
end
|
||||
|
||||
it 'to enable file type detection: directory structure'
|
||||
Expect requirements#matched_filename('require/dev.txt') to_be_false
|
||||
end
|
||||
end
|
||||
|
||||
describe 'g:requirements#detect_filename_pattern'
|
||||
it 'use g:requirements#detect_filename_pattern'
|
||||
Expect requirements#matched_filename('freeze.txt') to_be_false
|
||||
let g:requirements#detect_filename_pattern = 'freeze'
|
||||
Expect requirements#matched_filename('freeze.txt') to_be_true
|
||||
end
|
||||
end
|
||||
|
||||
" vim: et sw=4 ts=4 sts=4:
|
||||
Reference in New Issue
Block a user