spec/kamerling/receiver_spec.rb in kamerling-0.0.2 vs spec/kamerling/receiver_spec.rb in kamerling-0.0.3

- old
+ new

@@ -1,23 +1,33 @@ 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 - fakes :addr, :client, :task - - it 'saves the result and updates client and task' do - repos = fake :repos, as: :class - stub(repos).<<(any_args) { repos } - stub(repos).[](Client) { fake :repo, :[] => client } - stub(repos).[](Task) { fake :repo, :[] => task } - Receiver.new.receive addr: addr, client_uuid: client.uuid, data: 'data', - repos: repos, task_uuid: task.uuid - result = Result.new addr: addr, client: client, data: 'data', task: task, - uuid: anything - client.must_have_received :busy=, [false] - task.must_have_received :done=, [true] - repos.must_have_received :<<, [client] - repos.must_have_received :<<, [task] - repos.must_have_received :<<, [result] +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 end +end