1
0
Fork 0
mirror of https://github.com/pry/pry.git synced 2022-11-09 12:35:05 -05:00

Fix indentation (HARDER)

This commit is contained in:
Conrad Irwin 2013-01-13 14:24:58 -08:00 committed by John Mair
parent 4044682704
commit d29f6b5c04
2 changed files with 37 additions and 37 deletions

View file

@ -39,10 +39,10 @@ class Pry
Pry.config.editor.call(*args)
else
sanitized_file = if windows?
file.gsub(/\//, '\\')
else
Shellwords.escape(file)
end
file.gsub(/\//, '\\')
else
Shellwords.escape(file)
end
"#{Pry.config.editor} #{blocking_flag_for_editor(blocking)} #{start_line_syntax_for_editor(sanitized_file, line)}"
end

View file

@ -1,55 +1,55 @@
require 'helper'
describe Pry::Editor do
describe "build_editor_invocation_string" do
before do
class << Pry::Editor
public :build_editor_invocation_string
end
before do
class << Pry::Editor
public :build_editor_invocation_string
end
end
it 'should shell-escape files' do
Pry::Editor.build_editor_invocation_string("/tmp/hello world.rb", 5, true).should =~ %r(/tmp/hello\\ world.rb)
end
it 'should shell-escape files' do
Pry::Editor.build_editor_invocation_string("/tmp/hello world.rb", 5, true).should =~ %r(/tmp/hello\\ world.rb)
end
end
describe "build_editor_invocation_string on windows" do
before do
class << Pry::Editor
def windows?; true; end
end
before do
class << Pry::Editor
def windows?; true; end
end
end
after do
class << Pry::Editor
undef windows?
end
after do
class << Pry::Editor
undef windows?
end
end
it "should replace / by \\" do
Pry::Editor.build_editor_invocation_string("/tmp/hello world.rb", 5, true).should =~ %r(\\tmp\\)
end
it "should replace / by \\" do
Pry::Editor.build_editor_invocation_string("/tmp/hello world.rb", 5, true).should =~ %r(\\tmp\\)
end
it "should not shell-escape files" do
Pry::Editor.build_editor_invocation_string("/tmp/hello world.rb", 5, true).should =~ %r(hello world.rb)
end
it "should not shell-escape files" do
Pry::Editor.build_editor_invocation_string("/tmp/hello world.rb", 5, true).should =~ %r(hello world.rb)
end
end
describe 'invoke_editor with a proc' do
before do
@old_editor = Pry.config.editor
before do
@old_editor = Pry.config.editor
Pry.config.editor = proc{ |file, line, blocking|
@file = file
nil
@file = file
nil
}
end
end
after do
Pry.config.editor = @old_editor
end
after do
Pry.config.editor = @old_editor
end
it 'should not shell-escape files' do
Pry::Editor.invoke_editor('/tmp/hello world.rb', 10, true)
@file.should == "/tmp/hello world.rb"
end
it 'should not shell-escape files' do
Pry::Editor.invoke_editor('/tmp/hello world.rb', 10, true)
@file.should == "/tmp/hello world.rb"
end
end
end