Created
August 17, 2010 21:40
-
-
Save ymendel/532196 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#!/usr/bin/env ruby -pi.bak | |
# bacon before takes no argument | |
$_.sub!(/before\s*\(?\s*:each\s*\)?\s*/, 'before ') | |
# same with after | |
# No magic annoying spaces after 'should'. | |
# Matchers are methods on the Should object | |
$_.sub!(/\.should\s*/, '.should.') | |
# fix `should_not` -> `should._not` | |
# and catch `should_not something` | |
$_.sub!(/\._not\s*/, '.not.') | |
# fix `should ==` -> `should.==` and the like | |
$_.sub!(/\.([=<>])/, ' \1') | |
$_.sub!(/be_/, 'be.') | |
$_.sub!(/raise_error/, 'raise') | |
# mocha -> facon | |
$_.sub!(/\.stubs/, '.stub!') | |
$_.sub!(/\.expects/, '.should.receive') | |
$_.sub!(/\.returns/, '.and_return') | |
$_.sub!(/\.raises/, '.and_raise') | |
# turn .raises(SomeError, 'some message') into .and_raise(SomeError.new('some message')) | |
# yields -> and_yield | |
$_.sub!(/stub\(/, 'mock(') | |
# argument expectations | |
# .with do -> just print a warning and make the user do it? | |
# otherwise would probably require some sexp action instead of just regexes |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment