Sha256: 74ac55401744043b4ca7d53d64ade623f17fd5c3dd0e3e84ea5e2b2291a05ba9

Contents?: true

Size: 1.21 KB

Versions: 2

Compression:

Stored size: 1.21 KB

Contents

require_relative '../../spec_helper'
require_relative '../../../lib/say_when/processor/active_messaging'
require_relative '../../../lib/say_when/storage/active_record/job'

def destination(destination_name)
  d = ActiveMessaging::Gateway.find_destination(destination_name).value
  ActiveMessaging::Gateway.connection('default').find_destination d
end

describe SayWhen::Processor::ActiveMessaging do

  before do

    require 'activemessaging'

    ActiveMessaging::Gateway.stub!(:load_connection_configuration).and_return({:adapter=>:test})

    ActiveMessaging::Gateway.define do |s|    
      s.destination :say_when, '/queue/SayWhen'
    end

    SayWhen::Scheduler.configure do |scheduler|
      scheduler.storage_strategy = :active_record
      scheduler.processor_class  = SayWhen::Processor::ActiveMessaging
    end
    @processor = SayWhen::Processor::ActiveMessaging.new(SayWhen::Scheduler.scheduler)
  end

  it "process a job by sending a message" do
    @job = mock('SayWhen::Storage::ActiveRecord::Job')
    @job.should_receive(:id).and_return(100)
    @processor.process(@job)
    destination(:say_when).messages.size.should == 1
    YAML::load(destination(:say_when).messages.first.body)[:job_id].should == 100
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
say_when-0.4.1 spec/say_when/processor/active_messaging_spec.rb
say_when-0.4.0 spec/say_when/processor/active_messaging_spec.rb