lib/respec/app.rb in respec-0.8.1 vs lib/respec/app.rb in respec-0.8.2
- old
+ new
@@ -76,10 +76,11 @@
def process_args
args = []
files = []
pass_next_arg = false
+ using_filters = false
@args.each do |arg|
if pass_next_arg
args << arg
pass_next_arg = false
elsif rspec_option_that_requires_an_argument?(arg)
@@ -106,15 +107,17 @@
else
warn "no fail file - ignoring 'f' argument"
[]
end
end
+ using_filters = true
elsif arg =~ /\A\d+\z/
i = Integer(arg)
if (failure = failures[i - 1])
args << '-e' << failure
@update_failures = false
+ using_filters = true
else
warn "invalid failure: #{i} for (1..#{failures.size})"
end
else
args << '-e' << arg.gsub(/[$]/, '\\\\\\0')
@@ -126,9 +129,15 @@
if arg.respond_to?(:call)
expanded.concat(arg.call)
else
expanded << arg
end
+ end
+
+ # If rerunning failures, chop off explicit line numbers, as they are
+ # additive, and filters are subtractive.
+ if using_filters
+ files.map! { |f| f.sub(/:\d+\z/, '') }
end
# Since we append our formatter as a file to run, rspec won't fall back to
# using 'spec' by default. Add it explicitly here.
files << 'spec' if files.empty?