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.


44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/watchdoge/regression.rb', line 44

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_options =
    WatchDoge.configuration.default_worker_options.merge WatchDoge.configuration.worker_options

  @worker = WatchDoge::Worker.new @scenario_name, worker_options.dup

  @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
37
38
39
40
41
# File 'lib/watchdoge/regression.rb', line 22

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

  Dir["#{WatchDoge::Regression::Utils.scenarios_dir}/*"].each do |scenario_path|
    mgr = self.new scenario_path, regression_flag: regression_flag

    WatchDoge.hooks.before_scenario.each { |t| mgr.instance_exec &t }

    if WatchDoge.hooks.around_scenario
      WatchDoge.hooks.around_scenario.call(Proc.new { mgr.eval_scenario })
    else
      mgr.eval_scenario
    end

    WatchDoge.hooks.after_scenario.each { |t| mgr.instance_exec &t }
  end

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

Instance Method Details

#eval_scenarioObject


60
61
62
63
64
65
66
# File 'lib/watchdoge/regression.rb', line 60

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

#reference_imageObject


68
69
70
# File 'lib/watchdoge/regression.rb', line 68

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