Skip to content

Commit

Permalink
make run focussed unit test work for shoulda tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tobsch authored and infininight committed Mar 12, 2013
1 parent 6b42594 commit 35b5170
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions Support/RubyMate/run_script.rb
Expand Up @@ -9,7 +9,7 @@
if ARGV.first == "--name="
n = ENV['TM_LINE_NUMBER'].to_i

spec, context, name, test_name = nil, nil, nil
should, spec, context, name, test_name = nil, nil, nil

File.open(ENV['TM_FILEPATH']) do |f|
# test/unit
Expand All @@ -20,14 +20,20 @@
# test/spec.
spec = $3 || $4 if lines.find { |line| line =~ /^\s*(specify|it)\s+('(.*)'|"(.*)")+\s*(\{|do)/ }
context = $3 || $4 if lines.find { |line| line =~ /^\s*(context|describe)\s+('(.*)'|"(.*)")+\s*(\{|do)/ }
# shoulda.
should = $3 || $4 if lines.find { |line| line =~ /^\s*(should)\s+('(.*)'|"(.*)")+\s*(\{|do)/ }
context = $3 || $4 if lines.find { |line| line =~ /^\s*(context)\s+('(.*)'|"(.*)")+\s*(\{|do)/ }
end

if name and !name.empty?
args << "--name=#{name}"
elsif test_name and !test_name.empty?
args << "--name=test_#{test_name.gsub(/\s+/,'_')}"
elsif spec and !spec.empty? and context and !context.empty?
args << %Q{--name="/test_spec \\{.*#{context}\\} \\d{3} \\[#{spec}\\]/"}
elsif should and !should.empty? and context and !context.empty?
test_name = "#{context} should #{should}".gsub(/[\$\?\+\.\s\'\"\(\)]/,'.?')
args << "--name=/#{test_name}/"
else
puts "Error: This doesn't appear to be a TestCase or spec."
exit
Expand Down

0 comments on commit 35b5170

Please sign in to comment.