Skip to content

Commit ed254ba

Browse files
committed
Fix specs for IO.popen and chdir option to have them passed on Windows
1 parent 647eb55 commit ed254ba

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

core/io/popen_spec.rb

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -96,17 +96,19 @@
9696
end
9797

9898
it "accepts a path using the chdir: keyword argument" do
99-
File.write(@fname, 'hello world')
100-
@io = IO.popen("/bin/ls", chdir: File.dirname(@fname));
101-
@io.read.chomp.should == File.basename(@fname)
99+
path = File.dirname(@fname)
100+
101+
@io = IO.popen(ruby_cmd("puts Dir.pwd"), "r", chdir: path)
102+
@io.read.chomp.should == path
102103
end
103104

104105
it "accepts a path using the chdir: keyword argument and a coercible path" do
105-
path = mock("path")
106-
path.should_receive(:to_path).and_return(File.dirname(@fname))
107-
File.write(@fname, 'hello world')
108-
@io = IO.popen("/bin/ls", chdir: path);
109-
@io.read.chomp.should == File.basename(@fname)
106+
path = File.dirname(@fname)
107+
object = mock("path")
108+
object.should_receive(:to_path).and_return(path)
109+
110+
@io = IO.popen(ruby_cmd("puts Dir.pwd"), "r", chdir: object)
111+
@io.read.chomp.should == path
110112
end
111113

112114
describe "with a block" do

0 commit comments

Comments
 (0)