Class: TestRunner::Example
- Inherits:
 - 
      Object
      
        
- Object
 - TestRunner::Example
 
 
- Defined in:
 - lib/test-runner/example.rb
 
Instance Attribute Summary collapse
- #group ⇒ ExampleGroup readonly
 - #message ⇒ String readonly
 
Instance Method Summary collapse
- #evaluate ⇒ Object
 - #evaluate? ⇒ Boolean
 - #full_message ⇒ Object
 - 
  
    
      #initialize(group, message, pending: false, skip: false, &block)  ⇒ Example 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    
A new instance of Example.
 - #pending? ⇒ Boolean
 - #reason ⇒ Object
 - #set_pending ⇒ Object protected
 - #set_skip ⇒ Object protected
 - #skip? ⇒ Boolean
 
Constructor Details
#initialize(group, message, pending: false, skip: false, &block) ⇒ Example
Returns a new instance of Example.
      9 10 11 12 13 14 15  | 
    
      # File 'lib/test-runner/example.rb', line 9 def initialize(group, , pending: false, skip: false, &block) @group = group @message = @pending = pending @skip = skip @block = block end  | 
  
Instance Attribute Details
#group ⇒ ExampleGroup (readonly)
      4 5 6  | 
    
      # File 'lib/test-runner/example.rb', line 4 def group @group end  | 
  
#message ⇒ String (readonly)
      7 8 9  | 
    
      # File 'lib/test-runner/example.rb', line 7 def @message end  | 
  
Instance Method Details
#evaluate ⇒ Object
      41 42 43 44 45 46 47 48 49 50 51 52 53 54 55  | 
    
      # File 'lib/test-runner/example.rb', line 41 def evaluate t1 = Time.now begin catch(:skip) do @block.call end rescue StandardError, RSpec::Expectations::ExpectationNotMetError => e ExampleResult.new(self, Time.now - t1, e) else ExampleResult.new(self, Time.now - t1) ensure @block = nil end end  | 
  
#evaluate? ⇒ Boolean
      25 26 27  | 
    
      # File 'lib/test-runner/example.rb', line 25 def evaluate? !skip? end  | 
  
#full_message ⇒ Object
      29 30 31  | 
    
      # File 'lib/test-runner/example.rb', line 29 def "#{group.} #{}" end  | 
  
#pending? ⇒ Boolean
      17 18 19  | 
    
      # File 'lib/test-runner/example.rb', line 17 def pending? @pending end  | 
  
#reason ⇒ Object
      33 34 35 36 37 38 39  | 
    
      # File 'lib/test-runner/example.rb', line 33 def reason if @pending @pending.is_a?(String) ? @pending : 'Example is pending' elsif @skip @skip.is_a?(String) ? @skip : 'Example is skipped' end end  | 
  
#set_pending ⇒ Object (protected)
      59 60 61  | 
    
      # File 'lib/test-runner/example.rb', line 59 def set_pending @pending = true end  | 
  
#set_skip ⇒ Object (protected)
      63 64 65  | 
    
      # File 'lib/test-runner/example.rb', line 63 def set_skip @skip = true end  | 
  
#skip? ⇒ Boolean
      21 22 23  | 
    
      # File 'lib/test-runner/example.rb', line 21 def skip? @skip end  |