snap_diff-capybara 2.0.0.beta2 → 2.0.0.beta4

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.
Files changed (82) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +471 -0
  3. data/README.md +330 -0
  4. data/docs/UPGRADING.md +232 -34
  5. data/docs/architecture.md +9 -7
  6. data/docs/ci-integration.md +42 -11
  7. data/docs/configuration.md +176 -10
  8. data/docs/drivers.md +48 -5
  9. data/docs/framework-setup.md +10 -3
  10. data/docs/migration-guide.md +24 -13
  11. data/docs/reporters.md +70 -1
  12. data/docs/snapdiff.md +41 -8
  13. data/docs/thread_safety.md +77 -86
  14. data/lib/capybara/screenshot/diff/annotation_service.rb +1 -3
  15. data/lib/capybara/screenshot/diff/area_calculator.rb +1 -3
  16. data/lib/capybara/screenshot/diff/browser_helpers.rb +1 -3
  17. data/lib/capybara/screenshot/diff/config_legacy.rb +15 -60
  18. data/lib/capybara/screenshot/diff/cucumber.rb +5 -1
  19. data/lib/capybara/screenshot/diff/difference.rb +1 -4
  20. data/lib/capybara/screenshot/diff/drivers/chunky_png_driver.rb +3 -3
  21. data/lib/capybara/screenshot/diff/drivers/vips_driver.rb +2 -3
  22. data/lib/capybara/screenshot/diff/drivers.rb +4 -5
  23. data/lib/capybara/screenshot/diff/image_compare.rb +12 -11
  24. data/lib/capybara/screenshot/diff/image_preprocessor.rb +1 -3
  25. data/lib/capybara/screenshot/diff/os.rb +4 -11
  26. data/lib/capybara/screenshot/diff/region.rb +2 -2
  27. data/lib/capybara/screenshot/diff/reporters/default.rb +4 -3
  28. data/lib/capybara/screenshot/diff/screenshot_matcher.rb +1 -3
  29. data/lib/capybara/screenshot/diff/screenshoter.rb +1 -3
  30. data/lib/capybara/screenshot/diff/stable_screenshoter.rb +1 -3
  31. data/lib/capybara/screenshot/diff/utils.rb +1 -3
  32. data/lib/capybara/screenshot/diff/vcs.rb +1 -3
  33. data/lib/capybara/screenshot/diff/version.rb +8 -13
  34. data/lib/capybara-screenshot-diff.rb +10 -1
  35. data/lib/capybara_screenshot_diff/attempts_reporter.rb +1 -3
  36. data/lib/capybara_screenshot_diff/dsl.rb +5 -0
  37. data/lib/capybara_screenshot_diff/error_with_filtered_backtrace.rb +1 -4
  38. data/lib/capybara_screenshot_diff/reporters/html.rb +1 -3
  39. data/lib/capybara_screenshot_diff/screenshot_namer.rb +1 -3
  40. data/lib/capybara_screenshot_diff/snap.rb +1 -3
  41. data/lib/capybara_screenshot_diff/snap_manager.rb +1 -3
  42. data/lib/capybara_screenshot_diff/static.rb +4 -0
  43. data/lib/capybara_screenshot_diff.rb +17 -21
  44. data/lib/snap_diff/browser_helpers.rb +26 -5
  45. data/lib/snap_diff/capture/viewport.rb +2 -5
  46. data/lib/snap_diff/comparison.rb +54 -3
  47. data/lib/snap_diff/comparison_result.rb +3 -1
  48. data/lib/snap_diff/config.rb +189 -93
  49. data/lib/snap_diff/deprecation.rb +89 -28
  50. data/lib/snap_diff/driver.rb +18 -0
  51. data/lib/snap_diff/drivers/vips_driver.rb +12 -6
  52. data/lib/snap_diff/drivers.rb +94 -12
  53. data/lib/snap_diff/dsl.rb +51 -45
  54. data/lib/snap_diff/errors.rb +7 -1
  55. data/lib/snap_diff/integrations/cucumber.rb +1 -1
  56. data/lib/snap_diff/integrations/minitest.rb +45 -9
  57. data/lib/snap_diff/integrations/rspec.rb +11 -0
  58. data/lib/snap_diff/legacy_shims.rb +283 -28
  59. data/lib/snap_diff/removal.rb +159 -0
  60. data/lib/snap_diff/reporters/default.rb +86 -23
  61. data/lib/snap_diff/reporters/html.rb +29 -13
  62. data/lib/snap_diff/reporting.rb +330 -4
  63. data/lib/snap_diff/screenshot_assertion.rb +28 -23
  64. data/lib/snap_diff/screenshot_matcher.rb +121 -14
  65. data/lib/snap_diff/screenshot_namer.rb +1 -19
  66. data/lib/snap_diff/screenshoter.rb +5 -7
  67. data/lib/snap_diff/snap.rb +6 -1
  68. data/lib/snap_diff/snap_manager.rb +2 -3
  69. data/lib/snap_diff/stable_screenshoter.rb +2 -2
  70. data/lib/snap_diff/static.rb +1 -1
  71. data/lib/snap_diff/utils.rb +35 -17
  72. data/lib/snap_diff/vcs.rb +40 -7
  73. data/lib/snap_diff/version.rb +1 -1
  74. data/lib/snap_diff-capybara.rb +38 -0
  75. data/lib/snap_diff.rb +40 -39
  76. metadata +13 -10
  77. data/CODE_OF_CONDUCT.md +0 -129
  78. data/Rakefile +0 -65
  79. data/capybara-screenshot-diff.gemspec +0 -29
  80. data/docs/RELEASE_PREP.md +0 -44
  81. data/docs/docker-testing.md +0 -24
  82. data/gems.rb +0 -39
