Last Updated: February 25, 2016
·
326
· juliano

vim regexp for replacing mocha 'stubs().returns' style with rspec 'allow().to receive()'

Replace Pattern:

%s/\(\S\+\).stubs(\(:\S\+\)).returns(\(\S\+\))/allow(\1).to receive(\2).and_return(\3)/gc

Before:

controller.stubs(:current_account).returns(@account)

After:

allow(controller).to receive(:current_account).and_return(@account)