lib/minitest/spec.rb in minitest-2.11.3 vs lib/minitest/spec.rb in minitest-2.11.4

- old
+ new

@@ -172,10 +172,16 @@ raise "unsupported after type: #{type}" unless type == :each add_teardown_hook {|tc| tc.instance_eval(&block) } end + NAME_RE = if RUBY_VERSION >= "1.9" + Regexp.new("[^[[:word:]]]+") + else + /\W+/u + end + ## # Define an expectation with name +desc+. Name gets morphed to a # proper test method name. For some freakish reason, people who # write specs don't like class inheritence, so this goes way out of # its way to make sure that expectations aren't inherited. @@ -189,10 +195,10 @@ block ||= proc { skip "(no tests defined)" } @specs ||= 0 @specs += 1 - name = "test_%04d_%s" % [ @specs, desc.gsub(/\W+/, '_').downcase ] + name = "test_%04d_%s" % [ @specs, desc.gsub(NAME_RE, '_').downcase ] define_method name, &block self.children.each do |mod| mod.send :undef_method, name if mod.public_method_defined? name