Sha256: 3a650bb3097b18e57d716590ca429ef58786a88bdbc6ef9a48704e1374f23654

Contents?: true

Size: 1.18 KB

Versions: 4

Compression:

Stored size: 1.18 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/succeed'

module MiniKraken
  module Core
    describe Succeed do
      subject { Succeed.instance }

      context 'Initialization:' do
        it 'should have one instance' do
          expect { Succeed.instance }.not_to raise_error
        end

        it 'should know its name' do
          expect(subject.name).to eq('succeed')
        end
      end # context

      context 'Provided services:' do
        let(:ctx) { Context.new }

        it 'should unconditionally return a success result' do
          solver = nil
          expect { solver = subject.solver_for([], ctx) }.not_to raise_error

          # Solver should quack like a Fiber
          dummy_arg = double('dummy-stuff')
          result = solver.resume(dummy_arg)
          expect(result).to eq(ctx)
          expect(result).to be_success

          # Only one "solution", next 'resume' call should return nil
          result = solver.resume(dummy_arg)
          expect(result).to be_nil
        end
      end # context
    end # describe
  end # module
end # module

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
mini_kraken-0.3.03 spec/core/succeed_spec.rb
mini_kraken-0.3.02 spec/core/succeed_spec.rb
mini_kraken-0.3.01 spec/core/succeed_spec.rb
mini_kraken-0.3.00 spec/core/succeed_spec.rb