Sha256: d42d3579c45b58e5bda515872b1dddc44676f0cb19c3af78a91db3e080dc0186

Contents?: true

Size: 1.1 KB

Versions: 70

Compression:

Stored size: 1.1 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 }
            }.to raise_error
          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

70 entries across 70 versions & 3 rubygems

Version Path
itamae-spec-0.0.6 spec/unit/lib/itamae/handler_proxy_spec.rb
itamae-spec-0.0.5 spec/unit/lib/itamae/handler_proxy_spec.rb
itamae-spec-0.0.4 spec/unit/lib/itamae/handler_proxy_spec.rb
itamae-1.9.12 spec/unit/lib/itamae/handler_proxy_spec.rb
itamae-spec-0.0.3 spec/unit/lib/itamae/handler_proxy_spec.rb
itamae-spec-0.0.2 spec/unit/lib/itamae/handler_proxy_spec.rb
itamae-mitsurin-1.0.3 spec/unit/lib/itamae/handler_proxy_spec.rb
itamae-mitsurin-1.0.2 spec/unit/lib/itamae/handler_proxy_spec.rb
itamae-mitsurin-1.0.1 spec/unit/lib/itamae/handler_proxy_spec.rb
itamae-mitsurin-1.0.0 spec/unit/lib/itamae/handler_proxy_spec.rb
itamae-mitsurin-0.50 spec/unit/lib/itamae/handler_proxy_spec.rb
itamae-1.9.11 spec/unit/lib/itamae/handler_proxy_spec.rb
itamae-mitsurin-0.49 spec/unit/lib/itamae/handler_proxy_spec.rb
itamae-1.9.10 spec/unit/lib/itamae/handler_proxy_spec.rb
itamae-mitsurin-0.48 spec/unit/lib/itamae/handler_proxy_spec.rb
itamae-mitsurin-0.47 spec/unit/lib/itamae/handler_proxy_spec.rb
itamae-1.9.9 spec/unit/lib/itamae/handler_proxy_spec.rb
itamae-mitsurin-0.46 spec/unit/lib/itamae/handler_proxy_spec.rb
itamae-mitsurin-0.45 spec/unit/lib/itamae/handler_proxy_spec.rb
itamae-1.9.8 spec/unit/lib/itamae/handler_proxy_spec.rb