metadata CHANGED
@@ -1,11 +1,11 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: snap_diff-capybara
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0.beta2
4
+ version: 2.0.0.beta4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Uwe Kubosch
8
- bindir: exe
8
+ bindir: bin
9
9
  cert_chain: []
10
10
  date: 1980-01-02 00:00:00.000000000 Z
11
11
  dependencies:
@@ -69,7 +69,8 @@ dependencies:
69
69
  - - "<"
70
70
  - !ruby/object:Gem::Version
71
71
  version: '4'
72
- description: Save screen shots and track changes with graphical diff
72
+ description: Take screenshots in your Capybara tests, commit the baselines to git,
73
+ and let your suite fail on unintended visual changes. Runs offline, no SaaS.
73
74
  email:
74
75
  - uwe@kubosch.no
75
76
  executables: []
@@ -77,16 +78,12 @@ extensions: []
77
78
  extra_rdoc_files: []
78
79
  files:
79
80
  - CHANGELOG.md
80
- - CODE_OF_CONDUCT.md
81
81
  - LICENSE.txt
82
- - Rakefile
83
- - capybara-screenshot-diff.gemspec
84
- - docs/RELEASE_PREP.md
82
+ - README.md
85
83
  - docs/UPGRADING.md
86
84
  - docs/architecture.md
87
85
  - docs/ci-integration.md
88
86
  - docs/configuration.md
89
- - docs/docker-testing.md
90
87
  - docs/drivers.md
91
88
  - docs/framework-setup.md
92
89
  - docs/images/snap_diff_annotated.png
@@ -96,7 +93,6 @@ files:
96
93
  - docs/reporters.md
97
94
  - docs/snapdiff.md
98
95
  - docs/thread_safety.md
99
- - gems.rb
100
96
  - lib/capybara-screenshot-diff.rb
101
97
  - lib/capybara/screenshot/diff.rb
102
98
  - lib/capybara/screenshot/diff/annotation_service.rb
@@ -133,6 +129,7 @@ files:
133
129
  - lib/capybara_screenshot_diff/snap.rb
134
130
  - lib/capybara_screenshot_diff/snap_manager.rb
135
131
  - lib/capybara_screenshot_diff/static.rb
