Skip to content

Instantly share code, notes, and snippets.

@gcao
Created June 11, 2010 15:42
Show Gist options
  • Save gcao/434658 to your computer and use it in GitHub Desktop.
Save gcao/434658 to your computer and use it in GitHub Desktop.
it "around advice" do
advice = Klass.a4r_data[:test][0]
advice.around?.should be_true
o = Klass.new
o.expects(:a4r_invoke).with(:proxy, 1)
advice.invoke(o, :proxy, 1)
o.value.should == %w(around(before) around(after))
end
it "before advice" do
advice = Klass.a4r_data[:test][1]
advice.before?.should be_true
o = Klass.new
advice.invoke(o, 1)
o.value.should == %w(before)
end
it "after advice" do
advice = Klass.a4r_data[:test][3]
advice.after?.should be_true
o = Klass.new
advice.invoke(o, 1, 1).should == 100
o.value.should == %w(after)
end
it "test method without advices" do
Klass.a4r_disable_advices_temporarily :test do
o = Klass.new
o.test 1
o.value.should == %w(test)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment