Class: Maximus::Wraith

Inherits:
Statistic show all
Defined in:
lib/maximus/statistics/wraith.rb

Overview

Since:

  • 0.1.0

Instance Attribute Summary

Attributes inherited from Statistic

#output

Instance Method Summary collapse

Methods inherited from Statistic

#initialize

Methods included from Helper

#check_default_config_path, #edit_yaml, #file_count, #file_list, #is_rails?, #lines_added_to_range, #node_module_exists, #path_exists, #prompt, #reporter_path, #root_dir, #truthy

Constructor Details

This class inherits a constructor from Maximus::Statistic

Instance Method Details

#resultObject

By default checks homepage Requires config to be in config/wraith/history.yaml Adds a new config/wraith/history.yaml if not present Path should be an Array defined as [{ label: url }]

See Also:

Since:

  • 0.1.0


10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/maximus/statistics/wraith.rb', line 10

def result

  return if @settings[:wraith].blank?

  node_module_exists('phantomjs', 'brew install')

  puts 'Starting visual regression tests with wraith...'.color(:blue)

  # Run history or latest depending on the existence of a history directory as defined
  #   in each wraith config file.
  #
  # @todo this doesn't work very well. It puts the new shots in the history folder,
  #   even with absolute paths. Could be a bug in wraith
  #
  # @yieldparam browser [String] headless browser name
  # @yieldparam configpath [String] path to temp config file (see Config#wraith_setup)
  @settings[:wraith].each do |browser, configpath|
    wraith_yaml = YAML.load_file(configpath)
    if File.directory?("#{@settings[:root_dir]}/#{wraith_yaml['history_dir']}")
      puts `wraith latest #{configpath}`
    else
      puts `wraith history #{configpath}`
    end
    File.write('said.yml', wraith_yaml.to_yaml)
    File.delete(configpath)
    wraith_parse browser
  end

end