Last active
December 27, 2018 16:47
-
-
Save biinari/7483179 to your computer and use it in GitHub Desktop.
Converts mocha expectations to rspec-mocks.
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
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 |
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
find spec -type f -exec sed -i'' -f mocha_to_rspec_mocks.sed \{\} \+ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment