Sha256: c9debabcb790bfa990c498c0587ec2e00dfd94c46e5a25851883e7f1ca3e6219

Contents?: true

Size: 829 Bytes

Versions: 2

Compression:

Stored size: 829 Bytes

Contents

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

describe "method_added" do
  it "should work if target method is defined after method_added and method_added calls super" do
    klass = Class.new do
      include Aspect4r
      
      attr :value
      
      def initialize
        @value = []
      end
  
      around :test do |proxy|
        @value << "around1"
        a4r_invoke proxy
        @value << "around2"
      end   
      
      before :test do
        @value << "before"
      end
  
      after :test do |result|
        @value << "after"
      end
      
      def self.method_added(method)
        super
      end
      
      def test
        @value << "test"
      end
    end
    
    o = klass.new
    o.test
    
    o.value.should == %w(before around1 test around2 after)
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
aspect4r-0.9.0 spec/aspect4r/method_added_spec.rb
aspect4r-0.8.2 spec/aspect4r/method_added_spec.rb