Class: RSpec::Matchers::BuiltIn::RaiseError Private
- Inherits:
 - 
      Object
        
- Object
 - RSpec::Matchers::BuiltIn::RaiseError
 
 
- Includes:
 - Composable
 
- Defined in:
 - lib/rspec/matchers/built_in/raise_error.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.
Provides the implementation for raise_error. Not intended to be instantiated directly. rubocop:disable ClassLength rubocop:disable RescueException
Instance Method Summary collapse
- #description ⇒ String private
 - #expects_call_stack_jump? ⇒ Boolean private
 - #failure_message ⇒ String private
 - #failure_message_when_negated ⇒ String private
 - 
  
      #initialize(expected_error_or_message = nil, expected_message = nil, &block)  ⇒ RaiseError 
  
    constructor
  private
    
A new instance of RaiseError.
 - 
  
      #with_message(expected_message)  ⇒ Object 
  
    
Specifies the expected error message.
 
Methods included from Composable
#===, #and, #description_of, #or, should_enumerate?, surface_descriptions_in, unreadable_io?, #values_match?
Constructor Details
#initialize(expected_error_or_message = nil, expected_message = nil, &block) ⇒ RaiseError
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 RaiseError.
      12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28  | 
    
      # File 'lib/rspec/matchers/built_in/raise_error.rb', line 12 def initialize(=nil, =nil, &block) @block = block @actual_error = nil @warn_about_bare_error = .nil? case when nil @expected_error = Exception @expected_message = when String @expected_error = Exception @expected_message = else @expected_error = @expected_message = end end  | 
  
Instance Method Details
#description ⇒ String
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.
      97 98 99  | 
    
      # File 'lib/rspec/matchers/built_in/raise_error.rb', line 97 def description "raise #{expected_error}" end  | 
  
#expects_call_stack_jump? ⇒ Boolean
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.
      79 80 81  | 
    
      # File 'lib/rspec/matchers/built_in/raise_error.rb', line 79 def expects_call_stack_jump? true end  | 
  
#failure_message ⇒ String
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.
      85 86 87  | 
    
      # File 'lib/rspec/matchers/built_in/raise_error.rb', line 85 def @eval_block ? @actual_error. : "expected #{expected_error}#{given_error}" end  | 
  
#failure_message_when_negated ⇒ String
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.
      91 92 93  | 
    
      # File 'lib/rspec/matchers/built_in/raise_error.rb', line 91 def "expected no #{expected_error}#{given_error}" end  | 
  
#with_message(expected_message) ⇒ Object
Specifies the expected error message.
      32 33 34 35 36 37  | 
    
      # File 'lib/rspec/matchers/built_in/raise_error.rb', line 32 def () if @expected_message @warn_about_bare_error = false @expected_message = self end  |