2014-10-23 11:37:53 +00:00
|
|
|
RSpec.describe Mutant::Actor::Env do
|
2014-12-06 04:34:04 +00:00
|
|
|
let(:thread) { double('Thread') }
|
|
|
|
let(:thread_root) { double('Thread Root') }
|
2014-10-23 11:37:53 +00:00
|
|
|
|
|
|
|
let(:object) { described_class.new(thread_root) }
|
|
|
|
|
|
|
|
describe '#spawn' do
|
|
|
|
subject { object.spawn(&block) }
|
|
|
|
|
2014-12-06 04:34:04 +00:00
|
|
|
let!(:mailbox) { Mutant::Actor::Mailbox.new }
|
2014-10-23 11:37:53 +00:00
|
|
|
|
|
|
|
let(:yields) { [] }
|
|
|
|
|
|
|
|
let(:block) { ->(actor) { yields << actor } }
|
|
|
|
|
|
|
|
before do
|
|
|
|
expect(Mutant::Actor::Mailbox).to receive(:new).and_return(mailbox).ordered
|
|
|
|
expect(thread_root).to receive(:new).and_yield.and_return(thread).ordered
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'returns sender' do
|
2014-12-06 04:34:04 +00:00
|
|
|
should be(mailbox.sender)
|
2014-10-23 11:37:53 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'yields actor' do
|
2014-12-06 04:34:04 +00:00
|
|
|
expect { subject }.to change { yields }.from([]).to([mailbox])
|
2014-10-23 11:37:53 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|