Sha256: dd0a0d1e18b2528b5abbf31986d8f0bbb1a84a64e0c426d1e5d3f9474c536b4f

Contents?: true

Size: 1.09 KB

Versions: 7

Compression:

Stored size: 1.09 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)   { mock }
  let(:env)     { mock }

  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

7 entries across 7 versions & 1 rubygems

Version Path
substation-0.0.8 spec/unit/substation/dispatcher/call_spec.rb
substation-0.0.7 spec/unit/substation/dispatcher/call_spec.rb
substation-0.0.6 spec/unit/substation/dispatcher/call_spec.rb
substation-0.0.5 spec/unit/substation/dispatcher/call_spec.rb
substation-0.0.4 spec/unit/substation/dispatcher/call_spec.rb
substation-0.0.3 spec/unit/substation/dispatcher/call_spec.rb
substation-0.0.2 spec/unit/substation/dispatcher/call_spec.rb