Skip to content

Commit

Permalink
fix: prevents rspec collision
Browse files Browse the repository at this point in the history
Closes: #136
  • Loading branch information
pftg committed Dec 20, 2024
1 parent 2c94698 commit 7d00eca
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/capybara/screenshot/diff/test_methods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def screenshot(name, skip_stack_frames: 0, **options)

unless job
if Screenshot::Diff.fail_if_new
raise_error(<<-ERROR.strip_heredoc, caller(2))
_raise_error(<<-ERROR.strip_heredoc, caller(2))
No existing screenshot found for #{screenshot_full_name}!
To stop seeing this error disable by `Capybara::Screenshot::Diff.fail_if_new=false`
ERROR
Expand All @@ -140,7 +140,7 @@ def screenshot(name, skip_stack_frames: 0, **options)
schedule_match_job(job)
else
error_msg = assert_image_not_changed(*job)
raise_error(error_msg, caller(2)) if error_msg
_raise_error(error_msg, caller(2)) if error_msg
end
end

Expand Down Expand Up @@ -168,7 +168,7 @@ def assert_image_not_changed(caller, name, comparison)

private

def raise_error(error_msg, backtrace)
def _raise_error(error_msg, backtrace)
raise CapybaraScreenshotDiff::ExpectationNotMet.new(error_msg).tap { _1.set_backtrace(backtrace) }
end

Expand Down
Binary file modified test/fixtures/app/doc/screenshots/macos/cuprite/index.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions test/fixtures/files/rspec_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,8 @@

expect(page).to match_screenshot("index", skip_stack_frames: 1, driver: :chunky_png)
end

it "does not conflicts with rspec methods" do
expect { raise StandardError }.to raise_error(StandardError)
end
end

0 comments on commit 7d00eca

Please sign in to comment.