lookbook_visual_tester 0.6.0 → 0.7.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
  SHA256:
3
- metadata.gz: 3f7d81d326a95c67665b1e7bc5f0e253069f92f4dd9755520da6a915609b8111
4
- data.tar.gz: 9d5e4fbd12263bffa84e6be352dfcc2dc36a86ea32a7437ec7d310e605cfd87a
3
+ metadata.gz: d94b40b51271e7c94f1107872615622267d87fea8a4daefd0e3454b4b768f9f1
4
+ data.tar.gz: f7768f6d78d43b0e42b04cfca1ef4d23e41b932fe1d0005c53e580206a261ee3
5
5
  SHA512:
6
- metadata.gz: 87f5ee0e350a62685aa7d5c9e7d78dc85c59716c9d0e0ec02b02270a95c21852046b42b8bd9a4b0020b3fe0f9396b4162ad2e00ddc9d6edb9f0707cc88cf51da
7
- data.tar.gz: 24b7dd96bc5b536b6e51d6987dc87c3cb5818a6d43ba70ff6f16640525cd9963a38aae6ea249add02e60c53496a5477f92a628eee7bc88be7ec4111de118ac68
6
+ metadata.gz: 00ed31dbc76cc7baf465ce2875416862f9e4772e114c015798944fa0a1aef81d461cad7dd27456fbed685c1d9bd2454cef1c073cb082d913bc18c986d5493a83
7
+ data.tar.gz: 2b5a9a9f81b96eef19e3b0e1cf3ff4f49b3d6d9e26216650f31a1c75c4ddb7e966af4785de2323761df15dbb928cdb271a394068b77f1667819c521cd57f7372
data/.env.example ADDED
@@ -0,0 +1,13 @@
1
+ # RubyGems release credentials. Copy to .env and fill in.
2
+ # Get an API key at: https://rubygems.org/profile/api_keys
3
+ # For a release-only key, enable the "Push rubygem" scope (and MFA if your
4
+ # account requires it). Keep this file private — never commit the real .env.
5
+ #
6
+ # cp .env.example .env
7
+ # # edit .env, then: rake release:gem
8
+
9
+ RUBYGEMS_API_KEY=
10
+
11
+ # Optional: if your account has MFA enabled for API access, set the current
12
+ # one-time code here (or pass it at the prompt via `rake release:otp`).
13
+ # GEM_HOST_OTP_CODE=
data/CHANGELOG.md CHANGED
@@ -1,4 +1,30 @@
1
1
  # Changelog
2
+ ## [0.7.0] - 2026-08-09
3
+
4
+ ### Removed
5
+ - `cuprite` runtime dependency; legacy `LookbookVisualTester::SessionManager`, `CapybaraSetup`, `ScreenshotTaker`, and `BaselineManager` classes.
6
+ - ImageMagick `convert` and `compare` shell calls from the visual regression path.
7
+ - Hard-coded Devise/Warden/Pundit auth mocking inside the gem.
8
+ - Lookbook 1.x (`examples`) fallback — only Lookbook 2.x (`scenarios`) is supported.
9
+ - Global `$stdout` mutation in rake tasks.
10
+ - Version-fragile `check_preview_controller_config` introspection in `PreviewChecker`.
11
+
12
+ ### Added
13
+ - Pure-Ruby `LookbookVisualTester::ImageTrimmer` (ChunkyPNG) — no ImageMagick needed to trim screenshots.
14
+ - `config.preview_checker_setup` host hook for providing auth/helpers during deep checks.
15
+ - `LookbookVisualTester::ServerTestRunner` and `rake lookbook:server_and_test` for unattended agent/CI runs (process-group cleanup, log capture, configurable timeout).
16
+ - `Runner#initialize(..., output:)` — injectable output stream for thread-safe/quiet runs.
17
+ - `LookbookVisualTester::BrowserDiscovery` plus `config.browser_path` / `LOOKBOOK_BROWSER_PATH` to resolve a real Chrome binary, avoiding PATH-resolved wrapper scripts that break headless mode.
18
+ - `config.browser_options` (defaults to `{ "headless" => "new" }`), `config.browser_timeout`, and `config.process_timeout` for robust modern-Chrome launches.
19
+
20
+ ### Changed
21
+ - `copy_to_clipboard` now defaults to `false` (opt in to `xclip`).
22
+ - `automatic_run` is parsed as a boolean from the `LOOKBOOK_AUTOMATIC_RUN` env var.
23
+ - The Railtie `Lookbook.after_change` auto-run hook now drives the Ferrum `Runner` instead of the deleted Capybara `ScreenshotTaker`.
24
+ - `Runner#run_scenario` decomposed into focused private methods; the concurrent path stores its driver per-thread.
25
+ - `lookbook:approve` matches namespaced previews by exact base name or `_suffix`, so approving `ui/button/default` no longer also approves `ui_button_defaultmobile`.
26
+ - Ferrum dependency bumped to `>= 0.16` and launches with `--headless=new`, fixing "Multiple targets are not supported in headless mode" on modern Chrome builds.
27
+
2
28
  ## [0.6.0] - 2026-01-12
3
29
 
4
30
  ### Fixed
