Skip to content

Commit

Permalink
refact: shows deprecation message only when minitest required automat…
Browse files Browse the repository at this point in the history
…ically
  • Loading branch information
pftg committed Jul 30, 2024
1 parent 219dc24 commit ac5baba
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 16 deletions.
8 changes: 0 additions & 8 deletions lib/capybara-screenshot-diff.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
# frozen_string_literal: true

warn <<~MSG
DEPRECATED: use 'require "capybara_screenshot_diff/minitest"' instead of 'require "capybara-screenshot-diff"'
in #{caller(3)&.first}.
"capybara-screenshot-diff" is no longer needed and will be removed in the next major release.
MSG

require "capybara_screenshot_diff/minitest"
8 changes: 0 additions & 8 deletions lib/capybara/screenshot/diff.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
# frozen_string_literal: true

warn <<~MSG
DEPRECATED: use 'require "capybara_screenshot_diff/minitest"' or 'require "capybara_screenshot_diff/rspec"' instead of 'require "capybara/screenshot/diff"'
in #{caller(3)&.first}.
"capybara/screenshot/diff" is no longer needed and will be removed in the next major release.
MSG

require "capybara_screenshot_diff/minitest"
11 changes: 11 additions & 0 deletions lib/capybara_screenshot_diff/minitest.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,17 @@
require "minitest"
require "capybara_screenshot_diff/dsl"

used_deprecated_entrypoint = caller.any? do |path|
path.include?("capybara-screenshot-diff.rb") || path.include?("capybara/screenshot/diff.rb")
end

if used_deprecated_entrypoint
warn <<~MSG
[DEPRECATION] The default activation of `capybara_screenshot_diff/minitest` will be removed.
Please `require "capybara_screenshot_diff/minitest"` explicitly.
MSG
end

module CapybaraScreenshotDiff
module Minitest
module Assertions
Expand Down

0 comments on commit ac5baba

Please sign in to comment.