Sha256: 6c72133a9fd26802c0c342fdc151f439e86154de4839da55d53fef6b9ddd6aa6

Contents?: true

Size: 1.74 KB

Versions: 2

Compression:

Stored size: 1.74 KB

Contents

#Celluloid.logger = nil

class FakeWorker

  class << self
    attr_accessor :last_worker
    attr_accessor :jobs
  end

  self.jobs ||= []

  def initialize
    FakeWorker.last_worker = self
    FakeWorker.jobs ||= []
  end

  def foo(args)
    FakeWorker.jobs << args
  end

  def bar(args)
    FakeWorker.jobs << args
  end

end

Woodhouse.configure do |config|
  config.registry = { :FooBarWorker => FakeWorker }
  config.runner_type = :dummy
  config.dispatcher_type = :local
  config.logger = Logger.new("/dev/null")
end

shared_examples_for "common" do

  let(:empty_layout) {
    Woodhouse::Layout.new
  }

  let(:populated_layout) {
    Woodhouse::Layout.new.tap do |layout|
      layout.add_node Woodhouse::Layout::Node.new(:default)
      layout.node(:default).tap do |default|
        default.add_worker Woodhouse::Layout::Worker.new(:FooWorker, :foo)
        default.add_worker Woodhouse::Layout::Worker.new(:FooWorker, :foo, :only => { :size => "huge" })
        default.add_worker Woodhouse::Layout::Worker.new(:FooWorker, :bar, :threads => 3)
      end
      layout.add_node Woodhouse::Layout::Node.new(:other)
      layout.node(:other).tap do |default|
        default.add_worker Woodhouse::Layout::Worker.new(:OtherWorker, :bat)
      end
    end
  }

  let(:overlapping_layout) {
    Woodhouse::Layout.new.tap do |layout|
      layout.add_node Woodhouse::Layout::Node.new(:default)
      layout.node(:default).tap do |default|
        default.add_worker Woodhouse::Layout::Worker.new(:FooWorker, :foo)
        default.add_worker Woodhouse::Layout::Worker.new(:FooWorker, :bar, :threads => 3)
        default.add_worker Woodhouse::Layout::Worker.new(:BarWorker, :baz)
      end
    end
  }

  let!(:common_config) {
    Woodhouse.global_configuration
  }

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
woodhouse-0.1.2 spec/shared_contexts.rb
woodhouse-0.1.1 spec/shared_contexts.rb