Skip to content

Commit

Permalink
Test redirecting.
Browse files Browse the repository at this point in the history
  • Loading branch information
piotrmurach committed May 7, 2016
1 parent 6d35af1 commit 199cbf1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion spec/unit/cmd_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# encoding: utf-8

RSpec.describe TTY::Command::Cmd do
RSpec.describe TTY::Command::Cmd, '::new' do
it "requires at least command argument" do
expect {
TTY::Command::Cmd.new({})
Expand Down
12 changes: 11 additions & 1 deletion spec/unit/execute_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# encoding: utf-8

RSpec.describe TTY::Command do
RSpec.describe TTY::Command, '#execute' do
it 'executes command and prints to stdout' do
output = StringIO.new
command = TTY::Command.new(output: output)
Expand Down Expand Up @@ -102,4 +102,14 @@
command.execute!("echo 'nooo'; exit 1")
}.to raise_error(TTY::Command::FailedError, /Invoking `echo 'nooo'; exit 1` failed with status/)
end

it "redirects STDOUT to :err stream" do
output = StringIO.new
command = TTY::Command.new(output: output)

out, err = command.execute('echo hello', STDOUT => :err)

expect(out).to eq("")
expect(err).to eq("")
end
end

0 comments on commit 199cbf1

Please sign in to comment.