Skip to content

Commit

Permalink
do not double-escape test names
Browse files Browse the repository at this point in the history
  • Loading branch information
grosser authored and latortuga committed Sep 26, 2014
1 parent 16e590f commit 7e6e47a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
5 changes: 2 additions & 3 deletions rubygem/lib/zeus/m.rb
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,7 @@ def build_test_arguments
elsif user_specified_name?
abort_with_no_test_found_by_name unless tests.contains?(@test_name)

test_names = test_name_to_s
["-n", test_names]
["-n", test_name_to_s]
else
[]
end
Expand All @@ -257,7 +256,7 @@ def abort_with_valid_tests_msg message=""
end

def test_name_to_s
@test_name.is_a?(Regexp)? "/#{Regexp.escape(@test_name.source)}/" : Regexp.escape(@test_name)
@test_name.is_a?(Regexp)? "/#{@test_name.source}/" : @test_name
end

def user_specified_name?
Expand Down
4 changes: 2 additions & 2 deletions rubygem/spec/m_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ module Zeus::M
lambda { Runner.new(argv).run }.should exit_with_code(0)
end

it "escapes the question mark from explicit names" do
it "does not escape regex on explicit names" do
argv = ["path/to/file.rb", "--name", fake_special_characters_test_method]

fake_runner.should_receive(:run).with(["-n", "test_my_test_method\\?"])
fake_runner.should_receive(:run).with(["-n", "test_my_test_method?"])

lambda { Runner.new(argv).run }.should exit_with_code(0)
end
Expand Down

0 comments on commit 7e6e47a

Please sign in to comment.