Sha256: a803b26f0c53f929fdec60bfd4c11631b940cbb4d447e6dcaf4117dadccca8e3

Contents?: true

Size: 862 Bytes

Versions: 2

Compression:

Stored size: 862 Bytes

Contents

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

describe "Advices matched by regular expression" do
  it "should not apply to methods defined before advice" do
    @klass = Class.new do
      include Aspect4r

      attr :value
      
      def initialize
        @value = []
      end
      
      def test
        @value << "test"
      end
      
      before /test/ do
        @value << "before"
      end
    end

    @klass.new.test.should == %w"test"
  end
  
  it "should not apply to methods defined after advice" do
    @klass = Class.new do
      include Aspect4r

      attr :value
      
      def initialize
        @value = []
      end
      
      before /test/ do
        @value << "before"
      end
      
      def test
        @value << "test"
      end
    end

    @klass.new.test.should == %w"before test"
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

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