capybara-screenshot-diff 0.13.1 → 0.14.0

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
- SHA256:
3
- metadata.gz: f249dc7cf0295d09d935c84f9950b2484b08fcbeb1bb25bd15b00728b91e3763
4
- data.tar.gz: d2080d475dc6de4a2fb7b96cc1b06afc6b917aa851562dde599dec4dbdebe08a
2
+ SHA1:
3
+ metadata.gz: ab8bfbb400b5ee5a1f4652513e8769cbb142de67
4
+ data.tar.gz: '093da4d426368045c0faebaf77feb81b891249e3'
5
5
  SHA512:
6
- metadata.gz: d217726a6104e76c48c8593a328412be15d8305f6bbc73e1b622c0573ca796a9c37736d4ffa68a868790a6f96d9dfde80ed1cbbc0a5355f796bddbdee7ae3c16
7
- data.tar.gz: f99a43f46b8d4e317ec52567d125e3350f0af315bd16aa09f9b7ba1dd93b500bd38d651c32a99f7577ef039059197800fcddd9c53d1336317eb88a783ca3caab
6
+ metadata.gz: 2be6089d1f06236e9e5bb855c0cf69cb3c3885420e1bf02df4920211078c4ea25f01572275655903b178d603ebc16465e936d1926ee3e5730ba34577aec90fcb
7
+ data.tar.gz: 6e2b67f3c4eb7784e6280ec4aac9f8061a96232e351d48440f23eb7e68459c79c7ad32cb7652615a494c8f1e0847a8fcd44b6d2b82f55f82566310cb8242dcc3
data/.rubocop_todo.yml CHANGED
@@ -22,7 +22,7 @@ Metrics/ClassLength:
22
22
 
23
23
  # Offense count: 6
24
24
  Metrics/CyclomaticComplexity:
25
- Max: 12
25
+ Max: 13
26
26
 
27
27
  # Offense count: 16
28
28
  # Configuration parameters: CountComments.
data/README.md CHANGED
@@ -345,6 +345,30 @@ Capybara::Screenshot::Diff.color_distance_limit = 42
345
345
  ```
346
346
 
347
347
 
348
+ ### Allowed shift distance
349
+
350
+ Sometimes you want to allow small movements in the images. For example, jquer-tablesorter
351
+ renders the same table slightly differently sometimes. You can set set the shift distance
352
+ threshold for the comparison using the `shift_distance_limit` option to the `screenshot`
353
+ method:
354
+
355
+ ```ruby
356
+ test 'color threshold' do
357
+ visit '/'
358
+ screenshot 'index', shift_distance_limit: 6
359
+ end
360
+ ```
361
+
362
+ The difference is calculated as maximum distance in either the X or the Y axis.
363
+ You can also set this globally:
364
+
365
+ ```ruby
366
+ Capybara::Screenshot::Diff.shift_distance_limit = 4
367
+ ```
368
+
369
+ If `shift_distance_limit` is `nil` shift distance is not measured. If `shift_distance_limit` is set,
370
+ even to `0`, shift distabnce is measured and reported on image differences.
371
+
348
372
  ### Allowed difference size
349
373
 
350
374
  You can set set a threshold for the differing area size for the comparison
@@ -282,12 +282,8 @@ module Capybara
282
282
  color_distance <= @color_distance_limit)
283
283
  return color_matches if !@shift_distance_limit || @max_shift_distance == Float::INFINITY
284
284
 
285
- shift_distance =
286
- if color_matches
287
- 0
288
- else
289
- shift_distance_at(new_img, old_img, x, y, color_distance_limit: @color_distance_limit)
290
- end
285
+ shift_distance = (color_matches && 0) ||
286
+ shift_distance_at(new_img, old_img, x, y, color_distance_limit: @color_distance_limit)
291
287
  if shift_distance && (@max_shift_distance.nil? || shift_distance > @max_shift_distance)
292
288
  @max_shift_distance = shift_distance
293
289
  end
@@ -100,9 +100,7 @@ module Capybara
100
100
  JS
101
101
  blurred_input = page.driver.send :unwrap_script_result, active_element
102
102
  end
103
- if Capybara::Screenshot.hide_caret
104
- execute_script("$('*').css('caret-color','transparent')")
105
- end
103
+ execute_script("$('*').css('caret-color','transparent')") if Capybara::Screenshot.hide_caret
106
104
  blurred_input
107
105
  end
108
106
 
@@ -80,7 +80,7 @@ module Capybara
80
80
  FileUtils.mkdir_p File.dirname(file_name)
81
81
  comparison = ImageCompare.new(file_name,
82
82
  dimensions: Screenshot.window_size, color_distance_limit: color_distance_limit,
83
- area_size_limit: area_size_limit)
83
+ area_size_limit: area_size_limit, shift_distance_limit: shift_distance_limit)
84
84
  checkout_vcs(name, comparison)
85
85
  take_stable_screenshot(comparison, color_distance_limit: color_distance_limit,
86
86
  shift_distance_limit: shift_distance_limit,
@@ -3,7 +3,7 @@
3
3
  module Capybara
4
4
  module Screenshot
5
5
  module Diff
6
- VERSION = '0.13.1'.freeze
6
+ VERSION = '0.14.0'.freeze
7
7
  end
8
8
  end
9
9
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capybara-screenshot-diff
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.13.1
4
+ version: 0.14.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Uwe Kubosch
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-12-05 00:00:00.000000000 Z
11
+ date: 2019-01-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionpack
@@ -201,7 +201,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
201
201
  version: '0'
202
202
  requirements: []
203
203
  rubyforge_project:
204
- rubygems_version: 2.7.6
204
+ rubygems_version: 2.5.2.3
205
205
  signing_key:
206
206
  specification_version: 4
207
207
  summary: Track your GUI changes with diff assertions