| a | b | |
|---|
| 0 | + | From a3f952616a416480f9f382248c39d0f37b1385b2 Mon Sep 17 00:00:00 2001 |
|---|
| 0 | + | From: Graham <graham-storm-git@ript.net> |
|---|
| 0 | + | Date: Thu, 28 Jan 2010 15:46:33 -0700 |
|---|
| 0 | + | Subject: [PATCH] Updated spec for issue when raising an object instance with a message |
|---|
| 0 | + | |
|---|
| 0 | + | --- |
|---|
| 0 | + | spec/ruby/language/rescue_spec.rb | 23 +++++++++++++++++++++++ |
|---|
| 0 | + | 1 files changed, 23 insertions(+), 0 deletions(-) |
|---|
| 0 | + | |
|---|
| 0 | + | diff --git a/spec/ruby/language/rescue_spec.rb b/spec/ruby/language/rescue_spec.rb |
|---|
| 0 | + | index 2bd01eb..1b1bd11 100644 |
|---|
| 0 | + | --- a/spec/ruby/language/rescue_spec.rb |
|---|
| 0 | + | +++ b/spec/ruby/language/rescue_spec.rb |
|---|
| 0 | + | @@ -3,6 +3,12 @@ class SpecificExampleException < StandardError |
|---|
| 0 | + | end |
|---|
| 0 | + | class OtherCustomException < StandardError |
|---|
| 0 | + | end |
|---|
| 0 | + | +class CustomArgumentException < StandardError |
|---|
| 0 | + | + attr_reader :val |
|---|
| 0 | + | + def initialize(val) |
|---|
| 0 | + | + @val = val |
|---|
| 0 | + | + end |
|---|
| 0 | + | +end |
|---|
| 0 | + | |
|---|
| 0 | + | def exception_list |
|---|
| 0 | + | [SpecificExampleException, ZeroDivisionError] |
|---|
| 0 | + | @@ -24,6 +30,23 @@ describe "The rescue keyword" do |
|---|
| 0 | + | e.message.should == "some text" |
|---|
| 0 | + | end |
|---|
| 0 | + | end |
|---|
| 0 | + | + |
|---|
| 0 | + | + it "can take an object instance instead of a class to raise" do |
|---|
| 0 | + | + begin |
|---|
| 0 | + | + raise CustomArgumentException.new(1) |
|---|
| 0 | + | + rescue CustomArgumentException => e |
|---|
| 0 | + | + e.val.should == 1 |
|---|
| 0 | + | + end |
|---|
| 0 | + | + end |
|---|
| 0 | + | + |
|---|
| 0 | + | + it "can take an object instance instead of a class to raise as well as a message" do |
|---|
| 0 | + | + begin |
|---|
| 0 | + | + raise CustomArgumentException.new(1), "some text" |
|---|
| 0 | + | + rescue CustomArgumentException => e |
|---|
| 0 | + | + e.val.should == 1 |
|---|
| 0 | + | + e.message.should == "some text" |
|---|
| 0 | + | + end |
|---|
| 0 | + | + end |
|---|
| 0 | + | |
|---|
| 0 | + | it "can rescue multiple raised exceptions with a single rescue block" do |
|---|
| 0 | + | lambda do |
|---|
| 0 | + | -- |
|---|
| 0 | + | 1.6.1.2 |
|---|
| ... | |
|---|