Sha256: cc9b45a39c0edcfe721ec018218bc57c05ae12c4918a530d21f034e088153b52

Contents?: true

Size: 1.21 KB

Versions: 3

Compression:

Stored size: 1.21 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/fail' 

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

      context 'Initialization:' do
        it 'should have one instance' do
          expect { Fail.instance }.not_to raise_error
        end
        
        it 'should know its name' do
          expect(subject.name).to eq('fail')
        end
      end # context

      context 'Provided services:' do
        it 'should unconditionally return a failure result' do
          args = double('fake-args')
          env = double('fake-env')
          
          solver = nil
          expect { solver = subject.solver_for(args, env) }.not_to raise_error
          
          # Solver should quack like a Fiber
          dummy_arg = double('dummy-stuff')
          result = solver.resume(dummy_arg)
          expect(result).to eq(Failure)
          
          # 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

3 entries across 3 versions & 1 rubygems

Version Path
mini_kraken-0.1.04 spec/core/fail_spec.rb
mini_kraken-0.1.03 spec/core/fail_spec.rb
mini_kraken-0.1.02 spec/core/fail_spec.rb