summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorHo-Sheng Hsiao <hosheng.hsiao@gmail.com>2012-03-26 14:52:35 -0400
committerHo-Sheng Hsiao <hosheng.hsiao@gmail.com>2012-03-26 14:54:48 -0400
commit318c5572bc6cd1f3452760558bbb9da8b3b6dc9d (patch)
tree6915e8b3b6d5740f40215073f33d7bdc33b38ac0 /spec
parent724419d3d443ccf58075ef803b9aaf028ce2a4ee (diff)
downloadmixlib-shellout-318c5572bc6cd1f3452760558bbb9da8b3b6dc9d.tar.gz
[CHEF-2994][STDIN] ShellOut.new should accept input as an option
Diffstat (limited to 'spec')
-rw-r--r--spec/mixlib/shellout/shellout_spec.rb9
1 files changed, 7 insertions, 2 deletions
diff --git a/spec/mixlib/shellout/shellout_spec.rb b/spec/mixlib/shellout/shellout_spec.rb
index baf06d1..59afce0 100644
--- a/spec/mixlib/shellout/shellout_spec.rb
+++ b/spec/mixlib/shellout/shellout_spec.rb
@@ -160,7 +160,6 @@ describe Mixlib::ShellOut do
context 'when setting an input' do
let(:accessor) { :input }
let(:value) { "Random content #{rand(1000000)}" }
- let(:stream) { StringIO.new }
it "should set the input" do
should eql(value)
@@ -171,7 +170,8 @@ describe Mixlib::ShellOut do
context "with options hash" do
let(:cmd) { 'brew install couchdb' }
let(:options) { { :cwd => cwd, :user => user, :group => group, :umask => umask,
- :timeout => timeout, :environment => environment, :returns => valid_exit_codes, :live_stream => stream } }
+ :timeout => timeout, :environment => environment, :returns => valid_exit_codes,
+ :live_stream => stream, :input => input } }
let(:cwd) { '/tmp' }
let(:user) { 'toor' }
@@ -181,6 +181,7 @@ describe Mixlib::ShellOut do
let(:environment) { { 'RUBY_OPTS' => '-w' } }
let(:valid_exit_codes) { [ 0, 1, 42 ] }
let(:stream) { StringIO.new }
+ let(:input) { 1.upto(10).map { "Data #{rand(100000)}" }.join("\n") }
it "should set the working directory" do
shell_cmd.cwd.should eql(cwd)
@@ -240,6 +241,10 @@ describe Mixlib::ShellOut do
shell_cmd.live_stream.should eql(stream)
end
+ it "should set the input" do
+ shell_cmd.input.should eql(input)
+ end
+
context 'with an invalid option' do
let(:options) { { :frab => :job } }
let(:invalid_option_exception) { Mixlib::ShellOut::InvalidCommandOption }