Sha256: 1e718e6852918b14ce2b2d0055036137ca364408d354598ca324dbf5f0dc8055

Contents?: true

Size: 1.34 KB

Versions: 20

Compression:

Stored size: 1.34 KB

Contents

require "spec_helper"

describe "Command Worker" do
  let(:pipe_end) { StringIO.new }
  let(:command_worker) { Invoker::CommandWorker.new('rails', pipe_end, 100, :red) }

  describe "converting workers hash to json" do
    before do
      @workers = {}
      @workers["foo"] = Invoker::CommandWorker.new("foo", 89, 1023, "red")
      @workers["bar"] = Invoker::CommandWorker.new("bar", 99, 1024, "blue")
    end

    it "should print json" do
      expect(@workers.values.map {|worker| worker.to_h }.to_json).not_to be_empty
    end
  end

  describe "sending json responses" do
    before do
      @socket = StringIO.new
      Invoker.tail_watchers = Invoker::CLI::TailWatcher.new
      Invoker.tail_watchers.add(['rails'], @socket)
    end

    after do
      Invoker.tail_watchers = nil
    end

    context "when there is a error encoding the message" do
      it "should send nothing to the socket" do
        MM::TailResponse.any_instance.expects(:encoded_message).raises(StandardError, "encoding error")
        command_worker.receive_line('hello_world')
        expect(@socket.string).to be_empty
      end
    end

    context "when there is successful delivery" do
      it "should return json data to client if tail watchers" do
        command_worker.receive_line('hello_world')
        expect(@socket.string).to match(/hello_world/)
      end
    end
  end
end

Version data entries

20 entries across 20 versions & 3 rubygems

Version Path
itrg-invoker-1.6.1 spec/invoker/command_worker_spec.rb
itrg-invoker-1.6.0 spec/invoker/command_worker_spec.rb
invoker-1.5.8 spec/invoker/command_worker_spec.rb
invoker-1.5.7 spec/invoker/command_worker_spec.rb
invoker-1.5.6 spec/invoker/command_worker_spec.rb
invoker-1.5.5 spec/invoker/command_worker_spec.rb
invoker-1.5.4 spec/invoker/command_worker_spec.rb
invoker-1.5.3 spec/invoker/command_worker_spec.rb
meepo-1.5.2 spec/invoker/command_worker_spec.rb
invoker-1.5.1 spec/invoker/command_worker_spec.rb
invoker-1.4.1 spec/invoker/command_worker_spec.rb
invoker-1.4.0 spec/invoker/command_worker_spec.rb
invoker-1.3.2 spec/invoker/command_worker_spec.rb
invoker-1.3.1 spec/invoker/command_worker_spec.rb
invoker-1.3.0 spec/invoker/command_worker_spec.rb
invoker-1.2.0 spec/invoker/command_worker_spec.rb
invoker-1.2.0.pre2 spec/invoker/command_worker_spec.rb
invoker-1.2.0.pre1 spec/invoker/command_worker_spec.rb
invoker-1.2.0.pre spec/invoker/command_worker_spec.rb
invoker-1.1.0 spec/invoker/command_worker_spec.rb