capybara-screenshot-diff 0.4.0 → 0.5.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8b8e8db9866c1792d98837c0795f1cd079299082
4
- data.tar.gz: 70d03887cf122c6981883dd73b843ccb01affb85
3
+ metadata.gz: d2c578a6c17c416b415a2b9962acd2143475c1f6
4
+ data.tar.gz: cdf95fc4a8478c7034b6c42da6b2c0243c449b12
5
5
  SHA512:
6
- metadata.gz: 49185bf7799461dad6d4a10e1588846947bafa4352efa7f0475d1bcacc9c92a755c677c64ac3f413188fd496ec0c880922d2c11c90302a47d047207a0e257ade
7
- data.tar.gz: 75dad95ba44ec14b7ebb89afa78e0d25751b5e82fb806d17f7eb191e5072338fd4231769c93321dc394af7893c880ba3ece1fde0c7f3652cbfe0a1484d96318e
6
+ metadata.gz: 93d2c8284049415f00e368b50089e6a406047aa178f7ba9c979962d15cb8a6b3d005170cd2ba162ec8c572eee56521e4f33710f4d2c2a1bf6231a3579f174cbe
7
+ data.tar.gz: 0c5a82e828f86294d1d77cbcbf41710b922fd10918e6dd2d37fde681ead14e07cf28ffc392c9adfcd048ed04572462227016273520d161e8a671cd2a81045b6d
@@ -4,6 +4,16 @@ AllCops:
4
4
  DisplayCopNames: true
5
5
  DisplayStyleGuide: true
6
6
 
7
+ Layout/AlignParameters:
8
+ EnforcedStyle: with_fixed_indentation
9
+ IndentationWidth: 4
10
+
11
+ Layout/MultilineMethodCallIndentation:
12
+ EnforcedStyle: indented
13
+
14
+ Layout/MultilineOperationIndentation:
15
+ EnforcedStyle: indented
16
+
7
17
  Lint/Debugger:
8
18
  Enabled: false
9
19
 
@@ -16,16 +26,8 @@ Metrics/LineLength:
16
26
  Style/Documentation:
17
27
  Enabled: false
18
28
 
19
- Style/MultilineMethodCallIndentation:
20
- EnforcedStyle: indented
21
- IndentationWidth: 4
22
-
23
29
  Style/NumericPredicate:
24
30
  Enabled: false
25
31
 
26
32
  Style/SignalException:
27
33
  EnforcedStyle: semantic
28
-
29
- Style/AlignParameters:
30
- EnforcedStyle: with_fixed_indentation
31
- IndentationWidth: 4
@@ -1,23 +1,38 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2016-12-23 14:12:31 +0100 using RuboCop version 0.46.0.
3
+ # on 2017-06-08 11:42:01 +0200 using RuboCop version 0.49.1.
4
4
  # The point is for the user to remove these configuration records
5
5
  # one by one as the offenses are removed from the code base.
6
6
  # Note that changes in the inspected code, or installation of new
7
7
  # versions of RuboCop, may require this file to be generated again.
8
8
 
9
- # Offense count: 3
10
- Metrics/AbcSize:
11
- Max: 45
9
+ # Offense count: 2
10
+ # Cop supports --auto-correct.
11
+ Layout/EmptyLineAfterMagicComment:
12
+ Exclude:
13
+ - 'capybara-screenshot-diff.gemspec'
14
+ - 'lib/capybara/screenshot/diff/version.rb'
12
15
 
13
16
  # Offense count: 1
14
- Metrics/CyclomaticComplexity:
15
- Max: 12
17
+ # Cop supports --auto-correct.
18
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
19
+ # SupportedStyles: auto_detection, squiggly, active_support, powerpack, unindent
20
+ Layout/IndentHeredoc:
21
+ Exclude:
22
+ - 'lib/capybara/screenshot/diff/capybara_setup.rb'
16
23
 
17
24
  # Offense count: 4
25
+ Metrics/AbcSize:
26
+ Max: 31
27
+
28
+ # Offense count: 2
29
+ Metrics/CyclomaticComplexity:
30
+ Max: 8
31
+
32
+ # Offense count: 7
18
33
  # Configuration parameters: CountComments.
19
34
  Metrics/MethodLength:
20
- Max: 36
35
+ Max: 25
21
36
 
22
37
  # Offense count: 1
23
38
  # Configuration parameters: CountKeywordArgs.
@@ -26,9 +41,21 @@ Metrics/ParameterLists:
26
41
 
27
42
  # Offense count: 1
28
43
  Metrics/PerceivedComplexity:
29
- Max: 14
44
+ Max: 8
45
+
46
+ # Offense count: 1
47
+ Performance/Caller:
48
+ Exclude:
49
+ - 'lib/capybara/screenshot/diff/capybara_setup.rb'
50
+
51
+ # Offense count: 1
52
+ # Cop supports --auto-correct.
53
+ Security/YAMLLoad:
54
+ Exclude:
55
+ - 'matrix_test.rb'
30
56
 
31
57
  # Offense count: 1
58
+ # Cop supports --auto-correct.
32
59
  # Configuration parameters: EnforcedStyle, SupportedStyles.
33
60
  # SupportedStyles: format, sprintf, percent
34
61
  Style/FormatString:
@@ -1,8 +1,9 @@
1
1
  language: ruby
2
2
  rvm:
