Sha256: 7030598961451d9b62f4c08f7b21eeaa8877007e3c3d5d9ed5a779912c131248

Contents?: true

Size: 1004 Bytes

Versions: 1

Compression:

Stored size: 1004 Bytes

Contents

require_relative 'test_helper'
require_relative 'jobs/test_job'

# Unit Test for RocketJob::Server
class ServerTest < Minitest::Test
  context RocketJob::Server do
    setup do
      RocketJob::Config.instance.heartbeat_seconds = 0.1
      RocketJob::Config.instance.max_poll_seconds  = 0.1
      @server = RocketJob::Server.new
      @description = 'Hello World'
      @arguments   = [ 1 ]
      @job = Jobs::TestJob.new(
        description:         @description,
        arguments:           @arguments,
        destroy_on_complete: false
      )
    end

    teardown do
      @job.destroy if @job && !@job.new_record?
    end

    context '.config' do
      should 'support multiple databases' do
        assert_equal 'test_rocketjob', RocketJob::Job.collection.db.name
      end
    end

    context '#run' do
      should 'run a server' do
        Thread.new { sleep 1; @server.stop!}
        @server.run
        assert_equal :stopping, @server.state, @server.inspect
      end
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rocketjob-0.8.0 test/server_test.rb