Skip to content

Instantly share code, notes, and snippets.

@jnunemaker
Created April 17, 2009 21:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jnunemaker/97260 to your computer and use it in GitHub Desktop.
Save jnunemaker/97260 to your computer and use it in GitHub Desktop.
require 'rubygems'
data = open(ARGV[0]).read
data.gsub!(/^require.*/, '')
data.gsub!(/describe\s/, 'context ')
data.gsub!(/it\s(\"|\')should\s?/, 'should \1')
data.gsub!('before(:each)', 'setup')
data.gsub!('before', 'setup')
data.gsub!('be_nil', 'be(nil)')
data.gsub!('be_true', 'be(true)')
data.gsub!('be_false', 'be(false)')
data.gsub!(/(\w+)\.should\shave_error_on\(\:(\w+)\)/, '\1.errors.on(:\2).should_not be(nil)')
data.gsub!(/(\w+)\.should_not\shave_error_on\(\:(\w+)\)/, '\1.errors.on(:\2).should be(nil)')
data.gsub!(/it \{ \w+\.new\.(should|should_not)\s([\w\:\(\)\_]+)\s\}/, '\1_\2')
data.gsub!(/it \{ \w+\.new\.should ensure_length_of\(\:(\w+)\)\.is_at_least\((\d+)\)\.is_at_most\((\d+)\) \}/, 'should_ensure_length_in_range :\1, \2..\3')
puts data
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment