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.3.8 spec/lib/core/initializer_hooks_spec.rb
gosu_extensions-0.3.7 spec/lib/core/initializer_hooks_spec.rb
gosu_extensions-0.3.6 spec/lib/core/initializer_hooks_spec.rb
gosu_extensions-0.3.5 spec/lib/core/initializer_hooks_spec.rb
gosu_extensions-0.3.4 spec/lib/core/initializer_hooks_spec.rb
gosu_extensions-0.3.3 spec/lib/core/initializer_hooks_spec.rb
gosu_extensions-0.3.2 spec/lib/core/initializer_hooks_spec.rb
gosu_extensions-0.3.1 spec/lib/core/initializer_hooks_spec.rb
gosu_extensions-0.3.0 spec/lib/core/initializer_hooks_spec.rb
gosu_extensions-0.2.9 spec/lib/core/initializer_hooks_spec.rb
gosu_extensions-0.2.8 spec/lib/core/initializer_hooks_spec.rb
gosu_extensions-0.2.7 spec/lib/core/initializer_hooks_spec.rb
gosu_extensions-0.2.6 spec/lib/core/initializer_hooks_spec.rb
gosu_extensions-0.2.5 spec/lib/core/initializer_hooks_spec.rb
gosu_extensions-0.2.4 spec/lib/core/initializer_hooks_spec.rb
gosu_extensions-0.2.3 spec/lib/core/initializer_hooks_spec.rb
gosu_extensions-0.2.2 spec/lib/core/initializer_hooks_spec.rb
gosu_extensions-0.2.1 spec/lib/core/initializer_hooks_spec.rb
gosu_extensions-0.2.0 spec/lib/core/initializer_hooks_spec.rb
gosu_extensions-0.1.28 spec/lib/core/initializer_hooks_spec.rb