Skip to content
Browse files

Add support for BasicObjects

  • Loading branch information...
1 parent 448a9f9 commit e6259a786b1f9715127e9a26491331c5c525e549 @ConradIrwin committed Sep 23, 2012
Showing with 17 additions and 2 deletions.
  1. +1 −1 ext/interception.c
  2. +1 −1 interception.gemspec
  3. +15 −0 spec/interception_spec.rb
View
2 ext/interception.c
@@ -44,7 +44,7 @@ interception_start(VALUE self)
void
interception_hook(rb_event_flag_t evflag, VALUE data, VALUE self, ID mid, VALUE klass)
{
- VALUE binding = rb_funcall(self, rb_intern("binding"), 0, NULL);
+ VALUE binding = rb_funcall(rb_mKernel, rb_intern("binding"), 0, NULL);
rb_funcall(rb_mInterception, rb_intern("rescue"), 2, rb_errinfo(), binding);
}
View
2 interception.gemspec
@@ -1,6 +1,6 @@
Gem::Specification.new do |s|
s.name = "interception"
- s.version = "0.2"
+ s.version = "0.3"
s.author = "Conrad Irwin"
s.email = "conrad.irwin@gmail.com"
s.homepage = "http://github.com/ConradIrwin/interception"
View
15 spec/interception_spec.rb
@@ -138,4 +138,19 @@
it "should have the right exception and binding at the top level" do
$initial_eb.last.eval("self").should == TOPLEVEL_BINDING.eval("self")
end
+
+ if defined? BasicObject
+ it "should catch exceptions on basic objects" do
+
+ line = __LINE__ + 1
+ foo = Class.new(BasicObject){ def oops; shoulder = :bracket; foops; end }.new
+ begin
+ foo.oops
+ rescue => e1
+ #
+ end
+
+ @exceptions.map{ |e, b| [e] + b.eval('[self, shoulder, __LINE__]') }.should == [[e1, foo, :bracket, line]]
+ end
+ end
end

0 comments on commit e6259a7

Please sign in to comment.
Something went wrong with that request. Please try again.