Sha256: 86005715aa7038271a56d0259563270bfca287938c94d4b13c618cd6d1e3f339

Contents?: true

Size: 1.88 KB

Versions: 17

Compression:

Stored size: 1.88 KB

Contents

require 'spec_helper'

describe "nodelets" do
  class SpecialNodelet < DripDrop::Node::Nodelet
    def action
      route :worker1,     :zmq_pull, distributor_output.address, :connect
      route :worker2,     :zmq_pull, distributor_output.address, :connect
    end
  end
  
  before(:all) do
    nodelets = {}
    
    
    @node = run_reactor do
      nodelet :distributor do |nlet|
        nlet.route :output, :zmq_push, rand_addr, :bind
      end
      
      nodelet :worker_cluster, SpecialNodelet
    end
    
    @nodelets = @node.nodelets
  end
  
  it "should create the nodelets" do
    @nodelets.length.should == 2
  end
  
  it "should pass a DripDrop::Node::Nodelet to the block" do
    @nodelets.values.each do |nlet|
      nlet.should be_kind_of(DripDrop::Node::Nodelet)
    end
  end
    
  it "should give access to the full routing table to nodelets" do
    @node.routing.each do |route_name,handler|
      @nodelets.values.each do |nlet|
        nlet.send(route_name).should == handler
      end
    end
  end
  
  it "should use the class SpecialNodelet for the nodelet assigned that" do
    @nodelets[:worker_cluster].should be_a(SpecialNodelet)
  end

  it "should return a DripDrop::Handler for short routes" do
    @nodelets[:distributor].send(:output).should be_a(DripDrop::BaseHandler)
  end

  it "should return a DripDrop::Handler for long routes" do
    @nodelets[:distributor].send(:distributor_output).should be_a(DripDrop::BaseHandler)
  end
  
  it "should define prefix-less versions of nodelet specific routes" do
    {
      @nodelets[:worker_cluster] => {:worker1 => :worker_cluster_worker1, 
                                     :worker2 => :worker_cluster_worker2},
      @nodelets[:distributor]    => {:output  => :distributor_output}
    }.each do |nlet, mapping|
      mapping.each do |short,long|
        nlet.send(short).should == nlet.send(long)
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
dripdrop-0.11.0-java spec/node/nodelet_spec.rb
dripdrop-0.11.0 spec/node/nodelet_spec.rb
dripdrop-0.10.0 spec/node/nodelet_spec.rb
dripdrop-0.10.0-java spec/node/nodelet_spec.rb
dripdrop-0.10.0.beta2 spec/node/nodelet_spec.rb
dripdrop-0.10.0.beta1 spec/node/nodelet_spec.rb
dripdrop-0.9.10 spec/node/nodelet_spec.rb
dripdrop-0.9.9 spec/node/nodelet_spec.rb
dripdrop-0.9.8 spec/node/nodelet_spec.rb
dripdrop-0.9.6 spec/node/nodelet_spec.rb
dripdrop-0.9.5 spec/node/nodelet_spec.rb
dripdrop-0.9.4 spec/node/nodelet_spec.rb
dripdrop-0.9.3 spec/node/nodelet_spec.rb
dripdrop-0.9.2 spec/node/nodelet_spec.rb
dripdrop-0.8.1 spec/node/nodelet_spec.rb
dripdrop-0.8.0 spec/node/nodelet_spec.rb
dripdrop-0.7.1 spec/node/nodelet_spec.rb