Sha256: 51c85ac57b14e559bab021a2feebca9ecc4376958f1e75203cf3b58b18b53b6e

Contents?: true

Size: 1.28 KB

Versions: 3

Compression:

Stored size: 1.28 KB

Contents

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

require 'test/unit'
require 'dibber'

module Dibber
  class ProcessLogTest < Test::Unit::TestCase
    def setup
      @process_log = ProcessLog.new

    end

    def test_one
      @process_log.start(:one, '1')
      @process_log.finish(:one)

      expected = {:one => {:start => 1, :finish => 1, :command => '1'}}
      assert_equal(expected, @process_log.raw)
    end

    def test_two
      test_one
      @process_log.start(:two, '2')
      @process_log.finish(:two)

      expected = {
        :one => {:start => 1, :finish => 1, :command => '1'},
        :two => {:start => 2, :finish => 2, :command => '2'}
      }
      assert_equal(expected, @process_log.raw)
    end

    def test_report
      test_two
      expected = [
        'One was 1, now 1.',
        'Two was 2, now 2.'
      ]
      assert_equal(expected, @process_log.report)
    end

    def test_report_with_no_finish
      @process_log.start(:no_finish, '1')
      expected = ['No finish was 1, now 1.']
      assert_equal(expected, @process_log.report)
    end

    def test_exists_method
      assert !@process_log.exists?(:one), "There should not be a log for :one yet"
      test_one
      assert @process_log.exists?(:one), "There should be log for :one"
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
dibber-0.4.0 test/dibber/process_log_test.rb
dibber-0.3.1 test/dibber/process_log_test.rb
dibber-0.3.0 test/dibber/process_log_test.rb