free_mutant/spec/unit/mutant/actor/mailbox_spec.rb

30 lines
917 B
Ruby
Raw Normal View History

RSpec.describe Mutant::Actor::Mailbox do
let(:mutex) { instance_double(Mutex) }
let(:condition_variable) { instance_double(ConditionVariable) }
before do
2014-12-07 21:06:34 +00:00
allow(Mutex).to receive(:new).and_return(mutex)
allow(ConditionVariable).to receive(:new).and_return(condition_variable)
end
describe '.new' do
subject { described_class.new }
let(:object) { described_class.new }
let(:thread) { instance_double(Thread) }
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
let(:object) { described_class.new }
let(:other) { instance_double(Mutant::Actor::Sender) }
subject { object.bind(other) }
it { should eql(Mutant::Actor::Binding.new(object, other)) }
end
end