Sha256: 13d679a4c772c040dcb1b72bc4744ecec94666a6f3dabb5badd93339ae138121

Contents?: true

Size: 1.1 KB

Versions: 1

Compression:

Stored size: 1.1 KB

Contents

# encoding: utf-8

require 'spec_helper'

describe Dispatcher, '#call' do

  subject { object.call(action_name, input) }

  let(:object)  { described_class.coerce(config, env) }
  let(:config)  { { 'test' => { 'action' => 'Spec::Action::Success' } } }
  let(:request) { Request.new(env, input) }
  let(:input)   { double }
  let(:env)     { double }

  let(:expected_response) do
    Spec::Action::Success.call(request)
  end

  context 'when the action is registered' do
    let(:action_name) { :test }

    context 'without callbacks' do
      it { should eql(expected_response) }
    end

    context 'with observers' do
      let(:config) {
        config = super()
        config['test']['observer'] = 'Spec::Observer'
        config
      }

      it 'should call callback with response' do
        Spec::Observer.should_receive(:call).with(expected_response)
        should eql(expected_response)
      end
    end
  end

  context 'when the action is not registered' do
    let(:action_name) { :unknown }

    specify do
      expect { subject }.to raise_error(described_class::UnknownActionError)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
substation-0.0.10.beta2 spec/unit/substation/dispatcher/call_spec.rb