Sha256: 6925bfaa15b99229adeda70e16c9fef4410e076032a775d7665f24ef68e8f953

Contents?: true

Size: 1.3 KB

Versions: 34

Compression:

Stored size: 1.3 KB

Contents

require File.join(File.dirname(__FILE__), '/../../spec_helper')

describe InitializerHooks do
  
  before(:each) do
    @class = Class.new do
      include InitializerHooks
      def initialize
        after_initialize
      end
      def to_s
        "TestClass"
      end
    end
  end
  
  describe "register" do
    it "should instance eval the given hook on initializing" do
      InitializerHooks.register @class do
        raise "Hook called in #{self}"
      end
      
      lambda { @class.new }.should raise_error("Hook called in TestClass")
    end
  end
  
  describe "append" do
    it "should instance eval the given hook on initializing" do
      InitializerHooks.register @class do
        raise "Hook called in #{self}"
      end
      InitializerHooks.append @class do
        raise "Appended hook called in #{self}"
      end
      
      lambda { @class.new }.should raise_error("Hook called in TestClass")
    end
  end
  
  describe "prepend" do
    it "should instance eval the given hook on initializing" do
      InitializerHooks.register @class do
        raise "Hook called in #{self}"
      end
      InitializerHooks.prepend @class do
        raise "Prepended hook called in #{self}"
      end
      
      lambda { @class.new }.should raise_error("Prepended hook called in TestClass")
    end
  end
  
end

Version data entries

34 entries across 34 versions & 1 rubygems

Version Path
gosu_extensions-0.1.27 spec/lib/core/initializer_hooks_spec.rb
gosu_extensions-0.1.26 spec/lib/core/initializer_hooks_spec.rb
gosu_extensions-0.1.25 spec/lib/core/initializer_hooks_spec.rb
gosu_extensions-0.1.24 spec/lib/core/initializer_hooks_spec.rb
gosu_extensions-0.1.23 spec/lib/core/initializer_hooks_spec.rb
gosu_extensions-0.1.22 spec/lib/core/initializer_hooks_spec.rb
gosu_extensions-0.1.21 spec/lib/core/initializer_hooks_spec.rb
gosu_extensions-0.1.20 spec/lib/core/initializer_hooks_spec.rb
gosu_extensions-0.1.19 spec/lib/core/initializer_hooks_spec.rb
gosu_extensions-0.1.18 spec/lib/core/initializer_hooks_spec.rb
gosu_extensions-0.1.17 spec/lib/core/initializer_hooks_spec.rb
gosu_extensions-0.1.16 spec/lib/core/initializer_hooks_spec.rb
gosu_extensions-0.1.15 spec/lib/core/initializer_hooks_spec.rb
gosu_extensions-0.1.14 spec/lib/traits/initializer_hooks_spec.rb