2014-12-06 04:34:04 +00:00
|
|
|
RSpec.describe Mutant::Actor::Mailbox do
|
2015-11-15 20:16:42 +00:00
|
|
|
let(:mutex) { instance_double(Mutex) }
|
|
|
|
let(:condition_variable) { instance_double(ConditionVariable) }
|
2014-12-06 04:34:04 +00:00
|
|
|
|
|
|
|
before do
|
2014-12-07 21:06:34 +00:00
|
|
|
allow(Mutex).to receive(:new).and_return(mutex)
|
2014-12-06 04:34:04 +00:00
|
|
|
allow(ConditionVariable).to receive(:new).and_return(condition_variable)
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '.new' do
|
|
|
|
subject { described_class.new }
|
|
|
|
|
2015-11-15 20:16:42 +00:00
|
|
|
let(:object) { described_class.new }
|
|
|
|
let(:thread) { instance_double(Thread) }
|
2014-12-06 04:34:04 +00:00
|
|
|
|
|
|
|
its(:sender) { should eql(Mutant::Actor::Sender.new(condition_variable, mutex, [])) }
|
|
|
|
its(:receiver) { should eql(Mutant::Actor::Receiver.new(condition_variable, mutex, [])) }
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '#bind' do
|
2015-11-15 20:16:42 +00:00
|
|
|
let(:object) { described_class.new }
|
|
|
|
let(:other) { instance_double(Mutant::Actor::Sender) }
|
2014-12-06 04:34:04 +00:00
|
|
|
|
|
|
|
subject { object.bind(other) }
|
|
|
|
|
|
|
|
it { should eql(Mutant::Actor::Binding.new(object, other)) }
|
|
|
|
end
|
|
|
|
end
|