Sha256: b5a1b6b68aa53de71c10ed4238f3c3533f886cb86bff75aedb22222e666d8692

Contents?: true

Size: 466 Bytes

Versions: 5

Compression:

Stored size: 466 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

  def initialize &block
    @block = block
  end

  def run
    @block.call if @block
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
afterparty-0.1.0 spec/helpers.rb
afterparty-0.0.4 spec/helpers.rb
afterparty-0.0.3 spec/helpers.rb
afterparty-0.0.21 spec/helpers.rb
afterparty-0.0.2 spec/helpers.rb