
Several steps were made to achieve mutant working with Ruby 2.4 without warnings and spec failures: * Fix Fixnum deprecation warning * Update RuboCop to 0.47 and fix offenses * Relax version requirements on parser gem * Update diff-lcs to 1.3 * Update rake 11.x -> 12.x * Update reek 4.5 -> 4.6 (to work with parser 2.4) * Update json 2.0 -> 2.1 * Update parallel 1.10 -> 1.11 * Update simplecov 0.12 -> 0.14 * Run regexp_parser integration against v0.4.3 (as we requiring this exact version) * Update warnings.yml with new whitelist * Run CircleCI tests on Ruby 2.3 and 2.4 (Bundler.with_clean_env was causing troubles on new CircleCI 2.0 setup, so it was removed)
66 lines
2 KiB
Ruby
66 lines
2 KiB
Ruby
RSpec.describe Mutant::Parallel::Worker do
|
|
let(:actor_env) do
|
|
FakeActor::Env.new(message_sequence, actor_names)
|
|
end
|
|
|
|
let(:message_sequence) { FakeActor::MessageSequence.new }
|
|
let(:processor) { instance_double(Proc) }
|
|
let(:mailbox) { actor_env.mailbox(:worker) }
|
|
let(:parent) { actor_env.mailbox(:parent).sender }
|
|
let(:payload) { instance_double(Object) }
|
|
let(:result_payload) { instance_double(Object) }
|
|
|
|
let(:attributes) do
|
|
{
|
|
processor: processor,
|
|
parent: parent,
|
|
mailbox: mailbox
|
|
}
|
|
end
|
|
|
|
before do
|
|
message_sequence.add(:parent, :ready, mailbox.sender)
|
|
end
|
|
|
|
describe '.run' do
|
|
subject { described_class.run(attributes) }
|
|
|
|
let(:actor_names) { [:worker] }
|
|
|
|
context 'when receiving :job command' do
|
|
|
|
before do
|
|
expect(processor).to receive(:call).with(payload).and_return(result_payload)
|
|
|
|
message_sequence.add(:worker, :job, job)
|
|
message_sequence.add(:parent, :result, job_result)
|
|
message_sequence.add(:parent, :ready, mailbox.sender)
|
|
message_sequence.add(:worker, :stop)
|
|
end
|
|
|
|
let(:index) { instance_double(0.class) }
|
|
let(:job_result) { Mutant::Parallel::JobResult.new(job: job, payload: result_payload) }
|
|
let(:job) { Mutant::Parallel::Job.new(index: index, payload: payload) }
|
|
|
|
it 'signals ready and status to parent' do
|
|
subject
|
|
end
|
|
|
|
it { should be(described_class) }
|
|
|
|
it 'consumes all messages' do
|
|
expect { subject }.to change(&message_sequence.method(:consumed?)).from(false).to(true)
|
|
end
|
|
end
|
|
|
|
context 'when receiving unknown command' do
|
|
before do
|
|
message_sequence.add(:worker, :other)
|
|
end
|
|
|
|
it 'raises error' do
|
|
expect { subject }.to raise_error(Mutant::Actor::ProtocolError, 'Unknown command: :other')
|
|
end
|
|
end
|
|
end
|
|
end
|