capybara-screenshot-diff 0.12.0 → 0.12.1

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: 0b1699ff683e2c3cb5b32b32ae60bbb05bf15c7480c85f931d5276dec9712fb0
4
- data.tar.gz: c315dcb091a812a01b2c2f2fe0690a07814dc3b87c632668f3355d2c4c994a59
3
+ metadata.gz: 7f8a739e8e6e8f3de068e2d6dab4317017025730dbbeeb72459f73eb8dcb9e1a
4
+ data.tar.gz: e214590aca05de27eea1874fd64a8389c792b00801f215d813acf3e5f82ddf18
5
5
  SHA512:
6
- metadata.gz: bb6b91c2e92fdce32245fa82fefc1ba48ab29f92645cdcc1513c28f2c79635c5c184ed16d81207268e3384ca04b199f2aeea98bc9f915c3faf91299cb9879e24
7
- data.tar.gz: 19a7ef21e19844f845cb396bd3c8db4d24402d87f44da571a554d91ec504eb9a3326d6b31c012d2c19790c53e99e91a9514ac2bf3e9b28fd9ea16f141b2cd1d4
6
+ metadata.gz: d7e28f6579e2ccb54e42d64889806884bad3434283ad5bd50caf18c758a0482a0e8c0c248d4c9c15131e671f2250964753dbd1c9aa9c56bf62cb0e1dca8a2db5
7
+ data.tar.gz: 8d3bca6920baf9c8f46c2a7914491fb49540d0abe7e53a770dff6aad163f24db1b685b4ef124870d244cd9f479b02248cca9bed00dd8a626e73b20107b668fe1
data/.rubocop_todo.yml CHANGED
@@ -18,7 +18,7 @@ Metrics/BlockLength:
18
18
  # Offense count: 1
19
19
  # Configuration parameters: CountComments.
20
20
  Metrics/ClassLength:
21
- Max: 302
21
+ Max: 303
22
22
 
23
23
  # Offense count: 6
24
24
  Metrics/CyclomaticComplexity:
data/.travis.yml CHANGED
@@ -2,13 +2,13 @@ language: ruby
2
2
  sudo: false
3
3
  cache: bundler
4
4
  rvm:
5
- - jruby-9.1.16.0
5
+ - jruby-9.2.0.0
6
6
  - ruby-2.5.1
7
7
  - ruby-2.4.4
8
8
  - ruby-2.3.7
9
- - ruby-2.2.10
10
9
 
11
10
  gemfile:
11
+ - gemfiles/rails52.gemfile
12
12
  - gemfiles/rails51.gemfile
13
13
  - gemfiles/rails50.gemfile
14
14
  - gemfiles/rails42.gemfile
@@ -18,8 +18,8 @@ Gem::Specification.new do |spec|
18
18
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
19
  spec.require_paths = ['lib']
20
20
 
21
- spec.add_runtime_dependency 'actionpack', '>= 4.2', '<5.3'
22
- spec.add_runtime_dependency 'capybara', '~> 2.0'
21
+ spec.add_runtime_dependency 'actionpack', '>= 4.2', '< 5.3'
22
+ spec.add_runtime_dependency 'capybara', '>= 2', '< 4'
23
23
  spec.add_runtime_dependency 'chunky_png', '~> 1.3'
24
24
 
25
25
  spec.add_development_dependency 'bundler', '~> 1.11'
@@ -0,0 +1,3 @@
1
+ eval File.read("#{__dir__}/common.gemfile")
2
+
3
+ gem 'actionpack', '~>5.2.1'
@@ -36,8 +36,10 @@ module Capybara
36
36
  def quick_equal?
37
37
  return nil unless old_file_exists?
38
38
  return true if new_file_size == old_file_size
39
+
39
40
  old_bytes, new_bytes = load_image_files(@old_file_name, @new_file_name)
40
41
  return true if old_bytes == new_bytes
