Skip to content

Commit

Permalink
Fixes old use of instance variable #341
Browse files Browse the repository at this point in the history
  • Loading branch information
Dennis Günnewig committed Jan 25, 2016
1 parent 5f91220 commit 9cf22ae
Show file tree
Hide file tree
Showing 3 changed files with 94 additions and 2 deletions.
46 changes: 46 additions & 0 deletions features/api/command/stderr.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
Feature: Access STDERR of command

You may need to `#stop_all_commands` before accessing `#stderr` of a single
command - e.g. `#last_command_started`.

Background:
Given I use a fixture named "cli-app"
And the default aruba io wait timeout is 1 seconds

Scenario: Existing executable
Given an executable named "bin/cli" with:
"""bash
#!/bin/bash
echo 'Hello, Aruba!' >&2
"""
And a file named "spec/run_spec.rb" with:
"""ruby
require 'spec_helper'
RSpec.describe 'Run command', :type => :aruba do
before(:each) { run('cli') }
before(:each) { stop_all_commands }
it { expect(last_command_started.stderr).to start_with 'Hello' }
end
"""
When I run `rspec`
Then the specs should all pass

Scenario: Waiting for output to "appear" after 2 seconds
Given an executable named "bin/cli" with:
"""bash
#!/bin/bash
sleep 1
echo 'Hello, Aruba' >&2
"""
And a file named "spec/run_spec.rb" with:
"""ruby
require 'spec_helper'
RSpec.describe 'Run command', :type => :aruba, :io_wait_timeout => 2 do
before(:each) { run('cli') }
it { expect(last_command_started.stderr).to start_with 'Hello' }
end
"""
When I run `rspec`
Then the specs should all pass
46 changes: 46 additions & 0 deletions features/api/command/stdout.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
Feature: Access STDOUT of command

You may need to `#stop_all_commands` before accessing `#stdout` of a single
command - e.g. `#last_command_started`.

Background:
Given I use a fixture named "cli-app"
And the default aruba io wait timeout is 1 seconds

Scenario: Existing executable
Given an executable named "bin/cli" with:
"""bash
#!/bin/bash
echo 'Hello, Aruba!'
"""
And a file named "spec/run_spec.rb" with:
"""ruby
require 'spec_helper'
RSpec.describe 'Run command', :type => :aruba do
before(:each) { run('cli') }
before(:each) { stop_all_commands }
it { expect(last_command_started.stdout).to start_with 'Hello' }
end
"""
When I run `rspec`
Then the specs should all pass

Scenario: Waiting for output to "appear" after 2 seconds
Given an executable named "bin/cli" with:
"""bash
#!/bin/bash
sleep 1
echo 'Hello, Aruba'
"""
And a file named "spec/run_spec.rb" with:
"""ruby
require 'spec_helper'
RSpec.describe 'Run command', :type => :aruba, :io_wait_timeout => 2 do
before(:each) { run('cli') }
it { expect(last_command_started.stdout).to start_with 'Hello' }
end
"""
When I run `rspec`
Then the specs should all pass
4 changes: 2 additions & 2 deletions lib/aruba/processes/spawn_process.rb
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def stdin
def stdout(opts = {})
return @stdout_cache if stopped?

wait_for_io opts.fetch(:wait_for_io, @io_wait) do
wait_for_io opts.fetch(:wait_for_io, io_wait_timeout) do
@process.io.stdout.flush
open(@stdout_file.path).read
end
Expand All @@ -133,7 +133,7 @@ def stdout(opts = {})
def stderr(opts = {})
return @stderr_cache if stopped?

wait_for_io opts.fetch(:wait_for_io, @io_wait) do
wait_for_io opts.fetch(:wait_for_io, io_wait_timeout) do
@process.io.stderr.flush
open(@stderr_file.path).read
end
Expand Down

0 comments on commit 9cf22ae

Please sign in to comment.