Sha256: 7cb793a136715be5746075e11f41ee57f2bbc4a4d0932217e4202215d4bf7eed

Contents?: true

Size: 930 Bytes

Versions: 2

Compression:

Stored size: 930 Bytes

Contents

require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')

describe "singleton_method_added" do
  it "should work if target method is defined after singleton_method_added and singleton_method_added calls super" do
    class AdvicesOnClassMethod1
      include Aspect4r
        
      def self.singleton_method_added(method)
        super
      end
      
      class << self
        
        def value
          @value ||= []
        end
  
        around :test do |&block|
          value << "around1"
          block.call
          value << "around2"
        end   
      
        before :test do
          value << "before"
        end
  
        after :test do |result|
          value << "after"
        end
      
        def test
          value << "test"
        end
      end
    end
    
    AdvicesOnClassMethod1.test
    AdvicesOnClassMethod1.value.should == %w(before around1 test around2 after)
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
aspect4r-0.10.0 spec/aspect4r/singleton_method_added_spec.rb
aspect4r-0.9.1 spec/aspect4r/singleton_method_added_spec.rb