Sha256: 7f7b1515a91adf531c0d741e9ff4a5b4b96d127a077a079969d275ef0e43d249

Contents?: true

Size: 936 Bytes

Versions: 2

Compression:

Stored size: 936 Bytes

Contents

# encoding: utf-8

require 'spec_helper'

describe Utils, '.coerce_callable' do

  subject { described_class.coerce_callable(handler) }

  context "with a String handler" do
    let(:handler) { 'Spec::Action::Success' }

    it { should be(Spec::Action::Success) }
  end

  context "with a Symbol handler" do
    let(:handler) { :'Spec::Action::Success' }

    it { should be(Spec::Action::Success) }
  end

  context "with a const handler" do
    let(:handler) { Spec::Action::Success }

    it { should be(Spec::Action::Success) }
  end

  context "with a Proc handler" do
    let(:handler) { Proc.new { |response| respone } }

    it { should be(handler) }
  end

  context "with a Chain handler" do
    let(:handler) { Chain.new([]) }

    it { should be(handler) }
  end

  context "with an unsupported handler" do
    let(:handler) { mock }

    specify do
      expect { subject }.to raise_error(ArgumentError)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
substation-0.0.8 spec/unit/substation/utils/class_methods/coerce_callable_spec.rb
substation-0.0.7 spec/unit/substation/utils/class_methods/coerce_callable_spec.rb