Skip to content

Instantly share code, notes, and snippets.

@mindscratch
Created August 2, 2012 01:44
Show Gist options
  • Select an option

  • Save mindscratch/3232350 to your computer and use it in GitHub Desktop.

Select an option

Save mindscratch/3232350 to your computer and use it in GitHub Desktop.
Aquarium DSL #after_raising
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
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
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