Class: RSpec::Matcher::RescueAndCatch Private
- Inherits:
-
Object
- Object
- RSpec::Matcher::RescueAndCatch
- Defined in:
- lib/rspec/matcher.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Ensures hook is always called and takes care of control jumps.
Instance Attribute Summary collapse
- #catchable ⇒ Object private
- #context ⇒ Object private
- #rescuable ⇒ Object private
- #to_catch ⇒ Object private
- #to_rescue ⇒ Object private
Instance Method Summary collapse
- #catching(catchable, &block) ⇒ Object private private
- #cdo(&block) ⇒ Object private private
- #ensuring(rescuable, &block) ⇒ Object private private
-
#initialize(context, &block) ⇒ RescueAndCatch
constructor
private
A new instance of RescueAndCatch.
- #result ⇒ Object private
Constructor Details
#initialize(context, &block) ⇒ RescueAndCatch
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of RescueAndCatch.
51 52 53 54 |
# File 'lib/rspec/matcher.rb', line 51 def initialize context, &block self.context = context instance_eval(&block) end |
Instance Attribute Details
#catchable ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
49 50 51 |
# File 'lib/rspec/matcher.rb', line 49 def catchable @catchable end |
#context ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
49 50 51 |
# File 'lib/rspec/matcher.rb', line 49 def context @context end |
#rescuable ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
49 50 51 |
# File 'lib/rspec/matcher.rb', line 49 def rescuable @rescuable end |
#to_catch ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
49 50 51 |
# File 'lib/rspec/matcher.rb', line 49 def to_catch @to_catch end |
#to_rescue ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
49 50 51 |
# File 'lib/rspec/matcher.rb', line 49 def to_rescue @to_rescue end |
Instance Method Details
#catching(catchable, &block) ⇒ Object (private)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
70 71 72 73 |
# File 'lib/rspec/matcher.rb', line 70 def catching catchable, &block self.to_catch = block self.catchable = catchable end |
#cdo(&block) ⇒ Object (private)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
80 81 82 |
# File 'lib/rspec/matcher.rb', line 80 def cdo &block context.instance_eval(&block) end |
#ensuring(rescuable, &block) ⇒ Object (private)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
75 76 77 78 |
# File 'lib/rspec/matcher.rb', line 75 def ensuring rescuable, &block self.to_rescue = block self.rescuable = rescuable end |
#result ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/rspec/matcher.rb', line 56 def result r = catch catchable do cdo(&to_catch) end cdo(&to_rescue) r rescue rescuable => e cdo(&to_rescue) raise e end |