lib/testrbl.rb in testrbl-0.1.13 vs lib/testrbl.rb in testrbl-0.1.14

- old
+ new

@@ -78,30 +78,30 @@ exec command end def self.pattern_from_line(line) PATTERNS.each do |r| - if line =~ r - whitespace, method, test_name = $1, $2, $3 - regex = Regexp.escape(test_name).gsub("'",".").gsub("\\ "," ").gsub(INTERPOLATION, ".*") + next unless line =~ r + whitespace, method, test_name = $1, $2, $3 + return [whitespace, pattern_from_match(method, test_name)] + end + nil + end - if method == "should" - optional_test_name = "(?:\(.*\))?" - regex = "#{method} #{regex}\. #{optional_test_name}$" - elsif method == "test" - # test "xxx -_ yyy" - # test-unit: "test: xxx -_ yyy" - # activesupport: "test_xxx_-__yyy" - regex = "^test(: |_)#{regex.gsub(" ", ".")}$" - elsif method == "it" - regex = "^test_\\d+_#{test_name}$" - end + def self.pattern_from_match(method, test_name) + regex = Regexp.escape(test_name).gsub("\\ "," ").gsub(INTERPOLATION, ".*") - return [ - whitespace, - regex - ] - end + if method == "should" + optional_test_name = "(?:\(.*\))?" + regex = "#{method} #{regex}\. #{optional_test_name}$" + elsif method == "test" + # test "xxx -_ yyy" + # test-unit: "test: xxx -_ yyy" + # activesupport: "test_xxx_-__yyy" + regex = "^test(: |_)#{regex.gsub(" ", ".")}$" + elsif method == "it" + regex = "^test_\\d+_#{test_name}$" end - nil + + regex.gsub("'", ".") end end