Class: IntegrationDiff::Runner

Inherits:
Object
  • Object
show all
Includes:
Capybara::DSL
Defined in:
lib/integration_diff/runner.rb

Constant Summary collapse

DIR =
'tmp/idff_images'

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(base_uri, project_name, javascript_driver) ⇒ Runner

Returns a new instance of Runner.



16
17
18
19
20
21
# File 'lib/integration_diff/runner.rb', line 16

def initialize(base_uri, project_name, javascript_driver)
  @base_uri = base_uri
  @project_name = project_name
  @javascript_driver = javascript_driver
  Dir.mkdir(DIR) unless Dir.exist?(DIR)
end

Class Method Details

.instanceObject



10
11
12
13
14
# File 'lib/integration_diff/runner.rb', line 10

def self.instance
  @runner ||= Runner.new(IntegrationDiff.base_uri,
                         IntegrationDiff.project_name,
                         IntegrationDiff.javascript_driver)
end

Instance Method Details

#screenshot(identifier) ⇒ Object



44
45
46
47
48
# File 'lib/integration_diff/runner.rb', line 44

def screenshot(identifier)
  screenshot_name = image_file(identifier)
  page.save_screenshot(screenshot_name, full: true)
  @identifiers << identifier
end

#start_runObject

TODO: Improve error handling here for network timeouts



24
25
26
27
28
29
30
# File 'lib/integration_diff/runner.rb', line 24

def start_run
  @identifiers = []
  draft_run
rescue StandardError => e
  IntegrationDiff.logger.fatal e.message
  raise e
end

#wrap_runObject

TODO: Improve error handling here for network timeouts



33
34
35
36
37
38
39
40
41
42
# File 'lib/integration_diff/runner.rb', line 33

def wrap_run
  @identifiers.each do |identifier|
    upload_image(identifier)
  end

  finalize_run if @run_id
rescue StandardError => e
  IntegrationDiff.logger.fatal e.message
  raise e
end