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 +4 -4
- data/lib/watchdoge/configuration.rb +22 -7
- data/lib/watchdoge/rails/railtie.rb +2 -4
- data/lib/watchdoge/regression.rb +16 -8
- data/lib/watchdoge/regression/dsl.rb +13 -6
- data/lib/watchdoge/version.rb +1 -1
- data/lib/watchdoge/worker.rb +10 -13
- data/watchdoge.gemspec +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: '019747f5628db25d05c5c809d2cc66e0963d8ea977f61e2dbbdd322ed3223fea'
|
|
4
|
+
data.tar.gz: ff96d4b7718e406400f989bf2c9b17e8d3ff4e37dd004c92a0d31602162c5c89
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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
|
-
|
|
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
|
-
#
|
|
67
|
-
@
|
|
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
|
data/lib/watchdoge/regression.rb
CHANGED
|
@@ -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
|
|
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.
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
57
|
+
if args[:wait]
|
|
53
58
|
@view_port.merge!({
|
|
54
|
-
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}"
|
data/lib/watchdoge/version.rb
CHANGED
data/lib/watchdoge/worker.rb
CHANGED
|
@@ -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)
|
|
27
|
+
@http.read_timeout = options.delete(:timeout)
|
|
29
28
|
|
|
30
|
-
@
|
|
29
|
+
@browser = options[:browser]
|
|
31
30
|
|
|
32
|
-
|
|
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(
|
|
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,
|
|
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 =
|
|
56
|
-
@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
|
|
105
|
+
def default_browser_profile
|
|
109
106
|
case @browser
|
|
110
107
|
when :chrome
|
|
111
108
|
prefs = {}
|
data/watchdoge.gemspec
CHANGED
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.
|
|
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.
|
|
151
|
+
rubygems_version: 3.0.8
|
|
152
152
|
signing_key:
|
|
153
153
|
specification_version: 4
|
|
154
154
|
summary: dogi
|