data/README.md CHANGED
@@ -12,19 +12,16 @@ A powerful visual regression testing tool for [ViewComponent](https://viewcompon
12
12
  - **Intelligent Diffing**: High-quality image comparison using `chunky_png`.
13
13
  - **Human-Friendly Aesthetics**: Context is rendered with a light blue tint to make red highlights of differences pop.
14
14
  - **Robust Capture**: Automatically disables animations, waits for network idle, and allows masking/cropping.
15
- - **Lookbook Support**: Compatible with both Lookbook 1.x (`examples`) and 2.x (`scenarios`).
15
+ - **Lookbook Support**: Compatible with Lookbook 2.x (`scenarios`).
16
16
  - **Internal Test Harness**: Includes a dummy Rails app for self-contained testing and development.
17
17
 
18
18
  ## Installation
19
19
 
20
20
  ### System Dependencies
21
21
 
22
- The gem requires `imagemagick` for image processing and `xclip` for clipboard integration (Linux).
22
+ The gem uses [Ferrum](https://github.com/rubycdp/ferrum) (Chrome) and [ChunkyPNG](https://github.com/wvanbergen/chunky_png) for image processing. You need a Chrome-compatible browser installed locally. **No ImageMagick or `xclip` required.**
23
23
 
24
- For Ubuntu-based systems:
25
- ```bash
26
- sudo apt-get install imagemagick xclip
27
- ```
24
+ Clipboard support via `xclip` is optional and opt-in (`config.copy_to_clipboard = true`).
28
25
 
29
26
  ### Gem Installation
30
27
 
@@ -46,12 +43,16 @@ You can configure the tester in a Rails initializer:
46
43
 
47
44
  ```ruby
48
45
  LookbookVisualTester.configure do |config|
49
- config.lookbook_host = "http://localhost:3000" # Where your rails app is running
46
+ config.lookbook_host = "http://localhost:5000" # Where your rails app is running
50
47
  config.base_path = "coverage/screenshots" # Root for screenshots
51
- config.copy_to_clipboard = true # Enable xclip support
48
+ config.copy_to_clipboard = false # Default: off; opt in to xclip
52
49
  config.threads = 4 # Number of parallel threads (default: 4)
53
50
  config.wait_time = 0.5 # Optional: Wait time (seconds) before screenshot (fixes blank screens)
54
- config.tolerance = 0.05 # Optional: Mismatch tolerance (0.0 to 1.0) to ignore minor rendering differences
51
+ config.tolerance = 0.0 # Optional: Mismatch tolerance (0.0 to 1.0) to ignore minor rendering differences
52
+ config.preview_checker_setup = -> {
53
+ # Provide auth/helpers for deep checks, e.g.:
54
+ # Current.user = LookbookFixtures.demo_user
55
+ }
55
56
  end
56
57
  ```
57
58
 
@@ -83,6 +84,14 @@ Runs all Lookbook previews, generates a terminal summary, and creates an HTML re
83
84
  bundle exec rake lookbook:test
84
85
  ```
85
86
 
87
+ #### Start Server, Test, Stop (for agents/CI)
88
+ Starts Rails, waits for Lookbook to be reachable, runs `lookbook:test`, and stops the server.
89
+ ```bash
90
+ bundle exec rake lookbook:server_and_test
91
+ ```
92
+
93
+ Set `LOOKBOOK_SERVER_TIMEOUT` (seconds) and optional `LOOKBOOK_SERVER_LOG` (path to capture server output) as needed.
94
+
86
95
  #### Test a Specific Preview
87
96
  Filter previews by name or label.
88
97
  ```bash
data/Rakefile CHANGED
@@ -22,4 +22,57 @@ namespace :release do
22
22
  ENV['GEM_HOST_OTP_CODE'] = otp
23
23
  Rake::Task['release'].invoke
24
24
  end
25
+
26
+ desc 'Build the gem and push it to RubyGems (reads .env / RUBYGEMS_API_KEY)'
27
+ task :gem do
28
+ require 'fileutils'
29
+ load_dotenv
30
+
31
+ api_key = ENV['RUBYGEMS_API_KEY'] || ENV['GEM_HOST_API_KEY']
32
+ unless api_key
33
+ abort <<~MSG
34
+ Missing RubyGems API key.
35
+ Set RUBYGEMS_API_KEY (or GEM_HOST_API_KEY) in your environment or .env:
36
+ https://rubygems.org/profile/api_keys (enable MFA scopes as needed)
37
+ Then run: rake release:gem
38
+ MSG
39
+ end
40
+
41
+ write_credentials(api_key)
42
+ Rake::Task['build'].invoke
43
+
44
+ gem_path = Dir.glob('pkg/*.gem').max_by { |f| File.mtime(f) }
45
+ push_cmd = ['gem', 'push', gem_path]
46
+ push_cmd += ['--otp', ENV['GEM_HOST_OTP_CODE']] if ENV['GEM_HOST_OTP_CODE']
47
+ sh(*push_cmd)
48
+ end
49
+
50
+ def load_dotenv
51
+ path = File.expand_path('.env', Dir.pwd)
52
+ return unless File.file?(path)
53
+ File.readlines(path).each do |line|
54
+ line = line.strip
55
+ next if line.empty? || line.start_with?('#')
56
+ key, val = line.split('=', 2)
57
+ next unless key && val
58
+ ENV[key] = val.delete_suffix("\n").strip unless ENV.key?(key)
59
+ end
60
+ end
61
+
62
+ def write_credentials(api_key)
63
+ creds_path = File.expand_path('~/.gem/credentials')
64
+ creds = if File.file?(creds_path)
65
+ File.read(creds_path)
66
+ else
67
+ ''
68
+ end
69
+ updated = if creds =~ /^:rubygems_api_key: /
70
+ creds.gsub(/^:rubygems_api_key: .*/, ":rubygems_api_key: #{api_key}")
71
+ else
72
+ creds + ":rubygems_api_key: #{api_key}\n"
73
+ end
74
+ FileUtils.mkdir_p(File.dirname(creds_path))
75
+ File.write(creds_path, updated)
76
+ FileUtils.chmod(0o600, creds_path)
77
+ end
25
78
  end