3
- - ruby-2.3.3
4
- - jruby-9.1.6.0
5
- - ruby-2.2.6
3
+ - ruby-2.4.1
4
+ - jruby-9.1.8.0
5
+ - ruby-2.3.4
6
+ - ruby-2.2.7
6
7
  - ruby-2.1.9
7
8
  - ruby-head
8
9
  - jruby-head
@@ -19,8 +20,6 @@ jdk:
19
20
 
20
21
  matrix:
21
22
  exclude:
22
- - rvm: ruby-head # Cannot build json 1.x
23
- gemfile: gemfiles/rails42.gemfile
24
23
  - rvm: ruby-2.1.9 # Not supported by Rails 5
25
24
  gemfile: gemfiles/rails50.gemfile
26
25
  allow_failures:
data/Rakefile CHANGED
@@ -8,3 +8,7 @@ Rake::TestTask.new(:test) do |t|
8
8
  t.libs << 'lib'
9
9
  t.test_files = FileList['test/**/*_test.rb']
10
10
  end
11
+
12
+ require 'rubocop/rake_task'
13
+ RuboCop::RakeTask.new
14
+ task test: %i[rubocop:auto_correct]
@@ -25,6 +25,10 @@ module ActionDispatch
25
25
  end
26
26
  end
27
27
 
28
+ def self.macos?
29
+ os_name == 'macos'
30
+ end
31
+
28
32
  def self.screenshot_root
29
33
  Capybara::Screenshot.screenshot_root ||
30
34
  (defined?(Rails.root) && Rails.root) || File.expand_path('.')
@@ -65,11 +69,24 @@ module ActionDispatch
65
69
  File.join [self.class.screenshot_area] + group_parts
66
70
  end
67
71
 
72
+ private def current_capybara_driver_class
73
+ Capybara.drivers[Capybara.current_driver].call({}).class
74
+ end
75
+
76
+ private def selenium?
77
+ current_capybara_driver_class <= Capybara::Selenium::Driver
78
+ end
79
+
80
+ private def poltergeist?
81
+ return false unless defined?(Capybara::Poltergeist::Driver)
82
+ current_capybara_driver_class <= Capybara::Poltergeist::Driver
83
+ end
84
+
68
85
  setup do
69
86
  if Capybara::Screenshot.window_size
70
- if Capybara.default_driver == :selenium
87
+ if selenium?
71
88
  page.driver.browser.manage.window.resize_to(*Capybara::Screenshot.window_size)
72
- elsif Capybara.default_driver == :poltergeist
89
+ elsif poltergeist?
73
90
  page.driver.resize(*Capybara::Screenshot.window_size)
74
91
  end
75
92
  end
@@ -95,9 +112,9 @@ module ActionDispatch
95
112
 
96
113
  def screenshot(name)
97
114
  return unless Capybara::Screenshot.active?
98
- if Capybara.default_driver == :selenium && Capybara::Screenshot.window_size
99
- return unless page.driver.browser.manage.window
100
- .size == Selenium::WebDriver::Dimension.new(*Capybara::Screenshot.window_size)
115
+ if selenium? && Capybara::Screenshot.window_size
116
+ return unless page.driver.browser.manage.window.size ==
117
+ Selenium::WebDriver::Dimension.new(*Capybara::Screenshot.window_size)
101
118
  end
102
119
  if @screenshot_counter
103
120
  name = "#{'%02i' % @screenshot_counter}_#{name}"
@@ -168,6 +185,20 @@ EOF
168
185
  old_file_size = nil
169
186
  loop do
170
187
  save_screenshot(file_name)
188
+
189
+ # FIXME(uwe): Remove when chromedriver take right size screenshots
190
+ # Reduce Retina image size
191
+ if self.class.macos? && selenium? && Capybara::Screenshot.window_size
192
+ saved_image = ChunkyPNG::Image.from_file(file_name)
193
+ width = Capybara::Screenshot.window_size[0]
194
+ if saved_image.width >= width * 2
195
+ height = (width * saved_image.height) / saved_image.width
196
+ resized_image = saved_image.resample_bilinear(width, height)
197
+ resized_image.save(file_name)
198
+ end
199
+ end
200
+ # EMXIF
201
+
171
202
  break unless Capybara::Screenshot.stability_time_limit
172
203
  new_file_size = File.size(file_name)
173
204
  break if new_file_size == old_file_size
@@ -2,7 +2,7 @@
2
2
  module Capybara
3
3
  module Screenshot
4
4
  module Diff
5
- VERSION = '0.4.0'.freeze
5
+ VERSION = '0.5.0'.freeze
6
6
  end
7
7
  end
8
8
  end
@@ -43,7 +43,7 @@ travis['rvm'].each do |ruby|
43
43
  system "#{bundler_gem_check_cmd} || chruby-exec #{ruby} -- gem install bundler" || exit(1)
44
44
  travis['gemfile'].each do |gemfile|
45
45
  if (travis['matrix']['exclude'].to_a + travis['matrix']['allowed_failures'].to_a)
46
- .any? { |f| f['rvm'] == ruby && f['gemfile'] == gemfile }
46
+ .any? { |f| f['rvm'] == ruby && f['gemfile'] == gemfile }
47
47
  puts 'Skipping known failure.'
48
48
  next
49
49
  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.4.0
4
+ version: 0.5.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: 2017-04-04 00:00:00.000000000 Z
11
+ date: 2017-06-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionpack