watchdoge 0.1.22 → 0.1.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f9a6deaa86f5be34f6897add857e7fa2d045f26944ca58330f65a5a69fc353b3
4
- data.tar.gz: 4e157ff755b3c1067cb058bc2479f3cbdd243a8edeef89018d31874e2f0447df
3
+ metadata.gz: '019747f5628db25d05c5c809d2cc66e0963d8ea977f61e2dbbdd322ed3223fea'
4
+ data.tar.gz: ff96d4b7718e406400f989bf2c9b17e8d3ff4e37dd004c92a0d31602162c5c89
5
5
  SHA512:
6
- metadata.gz: 2e28048bc379d80f8a20349fd1a80ff38243846cff19f36430c22b58d335554724f8ab608225efd8b28cda4cd5537a19d095b9321e89e207a3e2bb362878ddf4
7
- data.tar.gz: 9414cbb506b2e92def9555e696ab0dfd2fe7d0756a4ae65363002ae8f4e5949a572a6cb53b28495f738861869f5b700ac15b534d714b0d6f43459f9784d1180e
6
+ metadata.gz: bfb7070e7f412f24a206cb41493c9771a039723f6d55440b46923cce3df8e0c3f84225cde5cbb6f25f34dd6399b67ee218005dbeaf38e1f50b0a3a37a862dbcd
7
+ data.tar.gz: 669fc2e2e3836d2daeaf0dbd0251b963628628053b52c76716d8b173d7d15ccace383aec14321ef0e7b6382b1cf11a7a11130d891f6f59994e052c04e2d2da32
@@ -17,12 +17,14 @@ module WatchDoge
17
17
  attr_accessor :after_regression
18
18
  attr_accessor :before_scenario
19
19
  attr_accessor :after_scenario
20
+ attr_accessor :around_scenario
20
21
 
21
22
  def initialize
22
23
  @before_regression = []
23
24
  @after_regression = []
24
25
  @before_scenario = []
25
26
  @after_scenario = []
27
+ @around_scenario = nil
26
28
  end
27
29
  end
28
30
 
@@ -31,9 +33,10 @@ module WatchDoge
31
33
  attr_accessor :web_drivers_dir
32
34
 
33
35
  attr_accessor :engine
34
- attr_accessor :browser
35
36
  attr_accessor :cookie_pool
36
- attr_accessor :http_timeout
37
+
38
+ attr_reader :default_worker_options
39
+ attr_accessor :worker_options
37
40
 
38
41
  attr_accessor :notifications
39
42
 
@@ -63,15 +66,27 @@ module WatchDoge
63
66
  # framwork that Worker used, default to selenium
64
67
  @engine = Watir::Browser
65
68
 
66
- # default browser used by engine
67
- @browser = :firefox
69
+ # options for worker
70
+ @default_worker_options = {
71
+ # default window-size of worker
72
+ width: 1280,
73
+ height: 768,
74
+
75
+ # using Firfox as default browser
76
+ browser: :firefox,
77
+
78
+ # default to headless
79
+ headless: true,
80
+
81
+ # connection timeout threshold(seconds)
82
+ timeout: 120
83
+ }
84
+
85
+ @worker_options = {}
68
86
 
69
87
  # where all cookie saved (as yaml)
70
88
  @cookie_pool = @base_dir + '/.doge_cookie'
71
89
 
72
- # connection timeout threshold(seconds)
73
- @http_timeout = 120
74
-
75
90
  # map of notification sources
76
91
  # key: must be stringify of its class name
77
92
  # value: hash struct, will passed to constructor while push message
@@ -6,17 +6,15 @@ module WatchDoge
6
6
  namespace :watchdoge do
7
7
  desc "generating reference images"
8
8
  task :capture => :environment do
9
+ WatchDoge.initialize!
9
10
  WatchDoge::Regression::Manager.run_all_scenarios :capture
10
11
  end
11
12
  desc "scrap screenshots and compare with reference images"
12
13
  task :test => :environment do
14
+ WatchDoge.initialize!
13
15
  WatchDoge::Regression::Manager.run_all_scenarios :test
14
16
  end
15
17
  end
16
18
  end
17
-
18
- initializer "watchdoge.initialize" do |app|
19
- WatchDoge.initialize!
20
- end
21
19
  end
22
20
  end
@@ -20,18 +20,23 @@ module WatchDoge
20
20
 
21
21
  class << self
22
22
  def run_all_scenarios regression_flag
23
- WatchDoge.hooks.before_regression.each { |t| t.call }
23
+ WatchDoge.hooks.before_regression.each { |t| instance_exec &t }
24
24
 
25
25
  Dir["#{WatchDoge::Regression::Utils.scenarios_dir}/*"].each do |scenario_path|
26
- WatchDoge.hooks.before_scenario.each { |t| t.call }
27
-
28
26
  mgr = self.new scenario_path, regression_flag: regression_flag
29
- mgr.eval_scenario
30
27
 
31
- WatchDoge.hooks.after_scenario.each { |t| t.call }
28
+ WatchDoge.hooks.before_scenario.each { |t| mgr.instance_exec &t }
29
+
30
+ if WatchDoge.hooks.around_scenario
31
+ WatchDoge.hooks.around_scenario.call(Proc.new { mgr.eval_scenario })
32
+ else
33
+ mgr.eval_scenario
34
+ end
35
+
36
+ WatchDoge.hooks.after_scenario.each { |t| mgr.instance_exec &t }
32
37
  end
33
38
 
