Sha256: 6d251053dde7a4304a6341a67643e594199e10530d19818a2aecbbe9687238ab

Contents?: true

Size: 1.58 KB

Versions: 2

Compression:

Stored size: 1.58 KB

Contents

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

module Aspect4r::Model
  describe Advice do
    it "before? returns true for before advice" do
      advice = Advice.new Advice::BEFORE, MethodMatcher.new, :advice_method, :group
      advice.before?.should be_true
    end
  
    it "before_filter? returns false for before advice" do
      advice = Advice.new Advice::BEFORE, MethodMatcher.new, :advice_method, :group
      advice.before_filter?.should be_false
    end
  
    it "before? returns false for before_filter advice" do
      advice = Advice.new Advice::BEFORE, MethodMatcher.new, :advice_method, :group, :skip_if_false => true
      advice.before?.should be_false
    end
  
    it "before_filter? returns true for before_filter advice" do
      advice = Advice.new Advice::BEFORE, MethodMatcher.new, :advice_method, :group, :skip_if_false => true
      advice.before_filter?.should be_true
    end
  
    it "invoke before advice" do
      advice = Advice.new Advice::BEFORE, MethodMatcher.new, :advice_method, :group
    
      o = Object.new
      o.expects(:advice_method).with(1)
    
      advice.invoke(o, 1)
    end
  
    it "invoke after advice" do
      advice = Advice.new Advice::AFTER, MethodMatcher.new, :advice_method, :group
    
      o = Object.new
      o.expects(:advice_method).with(1)
    
      advice.invoke(o, 1)
    end
  
    it "invoke around advice" do
      advice = Advice.new Advice::AROUND, MethodMatcher.new, :advice_method, :group
    
      o = Object.new
      o.expects(:advice_method).with(1)
    
      advice.invoke(o, 1)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
aspect4r-0.10.0 spec/aspect4r/model/advice_spec.rb
aspect4r-0.9.1 spec/aspect4r/model/advice_spec.rb