dotdiff 3.0.0 → 3.0.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: 161e2aca53c1b747a6de45cd09ac975f56938d246e32886f7c7efc65cc7f0426
4
- data.tar.gz: fc2878dc821b64da63222f2c5b8eb4bfb2f0b6a33d625556165d834d7c386f82
3
+ metadata.gz: dc1ca017c297dd63435e5282ad168d6e25ab0f9a3c8e2ac0caea8e2d2fa0df4e
4
+ data.tar.gz: bbecf64885b04e5ed2cd123d6b930e3ceaa15c82a03e0ee67937bb49af385537
5
5
  SHA512:
6
- metadata.gz: 7b130dcea90f5dc4ca7d85d1154fe84e7209554b4b4b3e09d617e32ec858c256a3bc489e6ffb4e97b738bb02092e95ca225707940be4990f1be5889b50a77043
7
- data.tar.gz: 5acf38c5ee36c8964041fd1e9b6c13dfdce58ecf15e0e3ae48b2188326c06f654f5c413d4564bdb63009d9bccc4607813d99b711f3966c02b12d36b2d9228dff
6
+ metadata.gz: df25e2add82e31537d9d6cab28f46c96cd251106a331a503709c9aa33e229ae64837c809a03c66e4142def23e3eedf05f49106101ba343bac48b61faeff16740
7
+ data.tar.gz: 4ba8aafa62200080f35294ade8a7d1198f880de72385cc9196eff04654e72755daf3771084136639aa8a01f5c6844a78274b749cacd6a82570a01a1d8833fbe5
@@ -11,12 +11,30 @@ module DotDiff
11
11
  end
12
12
 
13
13
  def result
14
+ comparer = build_comparer
15
+
16
+ if comparer.nil?
17
+ raise ArgumentError, "Unknown element class received: #{element.class.name}"
18
+ end
19
+
20
+ passed, msg = comparer.run
21
+ write_failure_imgs(comparer.new_image_path) if !passed && DotDiff.failure_image_path
22
+
23
+ [passed, msg]
24
+ end
25
+
26
+ private
27
+
28
+ def write_failure_imgs(new_image_path)
29
+ FileUtils.mkdir_p(snapshot.failure_path)
30
+ FileUtils.mv(new_image_path, snapshot.new_file, force: true)
31
+ end
32
+
33
+ def build_comparer
14
34
  if element.is_a?(Capybara::Session)
15
- DotDiff::Comparible::PageComparer.run(snapshot, nil)
35
+ DotDiff::Comparible::PageComparer.new(snapshot, nil)
16
36
  elsif element.is_a?(Capybara::Node::Base)
17
- DotDiff::Comparible::ElementComparer.run(snapshot, ElementMeta.new(page, element))
18
- else
19
- raise ArgumentError, "Unknown element class received: #{element.class.name}"
37
+ DotDiff::Comparible::ElementComparer.new(snapshot, ElementMeta.new(page, element))
20
38
  end
21
39
  end
22
40
  end
@@ -14,14 +14,13 @@ module DotDiff
14
14
 
15
15
  private
16
16
 
17
- attr_reader :snapshot, :element_meta, :new_image
17
+ attr_reader :snapshot, :element_meta
18
18
 
19
19
  def compare(compare_to_image)
20
- @new_image = compare_to_image
21
20
  return [false, img_container.dimensions_mismatch_msg] unless img_container.both_images_same_dimensions?
22
21
 
23
22
  cmd = CommandWrapper.new
24
- cmd.run(snapshot.basefile, new_image, snapshot.diff_file)
23
+ cmd.run(snapshot.basefile, new_image_path, snapshot.diff_file)
25
24
  return [cmd.passed?, cmd.message] if cmd.failed?
26
25
 
27
26
  calculate_result(cmd.pixels)
@@ -34,23 +33,15 @@ module DotDiff
34
33
  diff_pixels
35
34
  )
36
35
 
37
- passed = calc.under_threshold?
38
- write_failure_imgs if !passed && DotDiff.failure_image_path
39
-
40
- [passed, calc.message]
36
+ [calc.under_threshold?, calc.message]
41
37
  end
42
38
 
43
39
  def img_container
44
40
  @img_container ||= DotDiff::Image::Container.new(
45
41
  snapshot.basefile,
46
- new_image
42
+ new_image_path
47
43
  )
48
44
  end
49
-
50
- def write_failure_imgs
51
- FileUtils.mkdir_p(snapshot.failure_path)
52
- FileUtils.mv(new_image, snapshot.new_file, force: true)
53
- end
54
45
  end
55
46
  end
56
47
  end
@@ -14,6 +14,10 @@ module DotDiff
14
14
  end
15
15
  end
16
16
 
17
+ def new_image_path
18
+ snapshot.cropped_file
19
+ end
20
+
17
21
  private
18
22
 
19
23
  def take_snapshot_and_crop
@@ -13,6 +13,10 @@ module DotDiff
13
13
  compare(snapshot.fullscreen_file)
14
14
  end
15
15
  end
16
+
17
+ def new_image_path
18
+ snapshot.fullscreen_file
19
+ end
16
20
  end
17
21
  end
18
22
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DotDiff
4
- VERSION = '3.0.0'
4
+ VERSION = '3.0.1'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dotdiff
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 3.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jon Normington
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-03-21 00:00:00.000000000 Z
11
+ date: 2021-03-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rmagick