Sha256: c321856f44e55de33eb9d8c8825a0343ae78db9399460fb494de100a4a44f1ea

Contents?: true

Size: 1.08 KB

Versions: 4

Compression:

Stored size: 1.08 KB

Contents

#!/usr/bin/env ruby
require 'test/unit'
require_relative '../../processor/mock'
require_relative '../../processor/command/kill'

class TestCommandKill < Test::Unit::TestCase

  def setup
    @name      = File.basename(__FILE__, '.rb').split(/-/)[2]
    @dbg, @cmd = MockDebugger::setup(@name, false)
    def @cmd.msg(message)
      @msgs << message
    end
    def @cmd.errmsg(message)
      @errmsgs << message
    end
    reset_cmdproc_vars
  end

  def reset_cmdproc_vars
    @cmd.instance_variable_set('@msgs', [])
    @cmd.instance_variable_set('@errmsgs', [])
    @cmd.proc.leave_cmd_loop = false
  end
  
  def test_kill_command
      @cmd.run([@name, 'foo'])
      assert_equal(false,  @cmd.proc.leave_cmd_loop)
      assert_equal(1, @cmd.instance_variable_get('@errmsgs').size)
      
    if false
      save_trap = Signal.trap(10) {
        @success = true
      }
      
      @success = false
      @cmd.run([@name, '10'])
      #  assert_equal(true,  @success, 
      #             'Should have run the handler')
    end

  ensure
    # restore old trap if any
    trap(10, save_trap)
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
trepanning-0.0.9 test/unit/test-cmd-kill.rb
trepanning-0.0.8 test/unit/test-cmd-kill.rb
trepanning-0.0.6 test/unit/test-cmd-kill.rb
trepanning-0.0.4 test/unit/test-cmd-kill.rb