Skip to content

Instantly share code, notes, and snippets.

@kcurtin
Created May 22, 2013 18:40
Show Gist options
  • Save kcurtin/5629871 to your computer and use it in GitHub Desktop.
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
" 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>
@kcurtin
Copy link
Author

kcurtin commented May 22, 2013

TODO: it would be nice to convert matchers too, for example:

something.should == 4
expect(something).to eql 4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment