Add tests with 'vim-flavor'

This commit is contained in:
raimon
2015-11-29 00:05:47 +09:00
parent c260a9f18b
commit 0fa1ba8b7b
9 changed files with 95 additions and 2 deletions

5
.gitignore vendored Normal file
View File

@@ -0,0 +1,5 @@
## Environment normalisation:
/.bundle/
/vendor/bundle
/lib/bundler/man/
.vim-flavor

5
.travis.yml Normal file
View File

@@ -0,0 +1,5 @@
language: ruby
rvm:
- 2.2.3
script:
rake ci

3
Gemfile Normal file
View File

@@ -0,0 +1,3 @@
source 'https://rubygems.org'
gem 'vim-flavor', '~> 1.1'

19
Gemfile.lock Normal file
View 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
View 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
View 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
View File

@@ -0,0 +1 @@
kana/vim-vspec (1.6.1)

View File

@@ -12,11 +12,11 @@ endif
function! requirements#matched_filename(filename) 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 return 1
endif endif
if a:filename =~# '\v.require(ment)?s/.*\.(txt|in)' if a:filename =~# '\vrequire(ment)?s/.*\.(txt|in)$'
return 1 return 1
endif endif
@@ -24,6 +24,8 @@ function! requirements#matched_filename(filename)
\ && a:filename =~# g:requirements#detect_filename_pattern \ && a:filename =~# g:requirements#detect_filename_pattern
return 1 return 1
endif endif
return 0
endfunction endfunction
let &cpo = s:save_cpo let &cpo = s:save_cpo

43
t/test_ftdetect.vim Normal file
View 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: