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

Feature/io stream #154

Merged
merged 14 commits into from
Jun 17, 2013
Merged
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 aruba.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Gem::Specification.new do |s|
s.add_development_dependency 'kramdown', '>= 0.14'
s.add_development_dependency 'rake', '>= 0.9.2'
s.add_development_dependency 'rspec', '>= 2.7.0'
s.add_development_dependency 'fuubar', '>= 1.1.1'

s.rubygems_version = ">= 1.6.1"
s.files = `git ls-files`.split("\n")
Expand Down
25 changes: 25 additions & 0 deletions features/interactive.feature
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,31 @@ Feature: Interactive process control
Hello, world
"""

@posix
Scenario: Pipe in a file
Given a file named "test.txt" with:
"""
line1
line2
"""
When I run `cat` interactively
And I pipe in the file "test.txt"
Then the output should contain:
"""
line1
line2
"""

@posix
Scenario: Close stdin stream
When I run `cat` interactively
And I type "Hello, world"
And I close the stdin stream
Then the output should contain:
"""
Hello, world
"""

@posix
Scenario: Stop processes before checking for filesystem changes
See: http://github.com/aslakhellesoy/aruba/issues#issue/17 for context
Expand Down
8 changes: 8 additions & 0 deletions lib/aruba/api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,14 @@ def check_file_presence(paths, expect_presence)
end
end

def pipe_in_file(file)
in_current_dir do
File.open(file, 'r').each_line do |line|
_write_interactive(line)
end
end
end

def check_file_size(paths_and_sizes)
prep_for_fs_check do
paths_and_sizes.each do |path, size|
Expand Down
11 changes: 11 additions & 0 deletions lib/aruba/cucumber.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,16 @@
type(input)
end

When /^I close the stdin stream$/ do
eot
end

When /^I pipe in the file "([^"]*)"$/ do |file|
pipe_in_file(file)

eot
end

When /^I wait for (?:output|stdout) to contain "([^"]*)"$/ do |expected|
Timeout::timeout(exit_timeout) do
loop do
Expand Down Expand Up @@ -312,3 +322,4 @@
Then /^the file "([^"]*)" should not match \/([^\/]*)\/$/ do |file, partial_content|
check_file_content(file, /#{partial_content}/, false)
end

7 changes: 7 additions & 0 deletions spec/aruba/api_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,13 @@ def announce_or_puts(*args)
@aruba.eot
@aruba.all_output.should == "Hello\n"
end

it "pipes data" do
@aruba.write_file(@file_name, "Hello\nWorld!")
@aruba.pipe_in_file(@file_name)
@aruba.eot
@aruba.all_output.should == "Hello\nWorld!"
end
end

end # Aruba::Api