Created
January 31, 2009 01:43
-
-
Save JackDanger/55400 to your computer and use it in GitHub Desktop.
This file contains 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 | |
# 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