Class: Sauce::SauceFacade

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

Overview

wrapps the sauce whick api accessor with sane error handling

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(timeout = 10) ⇒ SauceFacade

Returns a new instance of SauceFacade.



14
15
16
# File 'lib/sauce/sauce_facade.rb', line 14

def initialize(timeout = 10)
  @timeout  = timeout ||= 10
end

Instance Attribute Details

#job_idObject

Returns the value of attribute job_id.



12
13
14
# File 'lib/sauce/sauce_facade.rb', line 12

def job_id
  @job_id
end

#timeoutObject

Returns the value of attribute timeout.



12
13
14
# File 'lib/sauce/sauce_facade.rb', line 12

def timeout
  @timeout
end

Instance Method Details

#fail_jobObject



18
19
20
21
# File 'lib/sauce/sauce_facade.rb', line 18

def fail_job
  requires_job_id
  SauceWhisk::Jobs.fail_job @job_id
end

#fetch_job_dataObject



42
43
44
45
46
47
48
49
50
51
52
# File 'lib/sauce/sauce_facade.rb', line 42

def fetch_job_data
  requires_job_id
  # TODO: let's switch this over to use whisk as well
  # This is used because it's easy to get all the data out of the job
  begin
    job = Sauce::Job.find @job_id
    JSON.parse job.to_json
  rescue StandardError => exception
    puts "An error occured while fetching the job data: #{exception.message}"
  end
end

#fetch_last_screenshotObject



28
29
30
31
32
33
# File 'lib/sauce/sauce_facade.rb', line 28

def fetch_last_screenshot
  requires_job_id
  polling_api_request @timeout do
    SauceWhisk::Jobs.fetch_asset @job_id, 'final_screenshot.png'
  end
end

#fetch_server_logObject



35
36
37
38
39
40
# File 'lib/sauce/sauce_facade.rb', line 35

def fetch_server_log
  requires_job_id
  polling_api_request @timeout do
    SauceWhisk::Jobs.fetch_asset @job_id, 'selenium-server.log'
  end
end

#pass_jobObject



23
24
25
26
# File 'lib/sauce/sauce_facade.rb', line 23

def pass_job
  requires_job_id
  SauceWhisk::Jobs.pass_job @job_id
end