The other day, I was moaning about cucumber and locations of step files, as it encourages (but doesn't depend upon) a file-naming convention. As such, step files can be hard to find. Anyway, as I'm kicking through a way to script a solution to that problem, I decided I wanted a way to run cukes from within vim.
I came up with two solutions:
- one to run the whole file that's in the currently open buffer
- one to run the scenario that starts on the line the cursor is on
I just added the following command definitions to my .vimrc:
command! Cuke call s:RunShellCommand('bundle exec cucumber ' .expand('%:p')) command! CukeL call s:RunShellCommand('bundle exec cucumber ' .expand('%:p').':'.winline())
I haven't mapped short commands with my <leader> yet as I'm not sure if I'll use this regularly, but it seemed helpful, so I thought I'd share. The drawback is that the execution time of cucumber is long, especially if it's a UI test, so it can take over your UI for a while, which is why I added CukeL, so I cold run just the current line. The cucumber overhead is still pretty high, so I may look into creating a modified RunShellCommand that forks the process, so you can continue working while you fire off the command.
No comments:
Post a Comment