Class: WatchDoge::Regression::Manager

Inherits:
Object
  • Object
show all
Includes:
DSL
Defined in:
lib/watchdoge/regression.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from DSL

#compare, #setup, #sign_in_as, #teardown, #use, #with_viewport

Constructor Details

#initialize(scenario_path, regression_flag:) ⇒ Manager

Returns a new instance of Manager.



39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/watchdoge/regression.rb', line 39

def initialize scenario_path, regression_flag:
  @scenario_path = scenario_path
  @scenario_name = File.basename @scenario_path, '.rb'
  @regression_flag = regression_flag

  @setup_proc = nil
  @teardown_proc = nil

  @worker = WatchDoge::Worker.new @scenario_name

  @view_port = {}
end

Class Method Details

.run_all_scenarios(regression_flag) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/watchdoge/regression.rb', line 22

def run_all_scenarios regression_flag
  WatchDoge.hooks.before_regression.each { |t| t.call }

  Dir["#{WatchDoge::Regression::Utils.scenarios_dir}/*"].each do |scenario_path|
    WatchDoge.hooks.before_scenario.each { |t| t.call }

    mgr = self.new scenario_path, regression_flag: regression_flag
    mgr.eval_scenario

    WatchDoge.hooks.after_scenario.each { |t| t.call }
  end

  WatchDoge.hooks.after_regression.each { |t| t.call }
  WatchDoge::Notification.flush
end

Instance Method Details

#eval_scenarioObject



52
53
54
55
56
57
58
# File 'lib/watchdoge/regression.rb', line 52

def eval_scenario
  puts "scenario: #{@scenario_name} begin"
  eval File.read(@scenario_path)
  @worker.close
  puts "scenario: #{@scenario_name} end\n"
  puts ""
end

#reference_imageObject



60
61
62
# File 'lib/watchdoge/regression.rb', line 60

def reference_image
  WatchDoge::Regression::Utils.reference_dir + "/#{@scenario_name}/#{@reference_file_name}.png"
end