Sha256: 232a825ab950a14ff79328a492d31a3ccc2e9e56ab7d62eb4374caba795d49fb

Contents?: true

Size: 1.45 KB

Versions: 2

Compression:

Stored size: 1.45 KB

Contents

# encoding: utf-8

require 'spec_helper'

describe Processor::Evaluator::Pivot do
  describe '#call' do
    subject { object.call(request) }

    let(:klass) { described_class }

    include_context 'Processor::Call'

    context 'with a successful handler' do
      before do
        expect(decomposer).to receive(:call).with(request).and_return(decomposed)
        expect(handler).to receive(:call).with(decomposed).and_return(handler_result)
        expect(observers).to receive(:each).with(no_args).and_yield(observer)
        expect(observer).to receive(:call).with(handler_result)
        expect(handler_result).to receive(:success?)
      end

      it { should eql(handler_result) }
    end

    context 'with a failing handler' do
      let(:handler_success) { false }
      let(:response)        { Response::Failure.new(request, composed) }

      before do
        expect(decomposer).to receive(:call).with(request).and_return(decomposed)
        expect(handler).to receive(:call).with(decomposed).and_return(handler_result)
        expect(observers).to receive(:each).with(no_args).and_yield(observer)
        expect(observer).to receive(:call).with(handler_result)
        expect(handler_result).to receive(:success?)
        expect(composer).to receive(:call).with(request, handler_output).and_return(composed)
        expect(failure_chain).to receive(:call).with(response).and_return(failure_response)
      end

      it { should eql(failure_response) }
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
substation-0.0.11 spec/unit/substation/processor/evaluator/pivot_spec.rb
substation-0.0.10 spec/unit/substation/processor/evaluator/pivot_spec.rb