34
- WatchDoge.hooks.after_regression.each { |t| t.call }
39
+ WatchDoge.hooks.after_regression.each { |t| instance_exec &t }
35
40
  WatchDoge::Notification.flush
36
41
  end
37
42
  end
@@ -44,14 +49,17 @@ module WatchDoge
44
49
  @setup_proc = nil
45
50
  @teardown_proc = nil
46
51
 
47
- @worker = WatchDoge::Worker.new @scenario_name
52
+ worker_options =
53
+ WatchDoge.configuration.default_worker_options.merge WatchDoge.configuration.worker_options
54
+
55
+ @worker = WatchDoge::Worker.new @scenario_name, worker_options.dup
48
56
 
49
57
  @view_port = {}
50
58
  end
51
59
 
52
60
  def eval_scenario
53
61
  puts "scenario: #{@scenario_name} begin"
54
- eval File.read(@scenario_path)
62
+ instance_eval File.read(@scenario_path), @scenario_path
55
63
  @worker.close
56
64
  puts "scenario: #{@scenario_name} end\n"
57
65
  puts ""
@@ -13,7 +13,14 @@ module WatchDoge
13
13
  def use browser
14
14
  puts "[use] browser #{browser}"
15
15
  @worker.close
16
- @worker = WatchDoge::Worker.new @scenario_name, browser: browser
16
+
17
+ worker_options =
18
+ WatchDoge.configuration.default_worker_options.merge WatchDoge.configuration.worker_options
19
+
20
+ worker_options = worker_options.dup
21
+ worker_options[:browser] = browser
22
+
23
+ @worker = WatchDoge::Worker.new @scenario_name, worker_options
17
24
  end
18
25
 
19
26
  def sign_in_as resoruce
@@ -42,20 +49,20 @@ module WatchDoge
42
49
  @setup_proc.call if @setup_proc
43
50
 
44
51
  args = {
45
- before: nil
52
+ wait: nil
46
53
  }.merge(kwargs)
47
54
 
48
- args[:before].call if args[:before]
49
-
50
55
  @worker.goto path
51
56
 
52
- if kwargs[:wait]
57
+ if args[:wait]
53
58
  @view_port.merge!({
54
- wait: kwargs[:wait]
59
+ wait: args[:wait]
55
60
  })
56
61
  end
57
62
 
58
63
  @worker.resize_by_viewport(@view_port) do
64
+ yield(@worker) if block_given?
65
+
59
66
  case @regression_flag
60
67
  when :capture
61
68
  puts " -> make reference images on worker #{@worker}"
@@ -1,4 +1,4 @@
1
1
  # Version of WatchDoge
2
2
  module WatchDoge
3
- VERSION = '0.1.22'
3
+ VERSION = '0.1.27'
4
4
  end
@@ -20,27 +20,24 @@ module WatchDoge
20
20
  # 2. height: browser's height, default to 768
21
21
  # 3. http_client: instance of Selenium::WebDriver::Remote::Http
22
22
  # 4. all acceptable arguments of Watir::Browser class
23
- def initialize uid, options={}
23
+ def initialize uid, options
24
24
  @http = Selenium::WebDriver::Remote::Http::Default.new
25
- @browser = WatchDoge.configuration.browser
26
25
 
27
26
  # HTTP timeout default to 120 sec
28
- @http.read_timeout = options.delete(:timeout) || WatchDoge.configuration.http_timeout
27
+ @http.read_timeout = options.delete(:timeout)
29
28
 
30
- @uid = uid
29
+ @browser = options[:browser]
31
30
 
32
- default_options = {
33
- width: 1280,
34
- height: 768,
35
- headless: true,
31
+ @uid = uid
36
32
 
33
+ options = {
37
34
  # Selenium HTTP configuration
38
35
  http_client: @http
39
- }.merge(options).merge(browser_profile)
36
+ }.merge(options).merge(default_browser_profile)
40
37
 
41
38
  # intall required version driver
42
39
  WatchDoge::WebdriverManager.new @browser
43
- @core = WatchDoge.configuration.engine.new @browser, default_options
40
+ @core = WatchDoge.configuration.engine.new @browser, options
44
41
 
45
42
  # for generate uri hash
46
43
  @landed_page = nil
@@ -52,8 +49,8 @@ module WatchDoge
52
49
  @cookie_loaded = false
53
50
 
54
51
  # width/height
55
- @width = default_options[:width]
56
- @height = default_options[:height]
52
+ @width = options[:width]
53
+ @height = options[:height]
57
54
  @core.window.resize_to @width, @height
58
55
  end
59
56
 
@@ -105,7 +102,7 @@ module WatchDoge
105
102
 
106
103
  private
107
104
 
108
- def browser_profile
105
+ def default_browser_profile
109
106
  case @browser
110
107
  when :chrome
111
108
  prefs = {}
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'watchdoge'
3
- s.version = '0.1.22'
3
+ s.version = '0.1.27'
4
4
  s.date = '2019-07-22'
5
5
  s.summary = "dogi"
6
6
  s.description = "WatchDoge is Ruby on Rails friendly frontend regression test tool"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: watchdoge
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.22
4
+ version: 0.1.27
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shen Lee
@@ -148,7 +148,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
148
148
  - !ruby/object:Gem::Version
149
149
  version: '0'
150
150
  requirements: []
151
- rubygems_version: 3.0.3
151
+ rubygems_version: 3.0.8
152
152
  signing_key:
153
153
  specification_version: 4
154
154
  summary: dogi