Skip to content

Commit

Permalink
normalize and escape regex to properly filter. fixes #78
Browse files Browse the repository at this point in the history
  • Loading branch information
daniely committed Mar 14, 2014
1 parent c6bed42 commit ab1065b
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions lib/turn/runners/minirunner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ def _run_suite suite, type
# suites are cases in minitest
@turn_case = @turn_suite.new_case(suite.name)

filter = @options[:filter] || @turn_config.pattern || /./
filter = normalize_filter(@options[:filter]) || @turn_config.pattern || /./

suite.send("#{type}_methods").grep(filter).each do |test|
suite.send("#{type}_methods").grep(/#{filter}/).each do |test|
@turn_case.new_test(test)
end

Expand Down Expand Up @@ -122,6 +122,14 @@ def puke(klass, meth, err)
super(klass, meth, err)
end

private

# regex gets turned into a string literal with leading/trailing slashes
# so remove them
def normalize_filter(filter)
filter.sub(/^(\/)/, '').sub(/(\/)$/, '') if filter

This comment has been minimized.

Copy link
@citizen428

citizen428 Mar 14, 2014

Contributor

Maybe something like "/sdfdsf/".tr(?/, '') #=> "sdfdsf" is simpler?

This comment has been minimized.

Copy link
@daniely

daniely Mar 14, 2014

Author Member

But I wanted to make sure it's only done at the start or end. Am I being too paranoid?

This comment has been minimized.

Copy link
@citizen428

citizen428 Mar 14, 2014

Contributor

I haven't really looked at the rest of the code, so I don't know if filter is likely to have forward slashes. Anyway, I'll have a look later, because maybe it makes more sense to tackle the actual problem instead of fixing the result.

end

end

end

0 comments on commit ab1065b

Please sign in to comment.