Class: Maximus::Wraith

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

Overview

Generates screenshots for visual regression testing

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

#discover_path, #edit_yaml, #file_count, #file_list, #is_middleman?, #is_rails?, #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

Runs Wraith through command line WARNING: If you call this class from a script,

you should delete the images generated after they've been
created.

Examples:

removing images after run

dest = '/desired/root/directory'
wraith_pics = Maximus::Wraith.new.result
wraith_pics.each do |path_label, data|
  data[:images].each do |image|
    moved_image = "#{dest}/#{File.basename(image)}"
    FileUtils.mv image, moved_image, force: true
  end
end

See Also:

Since:

  • 0.1.0



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/maximus/statistics/wraith.rb', line 21

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.
  # @yieldparam browser [String] headless browser name
  # @yieldparam configpath [String] path to temp config file (see Config#wraith_setup)
  @settings[:wraith].each { |browser, configpath| wraith_report(browser, configpath) }

  @output

end