Sha256: 5fa6d0144f25acf4542e1798c4977e5c4c441265360a624c49e6e5d9d36e626b

Contents?: true

Size: 1.42 KB

Versions: 169

Compression:

Stored size: 1.42 KB

Contents

require File.expand_path('../helper', __FILE__)

class TestRakeCpuCounter < Rake::TestCase

  def setup
    super

    @cpu_counter = Rake::CpuCounter.new
  end

  def test_count
    num = @cpu_counter.count
    skip 'cannot count CPU' if num == nil
    assert_kind_of Numeric, num
    assert_operator num, :>=, 1
  end

  def test_count_with_default_nil
    def @cpu_counter.count; nil; end
    assert_equal(8, @cpu_counter.count_with_default(8))
    assert_equal(4, @cpu_counter.count_with_default)
  end

  def test_count_with_default_raise
    def @cpu_counter.count; raise; end
    assert_equal(8, @cpu_counter.count_with_default(8))
    assert_equal(4, @cpu_counter.count_with_default)
  end

  class TestClassMethod < Rake::TestCase
    def setup
      super

      @klass = Class.new(Rake::CpuCounter)
    end

    def test_count
      @klass.class_eval do
        def count; 8; end
      end
      assert_equal(8, @klass.count)
    end

    def test_count_nil
      counted = false
      @klass.class_eval do
        define_method(:count) do
          counted = true
          nil
        end
      end
      assert_equal(4, @klass.count)
      assert_equal(true, counted)
    end

    def test_count_raise
      counted = false
      @klass.class_eval do
        define_method(:count) do
          counted = true
          raise
        end
      end
      assert_equal(4, @klass.count)
      assert_equal(true, counted)
    end
  end
end

Version data entries

169 entries across 153 versions & 58 rubygems

Version Path
windows-pr-1.2.5 vendor/bundle/ruby/2.2.0/gems/win32-api-1.6.0-universal-mingw32/vendor/bundle/ruby/2.2.0/gems/rake-11.1.2/test/test_rake_cpu_counter.rb
win32-api-1.6.0-universal-mingw32 vendor/bundle/ruby/2.2.0/gems/rake-11.1.2/test/test_rake_cpu_counter.rb
warbler-2.0.2 spec/sample_bundler/vendor/bundle/jruby/2.3.0/gems/rake-10.5.0/test/test_rake_cpu_counter.rb
warbler-2.0.2 spec/sample_bundler/vendor/bundle/jruby/2.2.0/gems/rake-10.4.2/test/test_rake_cpu_counter.rb
warbler-2.0.2 spec/sample_bundler/vendor/bundle/jruby/2.2.0/gems/rake-10.5.0/test/test_rake_cpu_counter.rb
able-neo4j-1.0.0 vendor/bundle/jruby/1.9/gems/rake-10.4.2/test/test_rake_cpu_counter.rb
warbler-2.0.1 spec/sample_bundler/vendor/bundle/jruby/2.2.0/gems/rake-10.5.0/test/test_rake_cpu_counter.rb
warbler-2.0.1 spec/sample_bundler/vendor/bundle/jruby/2.3.0/gems/rake-10.5.0/test/test_rake_cpu_counter.rb
warbler-2.0.1 spec/sample_bundler/vendor/bundle/jruby/2.2.0/gems/rake-10.4.2/test/test_rake_cpu_counter.rb
guesswhat-1.1.0 vendor/bundle/gems/rake-10.5.0/test/test_rake_cpu_counter.rb
guesswhat-1.0.1 vendor/bundle/gems/rake-10.5.0/test/test_rake_cpu_counter.rb
guesswhat-1.0.0 vendor/bundle/gems/rake-10.5.0/test/test_rake_cpu_counter.rb
guesswhat-0.1.0 vendor/bundle/gems/rake-10.5.0/test/test_rake_cpu_counter.rb
ish_lib_manager-0.0.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/rake-11.1.2/test/test_rake_cpu_counter.rb
warbler-2.0.0 spec/sample_bundler/vendor/bundle/jruby/2.2.0/gems/rake-10.4.2/test/test_rake_cpu_counter.rb
rake-11.1.2 test/test_rake_cpu_counter.rb
warbler-2.0.0.rc3 spec/sample_bundler/vendor/bundle/jruby/2.2.0/gems/rake-10.4.2/test/test_rake_cpu_counter.rb
rake-11.1.1 test/test_rake_cpu_counter.rb
rake-11.1.0 test/test_rake_cpu_counter.rb
rake-11.0.1 test/test_rake_cpu_counter.rb