Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow overriding cucumber_steps_glob definition for local requirements #41

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,24 @@ corresponding step definition and replaces the current buffer. `<C-W>d` or
the cursor there. `[d` or `]d` on a step opens the step definition in a new
split buffer while maintaining the current cursor position.

## Runtime Options

vim-cucumber looks through steps defined in your 'features' or 'stories' folder.
Usually this is OK, but if you work in a multi-project environment, where each
project has its own sub-folder, this can lead to many occurences of 'Multiple
matching steps...' and extra work to find the step that your project uses.

To avoid this situation, you can export the CUKEFILES environment variable as a
glob specification, which will then be used in place of the default. An example
would be:

export CUKEFILES='/Users/jesii/features/step\_definitions/mobweb/\*\*/\*.rb'

## Documentation

Standard vim documentation is available through:
:h vim-cucumber

## Installation

If you don't have a preferred installation method, I recommend installing
Expand Down
32 changes: 32 additions & 0 deletions doc/vim-cucumber.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
*vim-cucumber.txt* Simple docs for those of us suffering from CRS

Author: Jonathan Seidel <http://www.edpci.com>
License: Same terms as vim itself ( see |license|)

INTRODUCTION *vim-cucumber*

When working with cucumber, several useful commands are defined
that let you work with feature files and step definitions seamlessly.

MAPPINGS *vim-cucumber-mappings*

These mappings are available in your local buffers.

*vim-cucumber_[<CTRL-d>*
*vim-cucumber_]<CTRL-d>*
[<C-d> on a step jumps to the corresponding step definition and
]<C-d> replaces the current buffer.

*vim-cucumber_<CTRL-W>d*
*vim-cucumber_<CTRL-W><CTRL-d>*
<C-W>d on a step jumps to its definition in a new split buffer
<C-w><C-d> and moves the cursor there.

*vim-cucumber_[d*
*vim-cucumber_]d*
[d on a step jumps to its definition in a new split buffer
]d while maintaining the current cursor position.

*vim-cucumber_<CTRL-^>*
<C-^> Return from the step definition to the feature file
after having used the [<C-d> mapping.
16 changes: 13 additions & 3 deletions ftplugin/cucumber.vim
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
" Vim filetype plugin
" Language: Cucumber
" Maintainer: Tim Pope <vimNOSPAM@tpope.org>
" Last Change: 2013 Jun 01
" Last Change: 2016 May 28

" Only do this when not done yet for this buffer
if (exists("b:did_ftplugin"))
Expand All @@ -18,9 +18,19 @@ setlocal omnifunc=CucumberComplete

let b:undo_ftplugin = "setl fo< com< cms< ofu<"

" Allow setting the cucumber-root to a different value,
" via ENV variable CUKEFILES
" This is the default
let b:cucumber_root = expand('%:p:h:s?.*[\/]\%(features\|stories\)\zs[\/].*??')

if !exists("b:cucumber_steps_glob")
let b:cucumber_steps_glob = b:cucumber_root.'/**/*.rb'
if empty($CUKEFILES)
echom "Using default definition for b:cucumber_steps_glob"
let b:cucumber_steps_glob = b:cucumber_root.'/**/*.rb'
else
echom 'Using CUKEFILES environment variable for b:cucumber_steps_glob'
let b:cucumber_steps_glob = $CUKEFILES
endif
endif

if !exists("g:no_plugin_maps") && !exists("g:no_cucumber_maps")
Expand All @@ -45,7 +55,7 @@ function! s:jump(command,count)
if len(steps) == 0 || len(steps) < a:count
return 'echoerr "No matching step found"'
elseif len(steps) > 1 && !a:count
return 'echoerr "Multiple matching steps found"'
return 'echoerr "Multiple matching steps (" . len(steps) . ") found"'
else
let c = a:count ? a:count-1 : 0
return a:command.' +'.steps[c][1].' '.escape(steps[c][0],' %#')
Expand Down