Sha256: 85f259d315c08b7588921fb5e903643a26e3387709ea2eaabf4a537b110c85f8

Contents?: true

Size: 1.04 KB

Versions: 2

Compression:

Stored size: 1.04 KB

Contents

require File.expand_path('../../spec_helper.rb', __FILE__)

module SimpleWorker
  describe EventServer do
    let(:redis)            { double(Redis, :script => nil) }
    let(:namespace)        { 'my_namespace' }
    let(:jobid)            { 'my_jobid' }
    let(:event_server)     { EventServer.new(redis, namespace, jobid) }
    let(:log_key)          { "#{namespace}:log:#{jobid}" }
    let(:active_tasks_key) { "#{namespace}:active:#{jobid}" }
    let(:tasks_key)        { "#{namespace}:tasks:#{jobid}" }

    it 'can pull events' do
      expect(redis).to receive(:multi).and_return([[["event"].to_json], [["#{namespace}:active:#{jobid}:my_hostname:my_task"],["#{namespace}:active:#{jobid}:my2_hostname:my2_task"]], 0])

      expect(event_server).to receive(:fire).with("event")
      expect(event_server).to receive(:fire).with('on_task_expire', 'my_hostname', 'my_task')
      expect(event_server).to receive(:fire).with('on_task_active', 'my2_hostname', 'my2_task')

      result = event_server.pull_events
      expect(result).to eq(1)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
simpleworker-0.1.1 spec/simpleworker/event_server_spec.rb
simpleworker-0.1.0 spec/simpleworker/event_server_spec.rb