Sha256: af5ed965c7ef9c2516657ce6602db1b46f51857401685e503918bbee8beca500

Contents?: true

Size: 896 Bytes

Versions: 3

Compression:

Stored size: 896 Bytes

Contents

# frozen_string_literal: true

require File.expand_path('../../test_helper', File.dirname(__FILE__))

class BackgroundTest < Minitest::Test
  class ThreadDouble < Struct.new(:alive)
    def exit
    end

    def alive?
      alive
    end
  end

  def test_start
    Thread.expects(:new).yields.returns(ThreadDouble.new(true))
    Coverband::Background.expects(:loop).yields
    Coverband::Background.expects(:sleep).with(30)
    Coverband::Collectors::Coverage.instance.expects(:report_coverage).once
    2.times { Coverband::Background.start }
  end

  def test_start_dead_thread
    Thread.expects(:new).yields.returns(ThreadDouble.new(false)).twice
    Coverband::Background.expects(:loop).yields.twice
    Coverband::Background.expects(:sleep).with(30).twice
    Coverband::Collectors::Coverage.instance.expects(:report_coverage).twice
    2.times { Coverband::Background.start }
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
coverband-4.2.0 test/coverband/integrations/background_test.rb
coverband-4.2.0.rc3 test/coverband/integrations/background_test.rb
coverband-4.2.0.rc2 test/coverband/integrations/background_test.rb