Skip to content

Instantly share code, notes, and snippets.

@JackDanger
Created January 31, 2009 01:43
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save JackDanger/55400 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
# ActiveSupport has a more modern syntax now. Pipe any old-style
# ActiveSupport::TestCase suites into this file and have the syntax
# updated. For when you can't use Shoulda or RSpec but you still
# want to look sexy.
#
# Before:
#
# def test_guy_can_do_stuff
# assert guy.can_do?(:stuff)
# end
#
# After:
#
# test "guy can do stuff" do
# assert guy.can_do?(:stuff)
# end
#
# Usage:
#
# curl http://gist.github.com/55400.txt > test/update_tests.rb
# for file in `find test -name *.rb`; do
# cat $file | ruby test/update_tests.rb > $file.tmp
# mv $file.tmp $file;
# done
#
STDIN.read.each do |line|
matches = line.scan(/^(\s*)def test_([\w\d_]+)\s$/).flatten
unless [] == matches
line.sub!(
/^.*$/,
"#{matches.first}test \"#{matches.last.gsub(/_/, ' ')}\" do"
)
end
STDOUT.puts line
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment