Created
August 2, 2012 01:44
-
-
Save mindscratch/3232350 to your computer and use it in GitHub Desktop.
Aquarium DSL #after_raising
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'aquarium' | |
| module Gizmo | |
| class ExceptionHandling | |
| include Aquarium::DSL | |
| types = ['Gizmo::FindAll', 'Gizmo::Find', 'Gizmo::Make', 'Gizmo::Modify', 'Gizmo::Delete'] | |
| around :calls_to => [:call], :in_types => types do |jp, operation, *args| | |
| puts "inside around advice.. | |
| jp.proceed | |
| end | |
| after_raising :exceptions => [Exception], :pointcut => {:calls_to => [:call], :in_type => Gizmo::Find} do |*args| | |
| puts "AFTER RAISING" | |
| puts "# of args: #{args.size}" | |
| puts "args=#{args}" | |
| end | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| before(:each) do | |
| Gizmo::Find.any_instance.stub(:call) {|*args| raise Exception, "you shouldn't see this message, if so something isn't handling this error" } | |
| end | |
| it "should contain a Error in the response.data" do | |
| result = futz.find ModelsForTesting::Post, Moped::BSON::ObjectId.new | |
| result.data.should be_kind_of Gizmo::Error | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 1) Gizmo.find when an unexpected error occurs should contain a Error in the response.data | |
| Failure/Error: Gizmo::Find.any_instance.stub(:call) {|*args| raise Exception, "you shouldn't see this message, if so something isn't handling this error" } | |
| Exception: | |
| you shouldn't see this message, if so something isn't handling this error |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment