Sha256: 4cc2c26bab07bcd8e19cc75190dcee5c0ecca96a2ca342dfc79f0e3d23452ef8

Contents?: true

Size: 1.33 KB

Versions: 6

Compression:

Stored size: 1.33 KB

Contents

require "spec_helper"

describe Invoker::CommandListener::Client do
  describe "add command" do
    before do
      @client_socket = mock()
      @client = Invoker::CommandListener::Client.new(@client_socket)
    end
    
    it "should run if read from socket" do
      invoker_commander.expects(:on_next_tick).with("foo")
      @client_socket.expects(:gets).returns("add foo\n")

      @client.read_and_execute()
    end
  end

  describe "remove command" do
    before do
      @client_socket = mock()
      @client = Invoker::CommandListener::Client.new(@client_socket)
    end

    it "with specific signal" do
      invoker_commander.expects(:on_next_tick).with("foo", "9")
      @client_socket.expects(:gets).returns("remove foo 9\n")

      @client.read_and_execute()
    end

    it "with default signal" do
      invoker_commander.expects(:on_next_tick).with("foo",nil)
      @client_socket.expects(:gets).returns("remove foo\n")

      @client.read_and_execute()
    end
  end

  describe "invalid command" do
    before do
      @client_socket = mock()
      @client = Invoker::CommandListener::Client.new(@client_socket)
    end

    it "should print error if read from socket" do
      invoker_commander.expects(:on_next_tick).never()
      @client_socket.expects(:gets).returns("eugh foo\n")

      @client.read_and_execute
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
invoker-1.0.2 spec/invoker/command_listener/client_spec.rb
invoker-1.0.1 spec/invoker/command_listener/client_spec.rb
invoker-1.0.0 spec/invoker/command_listener/client_spec.rb
invoker-0.1.2 spec/invoker/command_listener/client_spec.rb
invoker-0.1.1 spec/invoker/command_listener/client_spec.rb
invoker-0.1.1.pre spec/invoker/command_listener/client_spec.rb