Created
May 22, 2013 18:40
-
-
Save kcurtin/5629871 to your computer and use it in GitHub Desktop.
For anyone working with a test suite that uses the original (soon to be deprecated?) "should" syntax for rspec, this is a nice little macro that will convert shoulds to expects
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" Example: | |
" response.body.should have_content("something") | |
" expect(response.body).to have_content("something") | |
" ================================================= | |
" Macro that converts rspec "should"s to "expect"s | |
" ================================================= | |
function! ConvertToExpect() | |
:normal! dd | |
:normal! P | |
:.s/^\(\s\+\)\(.\+\)\.should\(.*\)$/\1expect(\2).to\3/ | |
:normal == | |
endfunction | |
:command! ConvertToExpect :call ConvertToExpect() | |
:map <leader>e :ConvertToExpect<cr> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
TODO: it would be nice to convert matchers too, for example: