lib/testrbl.rb in testrbl-0.2.0 vs lib/testrbl.rb in testrbl-0.3.0
- old
+ new
@@ -1,23 +1,15 @@
require 'testrbl/version'
module Testrbl
PATTERNS = [
/^(\s+)(should|test|it)\s+['"](.*)['"]\s+do\s*(?:#.*)?$/,
- /^(\s+)(context)\s+['"]?(.*?)['"]?\s+do\s*(?:#.*)?$/,
+ /^(\s+)(context|describe)\s+['"]?(.*?)['"]?\s+do\s*(?:#.*)?$/,
/^(\s+)def\s+(test_)([a-z_\d]+)\s*(?:#.*)?$/
]
OPTION_WITH_ARGUMENT = ["-I", "-r", "-n", "-e"]
-
- # copied from minitest
- MINITEST_NAME_RE = if RUBY_VERSION >= "1.9"
- Regexp.new("[^[[:word:]]]+")
- else
- /\W+/u
- end
-
INTERPOLATION = /\\\#\\\{.*?\\\}/
def self.run_from_cli(argv)
files, options = partition_argv(argv)
files = files.map { |f| localize(f) }
@@ -126,19 +118,24 @@
end
def self.test_pattern_from_match(method, test_name)
regex = Regexp.escape(test_name).gsub("\\ "," ").gsub(INTERPOLATION, ".*")
- if method == "should"
+ regex = case method
+ when "should"
optional_test_name = "(?:\(.*\))?"
- regex = "#{method} #{regex}\. #{optional_test_name}$"
- elsif method == "test"
+ "#{method} #{regex}\. #{optional_test_name}$"
+ when "describe"
+ "#{test_name}(::)?"
+ when "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}$"
+ "^test(: |_)#{regex.gsub(" ", ".")}$"
+ when "it"
+ "#test_\\d+_#{test_name}$"
+ else
+ regex
end
regex.gsub("'", ".")
end
end