132
+ - lib/snap_diff-capybara.rb
136
133
  - lib/snap_diff.rb
137
134
  - lib/snap_diff/annotation_service.rb
138
135
  - lib/snap_diff/area_calculator.rb
@@ -157,6 +154,7 @@ files:
157
154
  - lib/snap_diff/legacy_shims.rb
158
155
  - lib/snap_diff/os.rb
159
156
  - lib/snap_diff/region.rb
157
+ - lib/snap_diff/removal.rb
160
158
  - lib/snap_diff/reporters/default.rb
161
159
  - lib/snap_diff/reporters/html.rb
162
160
  - lib/snap_diff/reporters/templates/report.html.erb
@@ -177,6 +175,11 @@ licenses:
177
175
  - MIT
178
176
  metadata:
179
177
  allowed_push_host: https://rubygems.org/
178
+ bug_tracker_uri: https://github.com/snap-diff/snap_diff-capybara/issues
179
+ changelog_uri: https://github.com/snap-diff/snap_diff-capybara/blob/master/CHANGELOG.md
180
+ documentation_uri: https://github.com/snap-diff/snap_diff-capybara/blob/master/docs/snapdiff.md
181
+ rubygems_mfa_required: 'true'
182
+ source_code_uri: https://github.com/snap-diff/snap_diff-capybara
180
183
  rdoc_options: []
181
184
  require_paths:
182
185
  - lib
@@ -193,5 +196,5 @@ required_rubygems_version: !ruby/object:Gem::Requirement
193
196
  requirements: []
194
197
  rubygems_version: 4.0.16
195
198
  specification_version: 4
196
- summary: Track your GUI changes with diff assertions
199
+ summary: Visual regression testing for Capybara screenshot diffs in your test suite
197
200
  test_files: []
