Sha256: 4dabd4baa1213ceeb1aa19dc635f4c99b003790aa68ec43ed2012835bfea50af
Contents?: true
Size: 1.32 KB
Versions: 1
Compression:
Stored size: 1.32 KB
Contents
# frozen_string_literal: true require_relative '../spec_helper' # Use the RSpec framework # Load the class under test require_relative '../../lib/mini_kraken/core/duck_fiber' module MiniKraken module Core describe DuckFiber do Callable = Struct.new(:proc) do def call proc.call end end let(:ctx) { Core::Context.new } let(:callable) { -> { ctx.failed! } } subject { DuckFiber.new(callable) } context 'Initialization:' do it 'could be initialized with a Proc' do expect { DuckFiber.new(-> { ctx.failed }) }.not_to raise_error end it "could be initialized with an object that responds to 'call'" do expect { DuckFiber.new(callable) }.not_to raise_error end it 'should know its callable object' do expect(subject.callable).to eq(callable) end end # context context 'Provided services:' do it 'should behave like a Fiber yielding the given Context' do result = nil expect { result = subject.resume }.not_to raise_error expect(result).to eq(ctx) expect(ctx).to be_failure # Only one result should be yielded expect(subject.resume).to be_nil end end # context end # describe end # module end # module
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
mini_kraken-0.3.00 | spec/core/duck_fiber_spec.rb |