Sha256: 1b4633952698282ef50d7e8e229b9f5d2835e675414b2fd423e13d5998924eb7

Contents?: true

Size: 1.23 KB

Versions: 118

Compression:

Stored size: 1.23 KB

Contents

require File.join(File.expand_path(File.dirname(__FILE__)), '../../..', 'test_helper.rb')
require 'rbbt/util/log/progress'

class TestProgress < Test::Unit::TestCase
  def test_bar
    t1 = Thread.new do
      Log::ProgressBar.with_bar(20, :desc => "Bar 1") do |bar|
        20.times do
          bar.tick
          sleep 0.3
        end
        Log.debug "Done progress"
        assert_equal 100, bar.percent
      end
    end

    t2 = Thread.new do
      Log::ProgressBar.with_bar(20, :desc => "Bar 2") do |bar|
        20.times do
          bar.tick
          sleep 0.2
        end
        Log.debug "Done progress"
        assert_equal 100, bar.percent
      end
    end
    t1.join
    t2.join
  end

  def test_bar_no_size
    t1 = Thread.new do
      Log::ProgressBar.with_bar(nil, :desc => "Bar 1") do |bar|
        20.times do
          bar.tick
          sleep 0.3
        end
        #Log.debug "Done progress"
        assert bar.history.length > 0
      end
    end

    t2 = Thread.new do
      Log::ProgressBar.with_bar(nil, :desc => "Bar 2") do |bar|
        20.times do
          bar.tick
          sleep 0.2
        end
        #Log.debug "Done progress"
        assert bar.history.length > 0
      end
    end
    t1.join
    t2.join
  end
end

Version data entries

118 entries across 118 versions & 1 rubygems

Version Path
rbbt-util-5.17.41 test/rbbt/util/log/test_progress.rb
rbbt-util-5.17.40 test/rbbt/util/log/test_progress.rb
rbbt-util-5.17.39 test/rbbt/util/log/test_progress.rb
rbbt-util-5.17.38 test/rbbt/util/log/test_progress.rb
rbbt-util-5.17.37 test/rbbt/util/log/test_progress.rb
rbbt-util-5.17.35 test/rbbt/util/log/test_progress.rb
rbbt-util-5.17.33 test/rbbt/util/log/test_progress.rb
rbbt-util-5.17.32 test/rbbt/util/log/test_progress.rb
rbbt-util-5.17.31 test/rbbt/util/log/test_progress.rb
rbbt-util-5.17.30 test/rbbt/util/log/test_progress.rb
rbbt-util-5.17.29 test/rbbt/util/log/test_progress.rb
rbbt-util-5.17.28 test/rbbt/util/log/test_progress.rb
rbbt-util-5.17.27 test/rbbt/util/log/test_progress.rb
rbbt-util-5.17.26 test/rbbt/util/log/test_progress.rb
rbbt-util-5.17.25 test/rbbt/util/log/test_progress.rb
rbbt-util-5.17.24 test/rbbt/util/log/test_progress.rb
rbbt-util-5.17.23 test/rbbt/util/log/test_progress.rb
rbbt-util-5.17.22 test/rbbt/util/log/test_progress.rb
rbbt-util-5.17.21 test/rbbt/util/log/test_progress.rb
rbbt-util-5.17.20 test/rbbt/util/log/test_progress.rb