Skip to content

Instantly share code, notes, and snippets.

View scarver2's full-sized avatar

Stan Carver II scarver2

View GitHub Profile
@biinari
biinari / mocha_to_rspec_mocks.sed
Last active December 27, 2018 16:47
Converts mocha expectations to rspec-mocks.
s/\([^.a-zA-Z_-]\)stub\>/\1double/g
s/\([^.a-zA-Z_-]\)mock\>/\1double/g
s/\.returns\>/.and_return/g
s/\.yields\>/.and_yield/g
s/\(\S\+\)\.stubs(/allow(\1).to receive(/g
s/\(\S\+\)\.expects(/expect(\1).to receive(/g
s/at_least_once/at_least(:once)/g
s/at_most_once/at_most(:once)/g
s/\.raises\>/.and_raise/g
s/\(allow\|expect\)(\(\S\+\)\.any_instance).to receive/\1_any_instance_of(\2).to receive/g