Class: Xcmonkey::Xcmonkey

Inherits:
Object
  • Object
show all
Defined in:
lib/xcmonkey.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params) ⇒ Xcmonkey

Returns a new instance of Xcmonkey.



12
13
14
15
16
17
18
# File 'lib/xcmonkey.rb', line 12

def initialize(params)
ensure_required_params(params)
  self.udid = params[:udid]
  self.bundle_id = params[:bundle_id]
  self.duration = params[:duration]
self.driver = Driver.new(params)
end

Instance Attribute Details

#bundle_idObject

Returns the value of attribute bundle_id.



10
11
12
# File 'lib/xcmonkey.rb', line 10

def bundle_id
  @bundle_id
end

#driverObject

Returns the value of attribute driver.



10
11
12
# File 'lib/xcmonkey.rb', line 10

def driver
  @driver
end

#durationObject

Returns the value of attribute duration.



10
11
12
# File 'lib/xcmonkey.rb', line 10

def duration
  @duration
end

#udidObject

Returns the value of attribute udid.



10
11
12
# File 'lib/xcmonkey.rb', line 10

def udid
  @udid
end

Instance Method Details

#ensure_required_params(params) ⇒ Object



33
34
35
36
37
38
39
# File 'lib/xcmonkey.rb', line 33

def ensure_required_params(params)
  Logger.error('UDID should be provided') if params[:udid].nil?
  Logger.error('Bundle identifier should be provided') if params[:bundle_id].nil?
  if params[:duration].nil? || !params[:duration].kind_of?(Integer) || !params[:duration].positive?
    Logger.error('Duration must be Integer and not less than 1 second')
  end
end

#gesturesObject



29
30
31
# File 'lib/xcmonkey.rb', line 29

def gestures
  [:precise_tap, :blind_tap, :swipe]
end

#runObject



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

def run
      driver.ensure_device_exists
      driver.ensure_app_installed
      driver.terminate_app
      driver.open_home_screen(return_tracker: true)
      driver.launch_app
      driver.monkey_test(gestures)
end