Skip to content

Commit

Permalink
Simplify spec.
Browse files Browse the repository at this point in the history
  • Loading branch information
jarib committed Nov 27, 2011
1 parent 0923c77 commit e81debb
Showing 1 changed file with 9 additions and 26 deletions.
35 changes: 9 additions & 26 deletions spec/childprocess_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -172,32 +172,15 @@
end

it "preserves Dir.pwd in the child" do
require 'pathname'
begin
path = nil
Tempfile.open("dir-spec") {|tf| path = tf.path }
path = Pathname.new(path).realpath.to_s
File.unlink(path)
Dir.mkdir(path)
Dir.chdir(path) do
process = ruby("puts Dir.pwd")
begin
out = Tempfile.new("dir-spec-out")

process.io.stdout = out
process.io.stderr = out

process.start
process.poll_for_exit(EXIT_TIMEOUT)

out.rewind
out.read.should == "#{path}\n"
ensure
out.close
end
end
ensure
Dir.rmdir(path) if File.exist?(path)
Tempfile.open("dir-spec-out") do |file|
process = ruby("print Dir.pwd")
process.io.stdout = process.io.stderr = file

process.start
process.poll_for_exit(EXIT_TIMEOUT)

file.rewind
file.read.should == Dir.pwd
end
end

Expand Down

0 comments on commit e81debb

Please sign in to comment.