Skip to content

Commit

Permalink
Merge pull request #2479 from avit/pathnames
Browse files Browse the repository at this point in the history
Allow Pathname arguments to be escaped
  • Loading branch information
myronmarston committed Nov 15, 2017
2 parents c23bf6c + 67fd3f5 commit 06e3563
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/rspec/core/shell_escape.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module ShellEscape
module_function

def quote(argument)
"'#{argument.gsub("'", "\\\\'")}'"
"'#{argument.to_s.gsub("'", "\\\\'")}'"
end

if RSpec::Support::OS.windows?
Expand All @@ -17,7 +17,7 @@ def quote(argument)
require 'shellwords'

def escape(shell_command)
shell_command.shellescape
Shellwords.escape(shell_command.to_s)
end
end

Expand Down
9 changes: 9 additions & 0 deletions spec/rspec/core/bisect/runner_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,15 @@ def expect_formatters_to_be_excluded
expect(cmd).to first_include('-Il\ p/foo:l\ p/bar').then_include(RSpec::Core.path_to_executable)
end
end

it 'supports Pathnames in the load path' do
cmd = command_for([], :load_path => [Pathname('l p/foo'), Pathname('l p/bar') ])
if uses_quoting_for_escaping?
expect(cmd).to first_include("-I'l p/foo':'l p/bar'").then_include(RSpec::Core.path_to_executable)
else
expect(cmd).to first_include('-Il\ p/foo:l\ p/bar').then_include(RSpec::Core.path_to_executable)
end
end
end

describe "#repro_command_from", :simulate_shell_allowing_unquoted_ids do
Expand Down

0 comments on commit 06e3563

Please sign in to comment.