Skip to content

Instantly share code, notes, and snippets.

@srushti
Created May 10, 2012 08:33
Show Gist options
  • Save srushti/2651900 to your computer and use it in GitHub Desktop.
Save srushti/2651900 to your computer and use it in GitHub Desktop.
Vim commands to convert a Test::Unit/Shoulda to RSpec
%s/def test_\(.*\)/it "\1" do
%s/ should / it /
%s/setup do/before(:each) do/
%s/def setup/before(:each) do/
%s/assert_true \(.*\)/\1.should be_true/
%s/assert \(.*\)/\1.should be_true/
%s/assert_false \(.*\)/\1.should be_false/
%s/assert_equal(\(.*\),\(.*\))/\2.should == \1/
%s/assert_equal \(.*\),\(.*\)/\2.should == \1/
%s/assert_nil \(.*\)/\1.should be_nil/
%s/assert_nothing_raised(\(.*\))\(.*\)/lambda \2.should_not raise_error(\1)
%s/assert_raise(\(.*\))\({.*}\)/lambda \2.should raise_error(\1)
%s/assert_raise(\(.*\)) \({.*}\)/lambda \2.should raise_error(\1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment