summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHo-Sheng Hsiao <hosheng.hsiao@gmail.com>2012-03-27 14:34:13 -0400
committerHo-Sheng Hsiao <hosheng.hsiao@gmail.com>2012-03-27 14:34:13 -0400
commitc2f9e603214a1ec441c2b47b25493ae36c632124 (patch)
tree5e1752453784a8b5ae620b117c6d901d7de5d2b8
parent7f4256fe0eb44f494da6584b22d62ae4cff8c974 (diff)
downloadchef-c2f9e603214a1ec441c2b47b25493ae36c632124.tar.gz
[CHEF-2994][RB187] Got specs passing for Ruby 1.8.7 (Linux)
-rw-r--r--spec/mixlib/shellout/shellout_spec.rb10
1 files changed, 6 insertions, 4 deletions
diff --git a/spec/mixlib/shellout/shellout_spec.rb b/spec/mixlib/shellout/shellout_spec.rb
index 29a0f48729..e4ea34a5c8 100644
--- a/spec/mixlib/shellout/shellout_spec.rb
+++ b/spec/mixlib/shellout/shellout_spec.rb
@@ -767,12 +767,14 @@ describe Mixlib::ShellOut do
end
context 'with subprocess piping lots of data through stdin, stdout, and stderr' do
- let(:expected_output_with) { lambda { |chr| (chr * 20_000) + "#{LINE_ENDING}" + (chr * 20_000) + "#{LINE_ENDING}" } }
- let(:ruby_code) { 'while(input = gets) do ( input[0] == "f" ? STDOUT : STDERR ).puts input; end' }
+ let(:multiplier) { 20_000 }
+ let(:expected_output_with) { lambda { |chr| (chr * multiplier) + "#{LINE_ENDING}" + (chr * multiplier) + "#{LINE_ENDING}" } }
+ # Use regex to work across Ruby versions
+ let(:ruby_code) { 'while(input = gets) do ( input =~ /^f/ ? STDOUT : STDERR ).puts input; end' }
let(:options) { { :input => input } }
context 'when writing to STDOUT first' do
- let(:input) { [ 'f' * 20_000, 'u' * 20_000, 'f' * 20_000, 'u' * 20_000 ].join(LINE_ENDING) }
+ let(:input) { [ 'f' * multiplier, 'u' * multiplier, 'f' * multiplier, 'u' * multiplier ].join(LINE_ENDING) }
it "should not deadlock" do
stdout.should eql(expected_output_with.call('f'))
@@ -781,7 +783,7 @@ describe Mixlib::ShellOut do
end
context 'when writing to STDERR first' do
- let(:input) { [ 'u' * 20_000, 'f' * 20_000, 'u' * 20_000, 'f' * 20_000 ].join(LINE_ENDING) }
+ let(:input) { [ 'u' * multiplier, 'f' * multiplier, 'u' * multiplier, 'f' * multiplier ].join(LINE_ENDING) }
it "should not deadlock" do
stdout.should eql(expected_output_with.call('f'))