Class: RSpec::Matcher::RescueAndCatch Private

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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

#catchableObject

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

#contextObject

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

#rescuableObject

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_catchObject

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_rescueObject

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

#resultObject

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