Module: Gauge::Processors Private

Includes:
ExecutionHandler
Included in:
MessageProcessor
Defined in:
lib/processors/kill_request_processor.rb,
lib/processors/execution_handler.rb,
lib/processors/datastore_init_processor.rb,
lib/processors/execution_hook_processors.rb,
lib/processors/step_name_request_processor.rb,
lib/processors/step_names_request_processor.rb,
lib/processors/execute_step_request_processor.rb,
lib/processors/refactor_step_request_processor.rb,
lib/processors/step_validation_request_processor.rb

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Defined Under Namespace

Modules: ExecutionHandler

Instance Method Summary collapse

Methods included from ExecutionHandler

#create_param_values, #handle_failure, #handle_hooks_execution, #handle_pass, #screenshot_bytes, #time_elapsed_since

Instance Method Details

#process_datastore_init(message) ⇒ 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.



23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/processors/datastore_init_processor.rb', line 23

def process_datastore_init(message)
  case message.messageType
    when Messages::Message::MessageType::SuiteDataStoreInit
      DataStoreFactory.suite_datastore.clear
    when Messages::Message::MessageType::SpecDataStoreInit
      DataStoreFactory.spec_datastore.clear
    when Messages::Message::MessageType::ScenarioDataStoreInit
      DataStoreFactory.scenario_datastore.clear
  end
  execution_status_response = Messages::ExecutionStatusResponse.new(:executionResult => Messages::ProtoExecutionResult.new(:failed => false, :executionTime => 0))
  Messages::Message.new(:messageType => Messages::Message::MessageType::ExecutionStatusResponse, :messageId => message.messageId, :executionStatusResponse => execution_status_response)
end

#process_execute_step_request(message) ⇒ 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.



24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/processors/execute_step_request_processor.rb', line 24

def process_execute_step_request(message)
  step_text = message.executeStepRequest.parsedStepText
  parameters = message.executeStepRequest.parameters
  args = create_param_values parameters
  start_time= Time.now
  begin
    Executor.execute_step step_text, args
  rescue Exception => e
    return handle_failure message, e, time_elapsed_since(start_time)
  end
  handle_pass message, time_elapsed_since(start_time)
end

#process_execution_end_request(message) ⇒ 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.



28
29
30
# File 'lib/processors/execution_hook_processors.rb', line 28

def process_execution_end_request(message)
  handle_hooks_execution(MethodCache.get_after_suite_hooks, message, message.executionEndingRequest.currentExecutionInfo)
end

#process_execution_start_request(message) ⇒ 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.



24
25
26
# File 'lib/processors/execution_hook_processors.rb', line 24

def process_execution_start_request(message)
  handle_hooks_execution(MethodCache.get_before_suite_hooks, message, message.executionStartingRequest.currentExecutionInfo)
end

#process_kill_processor_request(message) ⇒ 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.



21
22
23
# File 'lib/processors/kill_request_processor.rb', line 21

def process_kill_processor_request(message)
  return message
end

#process_scenario_execution_end_request(message) ⇒ 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.



44
45
46
# File 'lib/processors/execution_hook_processors.rb', line 44

def process_scenario_execution_end_request(message)
  handle_hooks_execution(MethodCache.get_after_scenario_hooks, message, message.scenarioExecutionEndingRequest.currentExecutionInfo)
end

#process_scenario_execution_start_request(message) ⇒ 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.



40
41
42
# File 'lib/processors/execution_hook_processors.rb', line 40

def process_scenario_execution_start_request(message)
  handle_hooks_execution(MethodCache.get_before_scenario_hooks, message, message.scenarioExecutionStartingRequest.currentExecutionInfo)
end

#process_spec_execution_end_request(message) ⇒ 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.



36
37
38
# File 'lib/processors/execution_hook_processors.rb', line 36

def process_spec_execution_end_request(message)
  handle_hooks_execution(MethodCache.get_after_spec_hooks, message, message.specExecutionEndingRequest.currentExecutionInfo)
end

#process_spec_execution_start_request(message) ⇒ 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.



32
33
34
# File 'lib/processors/execution_hook_processors.rb', line 32

def process_spec_execution_start_request(message)
  handle_hooks_execution(MethodCache.get_before_spec_hooks, message, message.specExecutionStartingRequest.currentExecutionInfo)
end

#process_step_execution_end_request(message) ⇒ 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.



52
53
54
# File 'lib/processors/execution_hook_processors.rb', line 52

def process_step_execution_end_request(message)
  handle_hooks_execution(MethodCache.get_after_step_hooks, message, message.stepExecutionEndingRequest.currentExecutionInfo)
end

#process_step_execution_start_request(message) ⇒ 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.



48
49
50
# File 'lib/processors/execution_hook_processors.rb', line 48

def process_step_execution_start_request(message)
  handle_hooks_execution(MethodCache.get_before_step_hooks, message, message.stepExecutionStartingRequest.currentExecutionInfo)
end

#process_step_name_request(message) ⇒ 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.



20
21
22
23
24
25
26
27
# File 'lib/processors/step_name_request_processor.rb', line 20

def process_step_name_request(message)
  parsed_step_text = message.stepNameRequest.stepValue
  is_valid = MethodCache.valid_step?(parsed_step_text)
  step_text = is_valid ? MethodCache.get_step_text(parsed_step_text) : ""
  has_alias = MethodCache.has_alias?(step_text)
  get_step_name_response = Messages::StepNameResponse.new(isStepPresent: is_valid, stepName: [step_text], hasAlias: has_alias)
  Messages::Message.new(:messageType => Messages::Message::MessageType::StepNameResponse, :messageId => message.messageId, :stepNameResponse => get_step_name_response)
end

#process_step_names_request(message) ⇒ 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.



20
21
22
23
24
# File 'lib/processors/step_names_request_processor.rb', line 20

def process_step_names_request(message)
  step_names_response = Messages::StepNamesResponse.new(:steps => MethodCache.all_steps)
  Messages::Message.new(:messageType => Messages::Message::MessageType::StepNamesResponse,
    :messageId => message.messageId, :stepNamesResponse => step_names_response)
end

#process_step_validation_request(message) ⇒ 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.



20
21
22
23
24
25
26
27
28
# File 'lib/processors/step_validation_request_processor.rb', line 20

def process_step_validation_request(message)
  step_validate_request = message.stepValidateRequest
  is_valid = MethodCache.valid_step?(step_validate_request.stepText)
  step_validate_response = Messages::StepValidateResponse.new(:isValid => is_valid,
    :errorMessage => is_valid ? "" : "Step implementation not found")
  Messages::Message.new(:messageType => Messages::Message::MessageType::StepValidateResponse,
    :messageId => message.messageId, 
    :stepValidateResponse => step_validate_response)
end

#refactor_step(message) ⇒ 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.



22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/processors/refactor_step_request_processor.rb', line 22

def refactor_step(message)
  oldStepValue = message.refactorRequest.oldStepValue.stepValue
  newStep = message.refactorRequest.newStepValue
  stepBlock = MethodCache.get_step oldStepValue
  refactor_response = Messages::RefactorResponse.new(success: true)
  begin
    CodeParser.refactor stepBlock, message.refactorRequest.paramPositions, newStep.parameters, newStep.parameterizedStepValue
  rescue Exception => e
    refactor_response.success=false
    refactor_response.error=e.message
  end
  Messages::Message.new(:messageType => Messages::Message::MessageType::RefactorResponse, :messageId => message.messageId, refactorResponse: refactor_response)
end