Sha256: 54c989a3d5b71d0ed0ff137db9b4c82f21c7032ac62fb7c42438fd7d9482e38e

Contents?: true

Size: 473 Bytes

Versions: 2

Compression:

Stored size: 473 Bytes

Contents

module Afterparty
  module QueueTestHelpers

    def test_job later=false, &block
      job = block ? TestJob.new(block) : TestJob.new
      job.execute_at = Time.now + (later) if later
      @block = block
      job
    end

    def chill seconds
      t = Time.now
      while Time.now < (t + seconds); end
    end
  end
end

class TestJob
  attr_accessor :execute_at, :name

  def initialize &block
    @block = block
  end

  def run
    @block.call if @block
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
afterparty-0.2.0 spec/helpers.rb
afterparty-0.1.1 spec/helpers.rb