Sha256: ff0be84f0959b0857f773836056d46eed1a74ef858e6f46ae438d2cacc542bb9

Contents?: true

Size: 1.08 KB

Versions: 62

Compression:

Stored size: 1.08 KB

Contents

require 'spec_helper'
require 'singleton'
module Startback
  module Support
    describe Hooks, "after_xxx" do

      class AfterHooked
        include Hooks.new(:xxx)

        def initialize
          super
          @after_called = false
        end
        attr_accessor :after_called

        after_xxx do
          self.after_called = true
        end

      end

      class SubAfterHooked < AfterHooked

        def initialize
          super
          @subafter_called = false
        end
        attr_accessor :subafter_called

        after_xxx do
          self.subafter_called = true
        end

      end

      it 'works as expected' do
        h = AfterHooked.new
        expect(h.after_called).to eql(false)
        h.after_xxx
        expect(h.after_called).to eql(true)
      end

      it 'works as expected on subclass' do
        h = SubAfterHooked.new
        expect(h.after_called).to eql(false)
        expect(h.subafter_called).to eql(false)
        h.after_xxx
        expect(h.after_called).to eql(true)
        expect(h.subafter_called).to eql(true)
      end

    end
  end
end

Version data entries

62 entries across 62 versions & 3 rubygems

Version Path
startback-1.1.0 spec/unit/support/hooks/test_after_hook.rb
startback-1.0.3 spec/unit/support/hooks/test_after_hook.rb
startback-1.0.2 spec/unit/support/hooks/test_after_hook.rb
startback-1.0.1 spec/unit/support/hooks/test_after_hook.rb
startback-1.0.0 spec/unit/support/hooks/test_after_hook.rb
startback-0.19.4 spec/unit/support/hooks/test_after_hook.rb
startback-0.19.3 spec/unit/support/hooks/test_after_hook.rb
startback-0.19.1 spec/unit/support/hooks/test_after_hook.rb
startback-0.19.0 spec/unit/support/hooks/test_after_hook.rb
startback-0.18.2 spec/unit/support/hooks/test_after_hook.rb
startback-0.18.1 spec/unit/support/hooks/test_after_hook.rb
startback-0.18.0 spec/unit/support/hooks/test_after_hook.rb
startback-0.17.4 spec/unit/support/hooks/test_after_hook.rb
startback-0.17.3 spec/unit/support/hooks/test_after_hook.rb
startback-0.17.2 spec/unit/support/hooks/test_after_hook.rb
startback-0.17.1 spec/unit/support/hooks/test_after_hook.rb
startback-0.17.0 spec/unit/support/hooks/test_after_hook.rb
startback-0.16.0 spec/unit/support/hooks/test_after_hook.rb
startback-0.15.5 spec/unit/support/hooks/test_after_hook.rb
startback-0.15.4 spec/unit/support/hooks/test_after_hook.rb