Sha256: a531646126adcd9b89cbf476166416674d1880491a739d5544a0e13e63284918

Contents?: true

Size: 1.6 KB

Versions: 3

Compression:

Stored size: 1.6 KB

Contents

if ENV['COVERAGE']
  require 'simplecov'
  SimpleCov.start do
    add_filter 'test'
    command_name 'Mintest'
  end
end

require 'bundler/setup'
require 'resque-state'
require 'minitest/autorun'
require 'mocha/setup'
require 'fakeredis'
require 'codeclimate-test-reporter'

CodeClimate::TestReporter.start

Resque.redis = Redis.new

#### Fixtures

class WorkingJob
  include Resque::Plugins::State

  def perform
    total = options['num']
    (1..total).each do |num|
      at(num, total, "At #{num}")
    end
  end
end

class ErrorJob
  include Resque::Plugins::State

  def perform
    raise "I'm a bad little job"
  end
end

class ErrorJobOnFailure
  include Resque::Plugins::State

  def perform
    raise "I'm a bad little job"
  end

  def on_failure(_e, *_args)
    failed("I'm such a terrible failure")
  end
end

class KillableJob
  include Resque::Plugins::State

  def perform
    Resque.redis.set("#{uuid}:iterations", 0)
    100.times do |num|
      Resque.redis.incr("#{uuid}:iterations")
      at(num, 100, "At #{num} of 100")
    end
  end
end

class SleeperJob
  include Resque::Plugins::State

  def perform
    @testing = true
    Resque.redis.set("#{uuid}:iterations", 0)
    100.times do |num|
      Resque.redis.incr("#{uuid}:iterations")
      at(num, 100, "At #{num} of 100")
    end
  end
end

class BasicJob
  include Resque::Plugins::State
end

class FailureJob
  include Resque::Plugins::State

  def perform
    failed("I'm such a failure")
  end
end

class NeverQueuedJob
  include Resque::Plugins::State

  def self.before_enqueue(*_args)
    false
  end

  def perform
    # will never get called
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
resque-state-1.0.2 test/test_helper.rb
resque-state-1.0.1 test/test_helper.rb
resque-state-1.0.0 test/test_helper.rb