Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup SpawnProcess files after use #149

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/aruba/cucumber/hooks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,6 @@

After do
restore_env
only_processes.each { |process| process.close_io! }
processes.clear
end
5 changes: 5 additions & 0 deletions lib/aruba/in_process.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,10 @@ def stdout
def stderr
@stderr.string
end

def close_io!
@stdout.close
@stderr.close
end
end
end
5 changes: 5 additions & 0 deletions lib/aruba/spawn_process.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ def terminate
end
end

def close_io!
@out.close
@err.close
end

private

def wait_for_io(&block)
Expand Down
14 changes: 14 additions & 0 deletions spec/aruba/spawn_process_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,19 @@ module Aruba
end
end

describe '#close_io!' do
before { process.run! }

it 'closes std out' do
process.close_io!
lambda{ process.stdout }.should raise_error(IOError)
end

it 'closes std err' do
process.close_io!
lambda{ process.stderr }.should raise_error(IOError)
end
end

end
end