From 054d82da1e23852a239c9c96800f0dfdb24adee8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dennis=20G=C3=BCnnewig?= Date: Sun, 26 May 2013 12:43:02 +0200 Subject: [PATCH 01/14] added tests for io stream --- features/interactive.feature | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/features/interactive.feature b/features/interactive.feature index 511aef499..4308a387a 100644 --- a/features/interactive.feature +++ b/features/interactive.feature @@ -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: Running a native binary interactively + 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 From a80ceee717f09d3f3866066fd1f4d043b71bad6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dennis=20G=C3=BCnnewig?= Date: Sun, 26 May 2013 12:43:19 +0200 Subject: [PATCH 02/14] added io stream steps --- lib/aruba/cucumber.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/lib/aruba/cucumber.rb b/lib/aruba/cucumber.rb index 62ad72ca0..253312ced 100644 --- a/lib/aruba/cucumber.rb +++ b/lib/aruba/cucumber.rb @@ -85,6 +85,21 @@ type(input) end +When /^I close the stdin stream$/ do + @interactive.stdin.close() +end + +When /^I pipe in the file "([^"]*)"$/ do |file| + in_current_dir do + File.open(file, 'r').each_line do |line| + _write_interactive(line) + end + end + + @interactive.stdin.close() +end + + When /^I wait for (?:output|stdout) to contain "([^"]*)"$/ do |expected| Timeout::timeout(exit_timeout) do loop do @@ -312,3 +327,4 @@ Then /^the file "([^"]*)" should not match \/([^\/]*)\/$/ do |file, partial_content| check_file_content(file, /#{partial_content}/, false) end + From 1cfc122bb5874caa870cfe3a7ff4f36d26e01b86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dennis=20G=C3=BCnnewig?= Date: Sun, 26 May 2013 12:48:05 +0200 Subject: [PATCH 03/14] rename scenario --- features/interactive.feature | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/features/interactive.feature b/features/interactive.feature index 4308a387a..92d964244 100644 --- a/features/interactive.feature +++ b/features/interactive.feature @@ -47,7 +47,7 @@ Feature: Interactive process control """ @posix - Scenario: Running a native binary interactively + Scenario: Close stdin stream When I run `cat` interactively And I type "Hello, world" And I close the stdin stream From d03f081297ace74435b2263185297447df8bf0bf Mon Sep 17 00:00:00 2001 From: Max Meyer Date: Sun, 9 Jun 2013 10:58:50 +0200 Subject: [PATCH 04/14] use correct method --- lib/aruba/api.rb | 10 ++++++++++ lib/aruba/cucumber.rb | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/aruba/api.rb b/lib/aruba/api.rb index 3826b123a..1cfcf0e3f 100644 --- a/lib/aruba/api.rb +++ b/lib/aruba/api.rb @@ -91,6 +91,16 @@ def check_file_presence(paths, expect_presence) end end + def pipe_in_file(file) + prep_for_fs_check do + File.open(file, 'r').each_line do |line| + _write_interactive(line) + end + + @interactive.eot + end + end + def check_file_size(paths_and_sizes) prep_for_fs_check do paths_and_sizes.each do |path, size| diff --git a/lib/aruba/cucumber.rb b/lib/aruba/cucumber.rb index 253312ced..239c78ab1 100644 --- a/lib/aruba/cucumber.rb +++ b/lib/aruba/cucumber.rb @@ -86,7 +86,7 @@ end When /^I close the stdin stream$/ do - @interactive.stdin.close() + @interactive.eot end When /^I pipe in the file "([^"]*)"$/ do |file| From 844c6d4edc2b672aec9450184f9d67910edaaad4 Mon Sep 17 00:00:00 2001 From: Max Meyer Date: Sun, 9 Jun 2013 10:59:02 +0200 Subject: [PATCH 05/14] move code to api --- lib/aruba/cucumber.rb | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/lib/aruba/cucumber.rb b/lib/aruba/cucumber.rb index 239c78ab1..a3fef577a 100644 --- a/lib/aruba/cucumber.rb +++ b/lib/aruba/cucumber.rb @@ -90,16 +90,9 @@ end When /^I pipe in the file "([^"]*)"$/ do |file| - in_current_dir do - File.open(file, 'r').each_line do |line| - _write_interactive(line) - end - end - - @interactive.stdin.close() + pipe_in_file(file) end - When /^I wait for (?:output|stdout) to contain "([^"]*)"$/ do |expected| Timeout::timeout(exit_timeout) do loop do From e7b142cc36c36e9e496fb8d6d60ee310d2a3bc93 Mon Sep 17 00:00:00 2001 From: Max Meyer Date: Sun, 9 Jun 2013 11:01:05 +0200 Subject: [PATCH 06/14] added alias --- lib/aruba/api.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/aruba/api.rb b/lib/aruba/api.rb index 1cfcf0e3f..809ac6ad7 100644 --- a/lib/aruba/api.rb +++ b/lib/aruba/api.rb @@ -348,6 +348,7 @@ def type(input) def eot @interactive.stdin.close end + alias_method :close_input, :eot def _write_interactive(input) @interactive.stdin.write(input) From a6a00b472c038a951d3df982059841ce7b746990 Mon Sep 17 00:00:00 2001 From: Max Meyer Date: Sun, 9 Jun 2013 11:09:39 +0200 Subject: [PATCH 07/14] added fuubar to make rspec work --- Gemfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Gemfile b/Gemfile index a273287f0..c3e6a21a0 100644 --- a/Gemfile +++ b/Gemfile @@ -1,6 +1,8 @@ source "http://rubygems.org" gemspec +gem 'fuubar' + # Use source from sibling folders (if available) instead of gems # %w[cucumber].each do |g| # if File.directory?(File.dirname(__FILE__) + "/../#{g}") From c13cae51d32a0e8d68ec9baeb116e9dc0a1199d2 Mon Sep 17 00:00:00 2001 From: Max Meyer Date: Sun, 9 Jun 2013 11:40:20 +0200 Subject: [PATCH 08/14] make it work --- lib/aruba/api.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/aruba/api.rb b/lib/aruba/api.rb index 809ac6ad7..bbb3391ed 100644 --- a/lib/aruba/api.rb +++ b/lib/aruba/api.rb @@ -92,12 +92,12 @@ def check_file_presence(paths, expect_presence) end def pipe_in_file(file) - prep_for_fs_check do + in_current_dir do File.open(file, 'r').each_line do |line| _write_interactive(line) end - @interactive.eot + eot end end From 7b78aa199de1a43ee069839954c1631752f1f384 Mon Sep 17 00:00:00 2001 From: Max Meyer Date: Sun, 9 Jun 2013 11:40:32 +0200 Subject: [PATCH 09/14] remove alias --- lib/aruba/api.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/aruba/api.rb b/lib/aruba/api.rb index bbb3391ed..2dfb4d21f 100644 --- a/lib/aruba/api.rb +++ b/lib/aruba/api.rb @@ -348,7 +348,6 @@ def type(input) def eot @interactive.stdin.close end - alias_method :close_input, :eot def _write_interactive(input) @interactive.stdin.write(input) From f7706aef64903dc3abbe1c83f64cb581364ae7b4 Mon Sep 17 00:00:00 2001 From: Max Meyer Date: Sun, 9 Jun 2013 11:40:48 +0200 Subject: [PATCH 10/14] added appi test --- spec/aruba/api_spec.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/spec/aruba/api_spec.rb b/spec/aruba/api_spec.rb index 98fe31bdb..bd5e76bbc 100644 --- a/spec/aruba/api_spec.rb +++ b/spec/aruba/api_spec.rb @@ -160,6 +160,12 @@ 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.all_output.should == "Hello\nWorld!" + end end end # Aruba::Api From fba87576c29dbbece5b02bca677dea262b378856 Mon Sep 17 00:00:00 2001 From: Max Meyer Date: Sun, 9 Jun 2013 11:41:53 +0200 Subject: [PATCH 11/14] added group specification --- Gemfile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index c3e6a21a0..6cf8ed3f6 100644 --- a/Gemfile +++ b/Gemfile @@ -1,7 +1,9 @@ source "http://rubygems.org" gemspec -gem 'fuubar' +group :development do + gem 'fuubar' +end # Use source from sibling folders (if available) instead of gems # %w[cucumber].each do |g| From 3dc728c520f5de167ef671ca3ff9127c37f01015 Mon Sep 17 00:00:00 2001 From: Max Meyer Date: Sun, 9 Jun 2013 11:43:09 +0200 Subject: [PATCH 12/14] moved to gemspec --- Gemfile | 4 ---- aruba.gemspec | 1 + 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/Gemfile b/Gemfile index 6cf8ed3f6..a273287f0 100644 --- a/Gemfile +++ b/Gemfile @@ -1,10 +1,6 @@ source "http://rubygems.org" gemspec -group :development do - gem 'fuubar' -end - # Use source from sibling folders (if available) instead of gems # %w[cucumber].each do |g| # if File.directory?(File.dirname(__FILE__) + "/../#{g}") diff --git a/aruba.gemspec b/aruba.gemspec index 8e3bfaf02..466bc80b5 100644 --- a/aruba.gemspec +++ b/aruba.gemspec @@ -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") From 45410dd8243fb03efe53337595d6e03b6d9de29f Mon Sep 17 00:00:00 2001 From: Max Meyer Date: Sun, 9 Jun 2013 11:52:12 +0200 Subject: [PATCH 13/14] explicit close --- spec/aruba/api_spec.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/spec/aruba/api_spec.rb b/spec/aruba/api_spec.rb index bd5e76bbc..30ef21713 100644 --- a/spec/aruba/api_spec.rb +++ b/spec/aruba/api_spec.rb @@ -164,6 +164,7 @@ def announce_or_puts(*args) 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 From de341913348dbf0bd19e5ed126854746629cf6d5 Mon Sep 17 00:00:00 2001 From: Max Meyer Date: Sun, 9 Jun 2013 14:24:30 +0200 Subject: [PATCH 14/14] ok i understand --- lib/aruba/api.rb | 2 -- lib/aruba/cucumber.rb | 4 +++- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/aruba/api.rb b/lib/aruba/api.rb index 2dfb4d21f..2d1f500d0 100644 --- a/lib/aruba/api.rb +++ b/lib/aruba/api.rb @@ -96,8 +96,6 @@ def pipe_in_file(file) File.open(file, 'r').each_line do |line| _write_interactive(line) end - - eot end end diff --git a/lib/aruba/cucumber.rb b/lib/aruba/cucumber.rb index a3fef577a..7a0ebe084 100644 --- a/lib/aruba/cucumber.rb +++ b/lib/aruba/cucumber.rb @@ -86,11 +86,13 @@ end When /^I close the stdin stream$/ do - @interactive.eot + 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|