Skip to content

Instantly share code, notes, and snippets.

@drewdeponte
Created February 6, 2014 20:54
Show Gist options
  • Save drewdeponte/8852301 to your computer and use it in GitHub Desktop.
Save drewdeponte/8852301 to your computer and use it in GitHub Desktop.
Vim script to get you most of the way to the upgraded state of the rspec2 syntax.
%s/\([a-zA-Z0-9:_@\.]\+\)\.stub\>/allow(\1).to receive/gc
%s/\([a-zA-Z0-9:_@\.]\+\)\.should_receive\>/expect(\1).to receive/gc
%s/\([a-zA-Z0-9:_@\.]\+\)\.should_not_receive\>/expect(\1).not_to receive/gc
%s/\([a-zA-Z0-9:_@\.\?\[\]"'()\/~]\+\)\.should\s*==\s*\(.*\)$/expect(\1).to eq(\2)/gc
%s/\([a-zA-Z0-9:_@\.\?\[\]"'()\/~]\+\)\.should_not\s*==\s*\(.*\)$/expect(\1).not_to eq(\2)/gc
%s/\([a-zA-Z0-9:_@\.\?\[\]"'()\/~]\+\)\.should\s\+\(.*\)$/expect(\1).to \2/gc
%s/\([a-zA-Z0-9:_@\.\?\[\]"'()\/~]\+\)\.should_not\s\+\(.*\)$/expect(\1).not_to \2/gc
%s/stub\>/double/g
%s/mock\>/double/g
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment