Browse files

Regexp.escape test names.

  • Loading branch information...
1 parent 46af094 commit 1c8c62d63b33f966abc2a8b65523ade88bbf0c55 @tristandunn tristandunn committed Jun 10, 2013
Showing with 19 additions and 3 deletions.
  1. +1 −1 lib/m.rb
  2. +5 −0 test/active_support_test.rb
  3. +2 −2 test/everything_test.rb
  4. +11 −0 test/examples/active_support_unescaped_example_test.rb
View
2 lib/m.rb
@@ -183,7 +183,7 @@ def execute
# If we found any tests,
if tests_to_run.size > 0
# assemble the regexp to run these tests,
- test_names = tests_to_run.map(&:name).join('|')
+ test_names = tests_to_run.map { |test| Regexp.escape(test.name) }.join('|')
# set up the args needed for the runner
test_arguments = ["-n", "/^(#{test_names})$/"]
View
5 test/active_support_test.rb
@@ -45,4 +45,9 @@ def test_run_on_test_with_spaces
output = m('examples/active_support_example_test.rb:22')
assert_output /1 tests, 1 assertions/, output
end
+
+ def test_run_on_test_with_unescaped_regular_express_characters
+ output = m('examples/active_support_unescaped_example_test.rb:8')
+ assert_output /1 tests, 1 assertions/, output
+ end
end
View
4 test/everything_test.rb
@@ -3,7 +3,7 @@
class EverythingTest < MTest
def test_runs_entire_test_suite_with_no_arguments
output = m('')
- assert_output /13 tests/, output
+ assert_output /14 tests/, output
end
def test_missing_file_gives_a_decent_error_message
@@ -18,7 +18,7 @@ def test_running_tests_within_a_subdirectory
assert_output /3 tests/, output
output = m('examples')
- assert_output /13 tests/, output
+ assert_output /14 tests/, output
end
def test_blank_file_is_quieter
View
11 test/examples/active_support_unescaped_example_test.rb
@@ -0,0 +1,11 @@
+require 'test/unit'
+require 'active_support/test_case'
+
+class ActiveSupportExampleTest < ActiveSupport::TestCase
+ setup do
+ end
+
+ test "#assert_equal compares to objects (and ensures they are equal)" do
+ assert_equal 1, 1
+ end
+end

0 comments on commit 1c8c62d

Please sign in to comment.