data/CODE_OF_CONDUCT.md DELETED
@@ -1,129 +0,0 @@
1
- # Contributor Covenant Code of Conduct
2
-
3
- ## Our Pledge
4
-
5
- We as members, contributors, and leaders pledge to make participation in our
6
- community a harassment-free experience for everyone, regardless of age, body
7
- size, visible or invisible disability, ethnicity, sex characteristics, gender
8
- identity and expression, level of experience, education, socio-economic status,
9
- nationality, personal appearance, race, religion, or sexual identity
10
- and orientation.
11
-
12
- We pledge to act and interact in ways that contribute to an open, welcoming,
13
- diverse, inclusive, and healthy community.
14
-
15
- ## Our Standards
16
-
17
- Examples of behavior that contributes to a positive environment for our
18
- community include:
19
-
20
- * Demonstrating empathy and kindness toward other people
21
- * Being respectful of differing opinions, viewpoints, and experiences
22
- * Giving and gracefully accepting constructive feedback
23
- * Accepting responsibility and apologizing to those affected by our mistakes,
24
- and learning from the experience
25
- * Focusing on what is best not just for us as individuals, but for the
26
- overall community
27
-
28
- Examples of unacceptable behavior include:
29
-
30
- * The use of sexualized language or imagery, and sexual attention or
31
- advances of any kind
32
- * Trolling, insulting or derogatory comments, and personal or political attacks
33
- * Public or private harassment
34
- * Publishing others' private information, such as a physical or email
35
- address, without their explicit permission
36
- * Other conduct which could reasonably be considered inappropriate in a
37
- professional setting
38
-
39
- ## Enforcement Responsibilities
40
-
41
- Community leaders are responsible for clarifying and enforcing our standards of
42
- acceptable behavior and will take appropriate and fair corrective action in
43
- response to any behavior that they deem inappropriate, threatening, offensive,
44
- or harmful.
45
-
46
- Community leaders have the right and responsibility to remove, edit, or reject
47
- comments, commits, code, wiki edits, issues, and other contributions that are
48
- not aligned to this Code of Conduct, and will communicate reasons for moderation
49
- decisions when appropriate.
50
-
51
- ## Scope
52
-
53
- This Code of Conduct applies within all community spaces, and also applies when
54
- an individual is officially representing the community in public spaces.
55
- Examples of representing our community include using an official e-mail address,
56
- posting via an official social media account, or acting as an appointed
57
- representative at an online or offline event.
58
-
59
- ## Enforcement
60
-
61
- Instances of abusive, harassing, or otherwise unacceptable behavior may be
62
- reported to the community leaders responsible for enforcement by
63
- [opening a GitHub Issue](https://github.com/snap-diff/snap_diff-capybara/issues).
64
-
65
- All complaints will be reviewed and investigated promptly and fairly.
66
-
67
- All community leaders are obligated to respect the privacy and security of the
68
- reporter of any incident.
69
-
70
- ## Enforcement Guidelines
71
-
72
- Community leaders will follow these Community Impact Guidelines in determining
73
- the consequences for any action they deem in violation of this Code of Conduct:
74
-
75
- ### 1. Correction
76
-
77
- **Community Impact:** Use of inappropriate language or other behavior deemed
78
- unprofessional or unwelcome in the community.
79
-
80
- **Consequence:** A private, written warning from community leaders, providing
81
- clarity around the nature of the violation and an explanation of why the
82
- behavior was inappropriate. A public apology may be requested.
83
-
84
- ### 2. Warning
85
-
86
- **Community Impact:** A violation through a single incident or series
87
- of actions.
88
-
89
- **Consequence:** A warning with consequences for continued behavior. No
90
- interaction with the people involved, including unsolicited interaction with
91
- those enforcing the Code of Conduct, for a specified period of time. This
92
- includes avoiding interactions in community spaces as well as external channels
93
- like social media. Violating these terms may lead to a temporary or
94
- permanent ban.
95
-
96
- ### 3. Temporary Ban
97
-
98
- **Community Impact:** A serious violation of community standards, including
99
- sustained inappropriate behavior.
100
-
101
- **Consequence:** A temporary ban from any sort of interaction or public
102
- communication with the community for a specified period of time. No public or
103
- private interaction with the people involved, including unsolicited interaction
104
- with those enforcing the Code of Conduct, is allowed during this period.
105
- Violating these terms may lead to a permanent ban.
106
-
107
- ### 4. Permanent Ban
108
-
109
- **Community Impact:** Demonstrating a pattern of violation of community
110
- standards, including sustained inappropriate behavior, harassment of an
111
- individual, or aggression toward or disparagement of classes of individuals.
112
-
113
- **Consequence:** A permanent ban from any sort of public interaction within
114
- the community.
115
-
116
- ## Attribution
117
-
118
- This Code of Conduct is adapted from the [Contributor Covenant][homepage],
119
- version 2.1, available at
120
- https://www.contributor-covenant.org/version/2/1/code_of_conduct.html.
121
-
122
- Community Impact Guidelines were inspired by
123
- [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
124
-
125
- [homepage]: https://www.contributor-covenant.org
126
-
127
- For answers to common questions about this code of conduct, see the FAQ at
128
- https://www.contributor-covenant.org/faq. Translations are available at
129
- https://www.contributor-covenant.org/translations.
data/Rakefile DELETED
@@ -1,65 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "bundler/gem_tasks"
4
- require "rake/testtask"
5
-
6
- task default: :test
7
-
8
- Rake::TestTask.new(:test) do |t|
9
- t.libs << "test"
10
- t.libs << "lib"
11
- t.test_files = FileList["test/**/*_test.rb"]
12
- end
13
-
14
- Rake::TestTask.new("test:unit") do |t|
15
- t.libs << "test"
16
- t.libs << "lib"
17
- t.test_files = FileList["test/unit/**/*_test.rb"]
18
- end
19
-
20
- Rake::TestTask.new("test:integration") do |t|
21
- t.libs << "test"
22
- t.libs << "lib"
23
- t.test_files = FileList["test/integration/**/*_test.rb"]
24
- end
25
-
26
- desc "Run all tests with coverage"
27
- task :coverage do
28
- ENV["COVERAGE"] = "true"
29
- Rake::Task["test"].invoke
30
- end
31
-
32
- desc "Generate sample HTML report. Use bin/rake 'report:sample[embed]' for base64 images"
33
- task "report:sample", [:embed] do |_t, args|
34
- embed_arg = args[:embed] ? "--embed" : ""
35
- ruby "scripts/generate_sample_report.rb #{embed_arg}"
36
- end
37
-
38
- desc "Remove screenshot diff artifacts (keeps baselines)"
39
- task "snap_diff:clean" do
40
- patterns = ["**/*.diff.png", "**/*.base.png", "**/*.base.diff.png", "**/*.heatmap.diff.png",
41
- "**/*.diff.webp", "**/*.base.webp", "**/*.base.diff.webp", "**/*.heatmap.diff.webp",
42
- "**/snap_diff_report.html"]
43
- removed = patterns.flat_map { |p| Dir.glob("tmp/#{p}") + Dir.glob("doc/screenshots/#{p}") }.uniq
44
- removed.each { |f| FileUtils.rm_f(f) }
45
- puts "Removed #{removed.size} diff artifacts"
46
- end
47
-
48
- task "clobber" do
49
- puts "Cleanup tmp/"
50
- FileUtils.rm_rf(Dir["./tmp/*"])
51
- end
52
-
53
- task "test:benchmark" do
54
- require_relative "scripts/benchmark/find_region_benchmark"
55
- benchmark = Capybara::Screenshot::Diff::Drivers::FindRegionBenchmark.new
56
-
57
- puts "For Medium Screen Size: 800x600"
58
- benchmark.for_medium_size_screens
59
-
60
- puts ""
61
- puts "*" * 100
62
-
63
- puts "For Small Screen Size: 80x60"
64
- benchmark.for_small_images
65
- end
@@ -1,29 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- lib = File.expand_path("lib", __dir__)
4
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
- require "capybara/screenshot/diff/version"
6
-
7
- Gem::Specification.new do |spec|
8
- spec.name = "capybara-screenshot-diff"
9
- spec.version = Capybara::Screenshot::Diff::VERSION
10
- spec.authors = ["Uwe Kubosch"]
11
- spec.email = ["uwe@kubosch.no"]
12
- spec.summary = "Track your GUI changes with diff assertions"
13
- spec.description = "Save screen shots and track changes with graphical diff"
14
- spec.homepage = "https://github.com/snap-diff/snap_diff-capybara"
15
- spec.required_ruby_version = ">= 3.2"
16
- spec.license = "MIT"
17
- spec.metadata["allowed_push_host"] = "https://rubygems.org/"
18
- spec.files = `git ls-files -z`.split("\x0").reject do |f|
19
- f.match(%r{(^(\.|tmp|bin|test|spec|features|gemfiles|scripts|foo)/)|(^(\.|Dockerfile|CONTRIBUTING|README))})
20
- end
21
-
22
- spec.bindir = "exe"
23
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
24
- spec.require_paths = ["lib"]
25
-
26
- spec.add_development_dependency "actionpack", ">= 7.1", "< 9"
27
- spec.add_development_dependency "activesupport", ">= 7.1", "< 9"
28
- spec.add_runtime_dependency "capybara", ">= 2", "< 4"
29
- end
data/docs/RELEASE_PREP.md DELETED
@@ -1,44 +0,0 @@
1
- # Release Preparation — v1.15.1
2
-
3
- ## Summary
4
-
5
- HIGH-severity VipsDriver resize fix (retina halving could enlarge screenshots
6
- and corrupt baselines) plus the driver contract tests that caught it.
7
-
8
- ## Release Checklist
9
-
10
- ### Pre-Release
11
-
12
- - [x] Update version to `1.15.1`
13
- - [x] Run tests: `bundle exec rake test:unit` (376 runs, 0 failures)
14
- - [x] Update CHANGELOG.md
15
-
16
- ### Release (One Click)
17
-
18
- 1. Push to GitHub
19
- 2. Go to [Actions → Release](https://github.com/snap-diff/snap_diff-capybara/actions/workflows/release.yml)
20
- 3. Click **Run workflow**, enter `1.15.1`
21
- 4. Workflow will: test → tag → publish to RubyGems → create GitHub Release
22
-
23
- ### Post-Release
24
-
25
- - [ ] Verify on [RubyGems](https://rubygems.org/gems/capybara-screenshot-diff)
26
- - [ ] Verify GitHub Release created
27
-
28
- ## What Changed
29
-
30
- ### Added
31
- - `SnapDiff::Config` — flat, additive consolidation of all 27 settings
32
- (`SnapDiff.config` / `SnapDiff.configure`); old accessors stay canonical
33
-
34
- ### Fixed
35
- - `pending_if_new` no longer converts real teardown/after-hook failures into
36
- pending tests (Minitest defers to `after_teardown`; RSpec uses `append_after`;
37
- known residual for consumer `append_after` hooks documented)
38
- - `BacktraceFilter` custom `lib_directory` matches on a path boundary
39
-
40
- ### Internal
41
- - Guard tests for failure masking and skip-area/VCS-baseline regressions;
42
- two files merged into sole consumers (constant paths preserved)
43
-
44
- See [CHANGELOG.md](../CHANGELOG.md) for full details.
@@ -1,24 +0,0 @@
1
- # Docker Testing
2
-
3
- ## Running tests in Docker
4
-
5
- Screenshot tests depend on exact browser rendering, which varies across OS and browser versions. Use `bin/dtest` to run tests inside Docker for consistent, reproducible results matching CI:
6
-
7
- ```bash
8
- bin/dtest # Run all tests with all drivers
9
- bin/dtest test/integration/ # Run specific test directory
10
- ```
11
-
12
- This builds a Docker image with Chrome and runs the test suite against three Capybara drivers: `cuprite`, `selenium_chrome_headless`, and `selenium_headless`.
13
-
14
- ## Recording baseline screenshots
15
-
16
- Screenshot baselines are committed to the repo and compared against during tests. When you set up the project for the first time, or after upgrading the browser/driver, you need to re-record them:
17
-
18
- ```bash
19
- RECORD_SCREENSHOTS=1 bin/dtest
20
- ```
21
-
22
- This skips screenshot comparisons and saves new baselines instead. Without this step, tests will fail because your local browser renders pixels differently from the previously committed baselines.
23
-
24
- [← Back to README](../README.md)
data/gems.rb DELETED
@@ -1,39 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- source "https://rubygems.org"
4
-
5
- # Specify your gem's dependencies in capybara-screenshot-diff.gemspec
6
- gemspec path: __dir__
7
-
8
- gem "rake"
9
-
10
- # Image processing libraries
11
- gem "chunky_png", ">= 1.3", require: false
12
- gem "oily_png", platform: :ruby, git: "https://github.com/wvanbergen/oily_png", ref: "44042006e79efd42ce4b52c1d78a4c70f0b4b1b2"
13
- gem "ruby-vips", require: false
14
-
15
- group :test do
16
- gem "capybara", ">= 3.26"
17
- gem "mutex_m" # Needed for RubyMine debugging. Try removing it.
18
- gem "minitest", "< 6", require: false
19
- gem "minitest-mock", require: false
20
- gem "minitest-stub-const", require: false
21
- gem "simplecov", require: false
22
- gem "rspec", require: false
23
- end
24
-
25
- # Capybara Server
26
- gem "puma", require: false
27
- gem "rackup", require: false
28
-
29
- # Capybara Drivers
30
- gem "cuprite", require: false
31
- gem "selenium-webdriver", ">= 4.11", require: false
32
-
33
- # Test Frameworks
34
- # gem "cucumber", require: false
35
- # gem "cucumber-rails", require: false
36
-
37
- group :tools do
38
- gem "standard", require: false
39
- end