Sha256: cd2004dffdfa6bf08fd68cfac7ebb6943290c25d04ca8d1e5ef3f260e1a6a280

Contents?: true

Size: 826 Bytes

Versions: 1

Compression:

Stored size: 826 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 an unsupported handler" do
    let(:handler) { mock }

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

Version data entries

1 entries across 1 versions & 1 rubygems

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