Sha256: 65c345a37804bba51d29d43115de7e27efa70d1b8d800441934dacec603afd0d

Contents?: true

Size: 1.03 KB

Versions: 13

Compression:

Stored size: 1.03 KB

Contents

require 'gorgon'

describe CallbackHandler do

  let(:config) {
    {
      :callbacks_class_file => "callback_file.rb"
    }
  }
  before do
    CallbackHandler.any_instance.stub(:load)
  end

  it "loads callback file" do
    CallbackHandler.any_instance.should_receive(:load).with config[:callbacks_class_file]

    CallbackHandler.new(config)
  end

  it "does not load callback file if it's not specified" do
    CallbackHandler.any_instance.should_not_receive(:load)

    CallbackHandler.new({})
  end

  context "#before_originate" do
    it "returns value from callbacks#before_originate if it's a string" do
      handler = CallbackHandler.new(config)
      Gorgon.callbacks.stub(:before_originate).and_return('my_job_id')
      expect(handler.before_originate).to eq('my_job_id')
    end

    it "returns nil if callbacks#before_originate did not return a string" do
      handler = CallbackHandler.new(config)
      Gorgon.callbacks.stub(:before_originate).and_return(Object.new)
      expect(handler.before_originate).to eq(nil)
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
gorgon-0.11.0 spec/callback_handler_spec.rb
gorgon-0.10.5 spec/callback_handler_spec.rb
gorgon-0.10.4 spec/callback_handler_spec.rb
gorgon-0.10.3 spec/callback_handler_spec.rb
gorgon-0.10.2 spec/callback_handler_spec.rb
gorgon-0.10.1 spec/callback_handler_spec.rb
gorgon-0.10.0 spec/callback_handler_spec.rb
gorgon-0.9.0 spec/callback_handler_spec.rb
gorgon-0.8.4 spec/callback_handler_spec.rb
gorgon-0.8.3 spec/callback_handler_spec.rb
gorgon-0.8.2 spec/callback_handler_spec.rb
gorgon-0.8.1 spec/callback_handler_spec.rb
gorgon-0.8.0 spec/callback_handler_spec.rb