Sha256: adb3870ef4ca7e39ff202ce7c8e42f795ef98fa6687fa6b9b9e3a994f5fe2f34

Contents?: true

Size: 1.53 KB

Versions: 15

Compression:

Stored size: 1.53 KB

Contents

# To change this template, choose Tools | Templates
# and open the template in the editor.

$:.unshift File.join(File.dirname(__FILE__),'..','lib')

require 'rubygems'

require 'test/unit'
gem 'Shoulda'; require 'shoulda'

require 'buzzcore/shell_extras'
require 'yore/yore_core'

class ShellTest < Test::Unit::TestCase
  should "raise exception on timeout"
  
  should "not raise exception on non-zero return code, fixed in block. Check result contents"
  
  should "return values from succesfult system call" do
    result = POpen4::shell('ls .')
    assert_instance_of Hash, result
    assert_instance_of String, result[:stdout]
    assert_instance_of String, result[:stderr]
    assert result[:stdout].length > 0
    assert_equal(0, result[:exitcode])
  end

  context "fail correctly" do

    should "raise exception on invalid ls" do
      begin
        result = POpen4::shell('ls asdsadasdasdasdasd')
      rescue ::StandardError => e
        assert_instance_of(POpen4::ExecuteError, e)
        assert_equal 1, e.result[:exitcode]
        assert_instance_of String,e.result[:stdout]
        assert_instance_of String,e.result[:stderr]
        return
      end
      flunk 'should have raised an exception'
    end

    should "not raise exception when fixed in block" do
      result = POpen4::shell('ls asdsadasdasdasdasd') do |r|
        r[:exitcode] = 0
      end
      assert_instance_of Hash, result
      assert_instance_of String, result[:stdout]
      assert_instance_of String, result[:stderr]
      assert_equal(0, result[:exitcode])
    end

  end
end

Version data entries

15 entries across 15 versions & 2 rubygems

Version Path
buzzware-buzzcore-0.2.2 test/shell_test.rb
buzzware-buzzcore-0.2.3 test/shell_test.rb
buzzcore-0.4.3 test/shell_test.rb
buzzcore-0.4.2 test/shell_test.rb
buzzcore-0.4.1 test/shell_test.rb
buzzcore-0.4.0 test/shell_test.rb
buzzcore-0.3.5 test/shell_test.rb
buzzcore-0.3.4 test/shell_test.rb
buzzcore-0.3.3 test/shell_test.rb
buzzcore-0.3.2 test/shell_test.rb
buzzcore-0.3.1 test/shell_test.rb
buzzcore-0.3.0 test/shell_test.rb
buzzcore-0.2.7 test/shell_test.rb
buzzcore-0.2.6 test/shell_test.rb
buzzcore-0.2.5 test/shell_test.rb