Sha256: b01a5fe2d0760ef0f4baafa6c74675a09172e07a37e79faa86af2c272dd14b8f

Contents?: true

Size: 1.14 KB

Versions: 26

Compression:

Stored size: 1.14 KB

Contents

require 'spec_helper'

module Itamae
  describe HandlerProxy do
    let(:handler) { instance_double(Handler::Base) }
    before { subject.register_instance(handler) }

    describe "#event" do
      context "with block" do
        context "when the block completes" do
          it "fires *_started and *_completed events" do
            expect(handler).to receive(:event).with(:name_started, :arg)
            expect(handler).to receive(:event).with(:name_completed, :arg)
            subject.event(:name, :arg) { }
          end
        end

        context "when the block fails" do
          it "fires *_started and *_failed events" do
            expect(handler).to receive(:event).with(:name_started, :arg)
            expect(handler).to receive(:event).with(:name_failed, :arg)
            expect {
              subject.event(:name, :arg) { raise "name is failed" }
            }.to raise_error "name is failed"
          end
        end
      end

      context "without block" do
        it "fires the event" do
          expect(handler).to receive(:event).with(:name, :arg)
          subject.event(:name, :arg)
        end
      end
    end
  end
end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
itamae-1.14.1 spec/unit/lib/itamae/handler_proxy_spec.rb
itamae-1.14.0 spec/unit/lib/itamae/handler_proxy_spec.rb
itamae-1.13.1 spec/unit/lib/itamae/handler_proxy_spec.rb
itamae-1.13.0 spec/unit/lib/itamae/handler_proxy_spec.rb
itamae-1.12.6 spec/unit/lib/itamae/handler_proxy_spec.rb
itamae-1.12.5 spec/unit/lib/itamae/handler_proxy_spec.rb
itamae-1.12.4 spec/unit/lib/itamae/handler_proxy_spec.rb
itamae-1.12.3 spec/unit/lib/itamae/handler_proxy_spec.rb
itamae-1.12.2 spec/unit/lib/itamae/handler_proxy_spec.rb
itamae-1.12.1 spec/unit/lib/itamae/handler_proxy_spec.rb
itamae-1.12.0 spec/unit/lib/itamae/handler_proxy_spec.rb
itamae-1.11.2 spec/unit/lib/itamae/handler_proxy_spec.rb
itamae-1.11.1 spec/unit/lib/itamae/handler_proxy_spec.rb
itamae-1.11.0 spec/unit/lib/itamae/handler_proxy_spec.rb
itamae-1.10.10 spec/unit/lib/itamae/handler_proxy_spec.rb
itamae-1.10.9 spec/unit/lib/itamae/handler_proxy_spec.rb
itamae-1.10.8 spec/unit/lib/itamae/handler_proxy_spec.rb
itamae-1.10.7 spec/unit/lib/itamae/handler_proxy_spec.rb
itamae-1.10.6 spec/unit/lib/itamae/handler_proxy_spec.rb
itamae-1.10.5 spec/unit/lib/itamae/handler_proxy_spec.rb