Class: Bucky::TestEquipment::UserOperation::UserOperator

Inherits:
Object
  • Object
show all
Includes:
Utils::BuckyLogger
Defined in:
lib/bucky/test_equipment/user_operation/user_operator.rb

Constant Summary

Constants included from Utils::BuckyLogger

Utils::BuckyLogger::LogFileDir

Instance Method Summary collapse

Methods included from Utils::BuckyLogger

write

Constructor Details

#initialize(args) ⇒ UserOperator

Returns a new instance of UserOperator.



13
14
15
16
# File 'lib/bucky/test_equipment/user_operation/user_operator.rb', line 13

def initialize(args)
  @operation_helper = Bucky::TestEquipment::UserOperation::UserOperationHelper.new(args)
  @pages = args[:pages]
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(operation, test_case_name, **args) ⇒ Object

Call user operation by argument

Parameters:

  • operation (String)
  • test_case_name (String)
  • args (Hash)


22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/bucky/test_equipment/user_operation/user_operator.rb', line 22

def method_missing(operation, test_case_name, **args)
  @operation = operation
  @test_case_name = test_case_name
  Bucky::Utils::BuckyLogger.write(test_case_name, args[:exec])

  # Call method of UserOperationHelper
  return @operation_helper.send(@operation, args[:exec]) if @operation_helper.methods.include?(@operation)

  # Call method of page object
  # e.g) {page: 'top', operation: 'input_freeword', word: 'testing word'}
  return page_method(args[:exec]) if args[:exec].key?(:page) && !args[:exec].key?(:part)

  # Call method of part
  part_mothod(args[:exec]) if args[:exec].key?(:part)
rescue StandardError => e
  Bucky::Core::Exception::WebdriverException.handle(e, "#{args[:step_number]}:#{args[:proc_name]}")
end