class IntegrationDiff::Runner
Attributes
browser[RW]
browser_version[RW]
device[RW]
device_name[RW]
os[RW]
os_version[RW]
Public Class Methods
instance()
click to toggle source
# File lib/integration_diff/runner.rb, line 11 def self.instance @runner ||= Runner.new(IntegrationDiff.project_name, IntegrationDiff.javascript_driver) end
new(project_name, javascript_driver)
click to toggle source
# File lib/integration_diff/runner.rb, line 19 def initialize(project_name, javascript_driver) @project_name = project_name @javascript_driver = javascript_driver dir = IntegrationDiff::Utils.images_dir Dir.mkdir('tmp') unless Dir.exist?('tmp') Dir.mkdir(dir) unless Dir.exist?(dir) self.browser = 'firefox' self.device = 'desktop' self.os = 'linux' end
Public Instance Methods
screenshot(identifier)
click to toggle source
# File lib/integration_diff/runner.rb, line 51 def screenshot(identifier) raise 'no browser information provided' if browser.nil? raise 'no device information provided' if device.nil? raise 'no os information provided' if os.nil? screenshot_name = IntegrationDiff::Utils.image_file(identifier) page.save_screenshot(screenshot_name, full: true) @uploader.enqueue(identifier, browser, device, os, browser_version, device_name, os_version) end
start_run()
click to toggle source
TODO: Improve error handling here for network timeouts
# File lib/integration_diff/runner.rb, line 33 def start_run draft_run @uploader = IntegrationDiff::Uploader.build(@run_id) rescue StandardError => e IntegrationDiff.logger.fatal e.message raise e end
wrap_run()
click to toggle source
TODO: Improve error handling here for network timeouts
# File lib/integration_diff/runner.rb, line 42 def wrap_run @uploader.wrapup complete_run if @run_id rescue StandardError => e IntegrationDiff.logger.fatal e.message raise e end
Private Instance Methods
complete_run()
click to toggle source
# File lib/integration_diff/runner.rb, line 79 def complete_run connection.put("/api/v1/runs/#{@run_id}/status", status: "completed") end
connection()
click to toggle source
# File lib/integration_diff/runner.rb, line 83 def connection @connection ||= IntegrationDiff::Utils.connection end
draft_run()
click to toggle source
# File lib/integration_diff/runner.rb, line 64 def draft_run run_name = @project_name + "-" + Time.now.iso8601 details = IntegrationDiff::RunDetails.new.details branch = details.branch author = details.author project = @project_name response = connection.post('/api/v1/runs', name: run_name, project: project, group: branch, author: author, js_driver: @javascript_driver) @run_id = JSON.parse(response.body)["id"] end