Sha256: 411cbd927ed4ebe57e4ed3eeee1df1efdf7865834f05956131f070da58388cf9

Contents?: true

Size: 1.46 KB

Versions: 1

Compression:

Stored size: 1.46 KB

Contents

require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')

require 'drbqs/manage/manage'

describe DRbQS::Manage::SendSignal do
  before(:all) do
    @ts = Rinda::TupleSpace.new
    @send_signal = DRbQS::Manage::SendSignal.new(@ts)
  end

  subject do
    @send_signal
  end

  it "should get ID of sender." do
    subject.sender_id.should be_an_instance_of String
  end

  it "should send :exit_signal." do
    @send_signal.send_exit_signal
    lambda do
      @ts.take([:server, :exit_server, @send_signal.sender_id], 0)
    end.should_not raise_error
  end

  it "should send :exit_after_task." do
    node_id = 100
    @send_signal.send_node_exit_after_task(node_id)
    lambda do
      @ts.take([:server, :exit_after_task, node_id], 0)
    end.should_not raise_error
  end

  it "should send signal to get status." do
    mes = 'message'
    @ts.should_receive(:take).once.and_return([:status, mes])
    @send_signal.get_status.should == mes
  end

  it "should send data." do
    data = 'hello world'
    @send_signal.send_data(data)
    lambda do
      @ts.take([:server, :new_data, data], 0)
    end.should_not raise_error 
  end

  it "should send request of response." do
    t = Time.now
    Time.should_receive(:now).and_return(t)
    sender_id = @send_signal.sender_id
    @ts.should_receive(:write).with([:server, :request_response, [sender_id, t]])
    @ts.should_receive(:take).once.and_return([:response, [sender_id, t]])
    @send_signal.get_response
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
drbqs-0.1.1 spec/manage/send_signal_spec.rb