Sha256: 6a16ff7d36e5d3920b048cab1f2b77e69d053355f8124cc534e03bdacf80f185

Contents?: true

Size: 1.3 KB

Versions: 2

Compression:

Stored size: 1.3 KB

Contents

# frozen_string_literal: true

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

class ResqueWorkerTest < Minitest::Test
  def enqueue_and_run_job
    Resque.enqueue(TestResqueJob)
    queue = ENV['QUEUE'] ='resque_coverband'
    worker = Resque::Worker.new
    worker.startup
    worker.work_one_job
  end

  def setup
    super
    Coverband.configure do |config|
      config.background_reporting_enabled = false
      config.root_paths = ["#{File.expand_path('../', File.dirname(__FILE__))}/"]
    end
    Coverband.start
    redis = Coverband.configuration.store.send(:redis)
    Resque.redis = redis
  end

  test 'resque job coverage' do
    relative_job_file = './integrations/test_resque_job.rb'
    resque_job_file = File.expand_path('./test_resque_job.rb', File.dirname(__FILE__))
    require resque_job_file

    enqueue_and_run_job

    assert !Coverband::Background.running?

    # TODO: There is a test only type issue where the test is looking at eager data
    # it merged eager and eager for merged and runtime is eager
    Coverband.runtime_coverage!
    report = Coverband.configuration.store.get_coverage_report

    assert_equal 0, report[Coverband::EAGER_TYPE][relative_job_file]['data'][4]
    assert_equal 1, report[Coverband::RUNTIME_TYPE][relative_job_file]['data'][4]
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
coverband-4.2.0 test/coverband/integrations/resque_worker_test.rb
coverband-4.2.0.rc3 test/coverband/integrations/resque_worker_test.rb