Sha256: 553a0c6ad991f703ca7b4a1c435f9f5c5e0927d6aac6366d1b3b0ca06e69393d

Contents?: true

Size: 771 Bytes

Versions: 8

Compression:

Stored size: 771 Bytes

Contents

# frozen_string_literal: true

RSpec.describe Mutant::Actor::Env do
  let(:thread)      { instance_double(Thread) }
  let(:thread_root) { class_double(Thread)    }

  let(:object) { described_class.new(thread_root) }

  describe '#spawn' do
    subject { object.spawn(&block) }

    let!(:mailbox) { Mutant::Actor::Mailbox.new }

    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
      should be(mailbox.sender)
    end

    it 'yields actor' do
      expect { subject }.to change { yields }.from([]).to([mailbox])
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
mutant-0.8.24 spec/unit/mutant/actor/env_spec.rb
mutant-0.8.23 spec/unit/mutant/actor/env_spec.rb
mutant-0.8.22 spec/unit/mutant/actor/env_spec.rb
mutant-0.8.21 spec/unit/mutant/actor/env_spec.rb
mutant-0.8.20 spec/unit/mutant/actor/env_spec.rb
mutant-0.8.19 spec/unit/mutant/actor/env_spec.rb
mutant-0.8.18 spec/unit/mutant/actor/env_spec.rb
mutant-0.8.17 spec/unit/mutant/actor/env_spec.rb