42
+
41
43
  images = load_images(old_bytes, new_bytes)
42
44
  old_bytes = new_bytes = nil # rubocop: disable Lint/UselessAssignment
43
45
  crop_images(images, @dimensions) if @dimensions
@@ -147,6 +149,8 @@ module Capybara
147
149
  def calculate_max_color_distance(new_image, old_image)
148
150
  pixel_pairs = old_image.pixels.zip(new_image.pixels)
149
151
  @max_color_distance = pixel_pairs.inject(0) do |max, (p1, p2)|
152
+ next max unless p1 && p2
153
+
150
154
  d = ChunkyPNG::Color.euclidean_distance_rgba(p1, p2)
151
155
  [max, d].max
152
156
  end
@@ -194,6 +198,7 @@ module Capybara
194
198
 
195
199
  def sizes_changed?(org_image, new_image)
196
200
  return unless org_image.dimension != new_image.dimension
201
+
197
202
  change_msg = [org_image, new_image].map { |i| "#{i.width}x#{i.height}" }.join(' => ')
198
203
  puts "Image size has changed for #{@new_file_name}: #{change_msg}"
199
204
  true
@@ -239,6 +244,7 @@ module Capybara
239
244
  old_img.height.times do |y|
240
245
  (0...left).find do |x|
241
246
  next if same_color?(old_img, new_img, x, y)
247
+
242
248
  top ||= y
243
249
  bottom = y
244
250
  left = x
@@ -275,6 +281,7 @@ module Capybara
275
281
  color_matches = color_distance == 0 || (@color_distance_limit && @color_distance_limit > 0 &&
276
282
  color_distance <= @color_distance_limit)
277
283
  return color_matches if !@shift_distance_limit || @max_shift_distance == Float::INFINITY
284
+
278
285
  shift_distance =
279
286
  if color_matches
280
287
  0
@@ -354,6 +361,7 @@ module Capybara
354
361
  end
355
362
  end
356
363
  break if bounds_breached == 4
364
+
357
365
  shift_distance += 1
358
366
  end
359
367
  Float::INFINITY
@@ -362,6 +370,7 @@ module Capybara
362
370
  def color_matches(new_img, org_color, dx, dy, color_distance_limit)
363
371
  new_color = new_img[dx, dy]
364
372
  return new_color == org_color unless color_distance_limit
373
+
365
374
  color_distance = ChunkyPNG::Color.euclidean_distance_rgba(org_color, new_color)
366
375
  color_distance <= color_distance_limit
367
376
  end
@@ -9,6 +9,7 @@ module Capybara
9
9
  return 'windows' if ON_WINDOWS
10
10
  return 'macos' if ON_MAC
11
11
  return 'linux' if ON_LINUX
12
+
12
13
  'unknown'
13
14
  end
14
15
  end
@@ -27,6 +27,7 @@ module Capybara
27
27
  take_right_size_screenshot(comparison)
28
28
 
29
29
  break unless Capybara::Screenshot.stability_time_limit
30
+
30
31
  if comparison.quick_equal?
31
32
  clean_stabilization_images(comparison.new_file_name)
32
33
  break
@@ -63,9 +64,11 @@ module Capybara
63
64
 
64
65
  def reduce_retina_image_size(file_name)
65
66
  return if !ON_MAC || !selenium? || !Capybara::Screenshot.window_size
67
+
66
68
  saved_image = ChunkyPNG::Image.from_file(file_name)
67
69
  width = Capybara::Screenshot.window_size[0]
68
70
  return if saved_image.width < width * 2
71
+
69
72
  unless @_csd_retina_warned
70
73
  warn 'Halving retina screenshot. ' \
71
74
  'You should add "force-device-scale-factor=1" to your Chrome chromeOptions args.'
@@ -116,10 +119,12 @@ module Capybara
116
119
 
117
120
  def assert_images_loaded(timeout: Capybara.default_max_wait_time)
