Sha256: 568402dddd9e1f5d3c52a66e56d904546effe0daa014e1658e444a4d6d96f271

Contents?: true

Size: 1.05 KB

Versions: 2

Compression:

Stored size: 1.05 KB

Contents

require File.dirname(__FILE__) + '/../lib/sweat_shop'
require File.dirname(__FILE__) + '/test_helper'
require File.dirname(__FILE__) + '/hello_worker'
class WorkerTest < Test::Unit::TestCase

  def setup
    File.delete(HelloWorker::TEST_FILE) if File.exist?(HelloWorker::TEST_FILE)
  end

  def teardown
    File.delete(HelloWorker::TEST_FILE) if File.exist?(HelloWorker::TEST_FILE)
  end

  test "daemon" do
    begin
      SweatShop.queue = nil
      SweatShop.logger = :silent

      worker = File.expand_path(File.dirname(__FILE__) + '/hello_worker')
      sweatd = "#{File.dirname(__FILE__)}/../lib/sweat_shop/sweatd.rb" 
      uid = HelloWorker.async_hello('Amos')

      `ruby #{sweatd} --worker-file #{worker} start`
      `ruby #{sweatd} stop`

      File.delete('sweatd.log') if File.exist?('sweatd.log')
      assert_equal 'Hi, Amos', File.read(HelloWorker::TEST_FILE)
    rescue Exception => e
      puts e.message
      puts e.backtrace.join("\n")
      fail "\n\n*** Functional test failed, is the rabbit server running on localhost? ***\n"
    end
  end
  
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
netinlet-sweat_shop-1.1.0 test/test_functional_worker.rb
netinlet-sweat_shop-1.1.1 test/test_functional_worker.rb