-
-
Notifications
You must be signed in to change notification settings - Fork 161
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
Allow multiple arguments to xProcess#write #634
Open
mvz
wants to merge
5
commits into
main
Choose a base branch
from
improve-process-write
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
1835b0f
Allow multiple arguments to xProcess#write
mvz 2781e97
Fix some BasicProcess method implementations
mvz 239c163
Add specs for xProcess#write
mvz 2660b3d
Correct RuboCop offenses
mvz 8fde296
Fix YARD syntax for array of strings
mvz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -99,12 +99,11 @@ def stderr(*) | |
@stderr.string | ||
end | ||
|
||
# Write strint to stdin | ||
# Write strings to stdin | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, again, tidy! |
||
# | ||
# @param [String] input | ||
# Write string to stdin in | ||
def write(input) | ||
@stdin.write input | ||
# @param *input [Array<String>] | ||
def write(*input) | ||
@stdin.write(*input) | ||
end | ||
|
||
# Close io | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,45 @@ | ||
require "spec_helper" | ||
|
||
RSpec.describe Aruba::Processes::BasicProcess do | ||
let(:process) do | ||
Class.new(described_class) do | ||
def initialize(*args) | ||
@stdout = args.shift | ||
@stderr = args.shift | ||
super(*args) | ||
end | ||
|
||
def stdout(*_args) | ||
@stdout | ||
end | ||
|
||
def stderr(*_args) | ||
@stderr | ||
end | ||
end.new(stdout, stderr, cmd, exit_timeout, io_wait_timeout, working_directory) | ||
end | ||
|
||
let(:cmd) { "foobar" } | ||
let(:exit_timeout) { 0 } | ||
let(:io_wait_timeout) { 0 } | ||
let(:working_directory) { Dir.pwd } | ||
let(:stdout) { "foo output" } | ||
let(:stderr) { "foo error output" } | ||
let(:process) { described_class.new(cmd, exit_timeout, io_wait_timeout, working_directory) } | ||
|
||
describe '#inspect' do | ||
let(:stdout) { 'foo output' } | ||
let(:stderr) { 'foo error output' } | ||
|
||
let(:derived_process) do | ||
Class.new(described_class) do | ||
def initialize(*args) | ||
@stdout = args.shift | ||
@stderr = args.shift | ||
super(*args) | ||
end | ||
|
||
describe "#inspect" do | ||
it "shows useful info" do | ||
def stdout(*_args) | ||
@stdout | ||
end | ||
|
||
def stderr(*_args) | ||
@stderr | ||
end | ||
end.new(stdout, stderr, cmd, exit_timeout, io_wait_timeout, working_directory) | ||
end | ||
|
||
it 'shows useful info' do | ||
expected = /commandline="foobar": stdout="foo output" stderr="foo error output"/ | ||
expect(process.inspect).to match(expected) | ||
expect(derived_process.inspect).to match(expected) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a neat update to the expect() clauses. |
||
end | ||
|
||
context "with no stdout" do | ||
let(:stdout) { nil } | ||
|
||
it "shows useful info" do | ||
expected = /commandline="foobar": stdout=nil stderr="foo error output"/ | ||
expect(process.inspect).to match(expected) | ||
expect(derived_process.inspect).to match(expected) | ||
end | ||
end | ||
|
||
|
@@ -46,7 +48,7 @@ def stderr(*_args) | |
|
||
it "shows useful info" do | ||
expected = /commandline="foobar": stdout="foo output" stderr=nil/ | ||
expect(process.inspect).to match(expected) | ||
expect(derived_process.inspect).to match(expected) | ||
end | ||
end | ||
|
||
|
@@ -56,8 +58,26 @@ def stderr(*_args) | |
|
||
it "shows useful info" do | ||
expected = /commandline="foobar": stdout=nil stderr=nil/ | ||
expect(process.inspect).to match(expected) | ||
expect(derived_process.inspect).to match(expected) | ||
end | ||
end | ||
end | ||
|
||
describe '#stdin' do | ||
it 'raises NotImplementedError' do | ||
expect { process.stdin }.to raise_error NotImplementedError | ||
end | ||
end | ||
|
||
describe '#stdout' do | ||
it 'raises NotImplementedError' do | ||
expect { process.stdout }.to raise_error NotImplementedError | ||
end | ||
end | ||
|
||
describe '#stderr' do | ||
it 'raises NotImplementedError' do | ||
expect { process.stderr }.to raise_error NotImplementedError | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This probably needs to enumerate something like