Sha256: 2bdc6a0a22dbdf9a1daba380905a06e04153688154c8ac3809e8ee48e9919498

Contents?: true

Size: 810 Bytes

Versions: 7

Compression:

Stored size: 810 Bytes

Contents

# coding: utf-8
require 'lib/command_runner'
require 'logger'
require 'test/unit'

class CommandRunnerTest < Test::Unit::TestCase
  def setup
    @log = Logger.new(STDERR)
    @log.level = Logger::ERROR
    @cmd = Hercules::CommandRunner.new @log
  end

  def test_command_output
    assert_equal 'test', @cmd.run("echo test").output
  end

  def test_command_log
    @cmd.run("echo test1")
    @cmd.run("echo test2")
    @cmd.run("echo test3")
    assert_equal "test1\ntest2\ntest3\n", @cmd.output
  end

  def test_command_log_store
    @cmd.run("echo test1")
    @cmd.run("echo test2")
    @cmd.run("echo test3")
    file = "/tmp/output.#{Time.now.strftime "%Y%m%d%H%M%S"}.log"
    @cmd.store_output file
    File.open(file, 'r') do |f|
      assert_equal "test1\ntest2\ntest3\n", f.read
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
hercules-0.2.6 tests/command_runner_test.rb
hercules-0.2.5 tests/command_runner_test.rb
hercules-0.2.4 tests/command_runner_test.rb
hercules-0.2.3 tests/command_runner_test.rb
hercules-0.2.2 tests/command_runner_test.rb
hercules-0.1.2 tests/command_runner_test.rb
hercules-0.1.1 tests/command_runner_test.rb