Class: Quke::BrowserstackStatusReporter
- Inherits:
 - 
      Object
      
        
- Object
 - Quke::BrowserstackStatusReporter
 
 
- Defined in:
 - lib/quke/browserstack_status_reporter.rb
 
Overview
Used to update the status of a session in Browserstack to mark it as passed or failed. It does this by making a PUT request to Browserstack’s REST API requesting the status of a specified session is set to ‘passed’ or ‘failed’ (only those values are accepted).
www.browserstack.com/automate/rest-api
A session ID is only available when we configure Quke to work with Browserstack, and can only be obtained when in the context of running a scenario. It’s unique to the overall session (it doesn’t change for each scenario or feature), but we have to set it as a global variable in after_hook.rb in order to access it in the after_exit block in env.rb
Instance Method Summary collapse
- 
  
    
      #failed(session_id)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Connects to the Browserstack REST API and makes a PUT request to update the session with the matching
session_idto ‘failed’. - 
  
    
      #initialize(config)  ⇒ BrowserstackStatusReporter 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    
Initialize’s the instance based in the
Quke::BrowserstackConfigurationinstance passed in. - 
  
    
      #passed(session_id)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Connects to the Browserstack REST API and makes a PUT request to update the session with the matching
session_idto ‘passed’. 
Constructor Details
#initialize(config) ⇒ BrowserstackStatusReporter
Initialize’s the instance based in the Quke::BrowserstackConfiguration instance passed in.
The values its interested in are username and auth_key as it will use these to authenticate with Browserstacks REST API.
      24 25 26 27  | 
    
      # File 'lib/quke/browserstack_status_reporter.rb', line 24 def initialize(config) @username = config.username @auth_key = config.auth_key end  | 
  
Instance Method Details
#failed(session_id) ⇒ Object
Connects to the Browserstack REST API and makes a PUT request to update the session with the matching session_id to ‘failed’.
It returns a string which can be used as a message for output confirming the action.
      44 45 46 47  | 
    
      # File 'lib/quke/browserstack_status_reporter.rb', line 44 def failed(session_id) check_before_update(session_id, status: "failed") "Browserstack session #{session_id} status set to \e[31mfailed\e[0m 😢" end  | 
  
#passed(session_id) ⇒ Object
Connects to the Browserstack REST API and makes a PUT request to update the session with the matching session_id to ‘passed’.
It returns a string which can be used as a message for output confirming the action.
      34 35 36 37  | 
    
      # File 'lib/quke/browserstack_status_reporter.rb', line 34 def passed(session_id) check_before_update(session_id, status: "passed") "Browserstack session #{session_id} status set to \e[32mpassed\e[0m 😀" end  |