watchdoge 0.1.24 → 0.1.25

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4a16fc3b9ab93bf0330328330314535ad9a74bc18caec50daf8327872564d4db
4
- data.tar.gz: 28fa4084a510d0413af4d1d579e3ece2bcc480c7ca68c783a380587ac1d3f991
3
+ metadata.gz: 82f7faeabe1627ca97fb027c5b6dd4273d89f992a5f838a514b0df8202182382
4
+ data.tar.gz: 71d1cf9249ecb4696afdca3b815ed0c718f9a704010a245957cb1d1ecff8d480
5
5
  SHA512:
6
- metadata.gz: '0999541a4012b25df6c64531f510279cf9509ccfccbdb98457b146a05eb51f3d4f1bacc96f96bcf659563010d558b64285229a9740fa100bc3763cf7bfaf1df6'
7
- data.tar.gz: 1a7dc9b351fac103e1ee413bad479b3a805738f27818bdb505b4779063c74be55db38aff88fdb3d8325904fc0ee3d8265054ba8108dee3d5dc814cbdf36b25aa
6
+ metadata.gz: d9fc30e9d5ccc14002589d234f1a838fcde272179966c6589829b4c56a509c3611ce085626560a1325cba14c327fc8cb6c26c019c4185f9e417aadcc71c470f0
7
+ data.tar.gz: 7a0a333d68d915e269ea86b8955649463e2f288ff140ff094a91efa7816b44d558191cacdd0e473a012bceeef0dc04063f2235fd037e9602532e9c91683d72b6
@@ -33,9 +33,10 @@ module WatchDoge
33
33
  attr_accessor :web_drivers_dir
34
34
 
35
35
  attr_accessor :engine
36
- attr_accessor :browser
37
36
  attr_accessor :cookie_pool
38
- attr_accessor :http_timeout
37
+
38
+ attr_reader :default_worker_options
39
+ attr_accessor :worker_options
39
40
 
40
41
  attr_accessor :notifications
41
42
 
@@ -65,15 +66,27 @@ module WatchDoge
65
66
  # framwork that Worker used, default to selenium
66
67
  @engine = Watir::Browser
67
68
 
68
- # default browser used by engine
69
- @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 = {}
70
86
 
71
87
  # where all cookie saved (as yaml)
72
88
  @cookie_pool = @base_dir + '/.doge_cookie'
73
89
 
74
- # connection timeout threshold(seconds)
75
- @http_timeout = 120
76
-
77
90
  # map of notification sources
78
91
  # key: must be stringify of its class name
79
92
  # value: hash struct, will passed to constructor while push message
@@ -23,17 +23,17 @@ module WatchDoge
23
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| instance_exec &t }
27
-
28
26
  mgr = self.new scenario_path, regression_flag: regression_flag
29
27
 
28
+ WatchDoge.hooks.before_scenario.each { |t| mgr.instance_exec &t }
29
+
30
30
  if WatchDoge.hooks.around_scenario
31
31
  WatchDoge.hooks.around_scenario.call(Proc.new { mgr.eval_scenario })
32
32
  else
33
33
  mgr.eval_scenario
34
34
  end
35
35
 
36
- WatchDoge.hooks.after_scenario.each { |t| instance_exec &t }
36
+ WatchDoge.hooks.after_scenario.each { |t| mgr.instance_exec &t }
37
37
  end
38
38
 
39
39
  WatchDoge.hooks.after_regression.each { |t| instance_exec &t }
@@ -49,7 +49,10 @@ module WatchDoge
49
49
  @setup_proc = nil
50
50
  @teardown_proc = nil
51
51
 
52
- @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
53
56
 
54
57
  @view_port = {}
55
58
  end
@@ -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}"
@@ -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 = {}
data/watchdoge.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'watchdoge'
3
- s.version = '0.1.24'
3
+ s.version = '0.1.25'
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.24
4
+ version: 0.1.25
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shen Lee