public
Rubygem
Description: Makes tests easy on the fingers and the eyes
Homepage: http://www.thoughtbot.com/projects/shoulda
Clone URL: git://github.com/thoughtbot/shoulda.git
convert_to_should_syntax: fix clobbering of test names; leave existing 
should names untouched; add test case
showaltb (author)
Tue Jul 29 12:52:01 -0700 2008
rmm5t (committer)
Wed Jul 30 05:25:25 -0700 2008
commit  630ce1744374c51e4e8e588caf4cecfc056e73fa
tree    b65a6493b64df1cd0af37a593203407b0c45f469
parent  d84209b8afea9b86f3237453cbfc4287fcd14bb7
...
32
33
34
35
36
37
 
 
38
39
40
...
32
33
34
 
 
 
35
36
37
38
39
0
@@ -32,9 +32,8 @@ usage("File '#{file}' doesn't exist") unless File.exists?(file)
0
 
0
 FileUtils.cp(file, tmpfile)
0
 contents = File.read(tmpfile)
0
-contents.gsub!(/def test_should_(.*)\s*$/, 'should "\1" do')
0
-contents.gsub!(/def test_(.*)\s*$/, 'should "RENAME ME: test \1" do')
0
-contents.gsub!(/should ".*" do$/) {|line| line.tr!('_', ' ')}
0
+contents.gsub!(/def test_should_(\S+)/) {|line| "should \"#{$1.tr('_', ' ')}\" do"}
0
+contents.gsub!(/def test_(\S+)/) {|line| "should \"RENAME ME: test #{$1.tr('_', ' ')}\" do"}
0
 File.open(file, 'w') { |f| f.write(contents) }
0
 
0
 puts "File '#{file}' has been converted to 'should' syntax. Old version has been stored in '#{tmpfile}'"

Comments

    No one has commented yet.