Sha256: 503445de5f917de267f61ec0b628d5bd607ab4cbbadfd54231e3acf6dcebc4c3

Contents?: true

Size: 1.82 KB

Versions: 14

Compression:

Stored size: 1.82 KB

Contents

require 'gorgon/callback_handler'

describe CallbackHandler do

  let(:config) {
    {
      :before_start => "some/file.rb",
      :after_complete => "some/other/file.rb",
      :before_creating_workers => "callbacks/before_creating_workers_file.rb",
      :after_sync => "callbacks/after_sync_file.rb"
    }
  }

  it "calls before hook" do
    handler = CallbackHandler.new(config)

    handler.should_receive(:load).with("some/file.rb")

    handler.before_start
  end

  it "does not attempt to load the before start script when before_start is not defined" do
    handler = CallbackHandler.new({})

    handler.should_not_receive(:load)

    handler.before_start
  end

  it "calls after hook" do
    handler = CallbackHandler.new(config)

    handler.should_receive(:load).with("some/other/file.rb")

    handler.after_complete
  end

  it "does not attempt to load the after complete script when before_start is not defined" do
    handler = CallbackHandler.new({})

    handler.should_not_receive(:load)

    handler.after_complete
  end

  it "calls before fork hook" do
    handler = CallbackHandler.new(config)

    handler.should_receive(:load).with("callbacks/before_creating_workers_file.rb")

    handler.before_creating_workers
  end

  it "does not attempt to load the before creating workers script when before_creating_workers is not defined" do
    handler = CallbackHandler.new({})

    handler.should_not_receive(:load)

    handler.before_creating_workers
  end

  it "calls after sync hook" do
    handler = CallbackHandler.new(config)

    handler.should_receive(:load).with("callbacks/after_sync_file.rb")

    handler.after_sync
  end

  it "does not attempt to load the after-sync script when after_sync is not defined" do
    handler = CallbackHandler.new({})

    handler.should_not_receive(:load)

    handler.after_sync
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
gorgon-0.4.2 spec/callback_handler_spec.rb
gorgon-0.4.1 spec/callback_handler_spec.rb
gorgon-0.4.1.rc1 spec/callback_handler_spec.rb
gorgon-0.4.0 spec/callback_handler_spec.rb
gorgon-0.4.0.rc2 spec/callback_handler_spec.rb
gorgon-0.4.0.rc1 spec/callback_handler_spec.rb
gorgon-0.3.2 spec/callback_handler_spec.rb
gorgon-0.3.1 spec/callback_handler_spec.rb
gorgon-0.3.0 spec/callback_handler_spec.rb
gorgon-0.2.0 spec/callback_handler_spec.rb
gorgon-0.1.1 spec/callback_handler_spec.rb
gorgon-0.1.0 spec/callback_handler_spec.rb
gorgon-0.0.2 spec/callback_handler_spec.rb
gorgon-0.0.1 spec/callback_handler_spec.rb