end
then modify the file
and add lines 1, 5-7 and 15-16
1 spec, context, name, test_name = nil, nil, nil
2
3 File.open() do |f|
4 # test/unit
5 lines = f.read.split("\n")[0...n].reverse
6 name = lines.find {|line| line =~ /^\s*def test[_a-z0-9]*[\?!]?/i }.to_s.sub(/^\s*def (.*?)\s*$/) {$1 }
7 # ActiveSupport::Testing::Declarative#test
8 # to use the new test "" do;end syntax
9 test_name = $3 || $4 if lines.find {|line| line =~ /^\s*(test)\s+('(.*)'|"(.*)")+\s*(\{|do)/ }
10 # test/spec.
11 spec = $3 || $4 if lines.find {|line| line =~ /^\s*(specify|it)\s+('(.*)'|"(.*)")+\s*(\{|do)/ }
12 context = $3 || $4 if lines.find {|line| line =~ /^\s*(context|describe)\s+('(.*)'|"(.*)")+\s*(\{|do)/ }
13 end
14
15 if name and !name.empty?
16 args << "--name="
17 elsif test_name and !test_name.empty?
18 args << "--name=test_"
19 elsif spec and !spec.empty? and context and !context.empty?
20 args << %Q{--name="/test_spec \\{.*\\} \\d{3} \\[\\]/"}
21 else
22 puts "Error: This doesn't appear to be a TestCase or spec."
23 exit
24 end
25