118
121
  return unless respond_to? :evaluate_script
122
+
119
123
  start = Time.now
120
124
  loop do
121
125
  pending_image = evaluate_script IMAGE_WAIT_SCRIPT
122
126
  break unless pending_image
127
+
123
128
  assert (Time.now - start) < timeout,
124
129
  "Images not loaded after #{timeout}s: #{pending_image.inspect}"
125
130
  sleep 0.1
@@ -49,6 +49,7 @@ module Capybara
49
49
 
50
50
  def poltergeist?
51
51
  return false unless defined?(Capybara::Poltergeist::Driver)
52
+
52
53
  current_capybara_driver_class <= Capybara::Poltergeist::Driver
53
54
  end
54
55
 
@@ -60,6 +61,7 @@ module Capybara
60
61
  @screenshot_group = name.to_s
61
62
  @screenshot_counter = 0
62
63
  return unless Screenshot.active? && name.present?
64
+
63
65
  FileUtils.rm_rf screenshot_dir
64
66
  end
65
67
 
@@ -67,6 +69,7 @@ module Capybara
67
69
  shift_distance_limit: Diff.shift_distance_limit, area_size_limit: Diff.area_size_limit)
68
70
  return unless Screenshot.active?
69
71
  return if window_size_is_wrong?
72
+
70
73
  if @screenshot_counter
71
74
  name = "#{format('%02i', @screenshot_counter)}_#{name}"
72
75
  @screenshot_counter += 1
@@ -83,6 +86,7 @@ module Capybara
83
86
  shift_distance_limit: shift_distance_limit,
84
87
  area_size_limit: area_size_limit)
85
88
  return unless comparison.old_file_exists?
89
+
86
90
  (@test_screenshots ||= []) << [caller(1..1).first, name, comparison]
87
91
  end
88
92
 
@@ -3,7 +3,7 @@
3
3
  module Capybara
4
4
  module Screenshot
5
5
  module Diff
6
- VERSION = '0.12.0'.freeze
6
+ VERSION = '0.12.1'.freeze
7
7
  end
8
8
  end
9
9
  end
data/matrix_test.rb CHANGED
@@ -35,6 +35,7 @@ end
35
35
 
36
36
  travis['rvm'].each do |ruby|
37
37
  next if ruby =~ /head/ # ruby-install does not support HEAD installation
38
+
38
39
  puts '#' * 80
39
40
  puts "Testing #{ruby}"
40
41
  puts
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.12.0
4
+ version: 0.12.1
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-09-27 00:00:00.000000000 Z
11
+ date: 2018-11-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionpack
@@ -34,16 +34,22 @@ dependencies:
34
34
  name: capybara
35
35
  requirement: !ruby/object:Gem::Requirement
36
36
  requirements:
37
- - - "~>"
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '2'
40
+ - - "<"
38
41
  - !ruby/object:Gem::Version
39
- version: '2.0'
42
+ version: '4'
40
43
  type: :runtime
41
44
  prerelease: false
42
45
  version_requirements: !ruby/object:Gem::Requirement
43
46
  requirements:
44
- - - "~>"
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: '2'
50
+ - - "<"
45
51
  - !ruby/object:Gem::Version
46
- version: '2.0'
52
+ version: '4'
47
53
  - !ruby/object:Gem::Dependency
48
54
  name: chunky_png
49
55
  requirement: !ruby/object:Gem::Requirement
@@ -165,6 +171,7 @@ files:
165
171
  - gemfiles/rails42.gemfile
166
172
  - gemfiles/rails50.gemfile
167
173
  - gemfiles/rails51.gemfile
174
+ - gemfiles/rails52.gemfile
168
175
  - lib/capybara/screenshot/diff.rb
169
176
  - lib/capybara/screenshot/diff/image_compare.rb
170
177
  - lib/capybara/screenshot/diff/os.rb