Sha256: 5afc9e47e12961fea9a6d771d5f07b02388662c457927ec61f16dcdf5deca04f

Contents?: true

Size: 1.25 KB

Versions: 1

Compression:

Stored size: 1.25 KB

Contents

require_relative '../spec_helper'
require_relative '../../lib/kamerling/addr'
require_relative '../../lib/kamerling/client'
require_relative '../../lib/kamerling/message'
require_relative '../../lib/kamerling/receiver'
require_relative '../../lib/kamerling/repo'
require_relative '../../lib/kamerling/repos'
require_relative '../../lib/kamerling/result'
require_relative '../../lib/kamerling/task'

module Kamerling
  describe Receiver do
    describe '.receive' do
      it 'saves the result and updates client and task' do
        addr   = Addr.new
        client = Client.new(busy: true)
        task   = Task.new(done: false)
        repos  = fake(:repos, as: :class)
        stub(repos).<<(any_args) { repos }
        stub(repos).[](Client)   { fake(:repo, :[] => client) }
        stub(repos).[](Task)     { fake(:repo, :[] => task)   }
        message = Message.build(client: client, payload: 'data',
                                project: Project.new, task: task, type: :RSLT)
        Receiver.receive addr: addr, message: message, repos: repos
        refute client.busy
        assert task.done
        repos.must_have_received :<<, [client]
        repos.must_have_received :<<, [any(Result)]
        repos.must_have_received :<<, [task]
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
kamerling-0.0.3 spec/kamerling/receiver_spec.rb