mirror of
https://github.com/pry/pry.git
synced 2022-11-09 12:35:05 -05:00
Fix errors in tests on Windows
Some tests are still failing, though. This commit fixes wrong usage of temporary paths on Windows. Please, note: the `edit` command is working well; the issue is in poor tests. Prettify some ugly code in `spec/editor_spec.rb`.
This commit is contained in:
parent
9df47232cc
commit
ae3f534b35
2 changed files with 23 additions and 8 deletions
|
@ -1,3 +1,4 @@
|
|||
require 'pathname'
|
||||
require 'helper'
|
||||
|
||||
describe "edit" do
|
||||
|
@ -15,13 +16,25 @@ describe "edit" do
|
|||
end
|
||||
|
||||
describe "with FILE" do
|
||||
before do
|
||||
# OS-specific tempdir name. For GNU/Linux it's "tmp", for Windows it's
|
||||
# something "Temp".
|
||||
@tf_dir = Pathname.new(Dir::Tmpname.tmpdir)
|
||||
|
||||
@tf_path = File.expand_path(File.join(@tf_dir.to_s, 'bar.rb'))
|
||||
FileUtils.touch(@tf_path)
|
||||
end
|
||||
|
||||
after do
|
||||
FileUtils.rm(@tf_path) if File.exists?(@tf_path)
|
||||
end
|
||||
|
||||
it "should invoke Pry.config.editor with absolutified filenames" do
|
||||
pry_eval 'edit lib/pry.rb'
|
||||
@file.should == File.expand_path('lib/pry.rb')
|
||||
|
||||
FileUtils.touch '/tmp/bar.rb'
|
||||
pry_eval 'edit /tmp/bar.rb'
|
||||
@file.should == '/tmp/bar.rb'
|
||||
pry_eval "edit #@tf_path"
|
||||
@file.should == @tf_path
|
||||
end
|
||||
|
||||
it "should guess the line number from a colon" do
|
||||
|
@ -40,9 +53,11 @@ describe "edit" do
|
|||
end
|
||||
|
||||
it "works with files that contain blanks in their names" do
|
||||
FileUtils.touch '/tmp/hello world.rb'
|
||||
pry_eval 'edit /tmp/hello world.rb'
|
||||
@file.should == '/tmp/hello world.rb'
|
||||
tf_path = File.join(File.dirname(@tf_path), 'swoop and doop.rb')
|
||||
FileUtils.touch(tf_path)
|
||||
pry_eval "edit #{ tf_path }"
|
||||
@file.should == tf_path
|
||||
FileUtils.rm(tf_path)
|
||||
end
|
||||
|
||||
describe do
|
||||
|
|
|
@ -11,7 +11,7 @@ describe Pry::Editor do
|
|||
# something "Temp".
|
||||
@tf_dir = Pathname.new(Dir::Tmpname.tmpdir)
|
||||
|
||||
@tf_path = @tf_dir.to_s + File::SEPARATOR + 'hello world.rb'
|
||||
@tf_path = File.join(@tf_dir.to_s, 'hello world.rb')
|
||||
end
|
||||
|
||||
unless Pry::Helpers::BaseHelpers.windows?
|
||||
|
@ -68,7 +68,7 @@ describe Pry::Editor do
|
|||
|
||||
it 'should not shell-escape files' do
|
||||
Pry::Editor.invoke_editor(@tf_path, 10, true)
|
||||
@file.should == "#@tf_path"
|
||||
@file.should == @tf_path
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue