Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fails if snapshot_name has forward slashes #45

Closed
wulffeld opened this issue Jan 17, 2024 · 3 comments
Closed

Fails if snapshot_name has forward slashes #45

wulffeld opened this issue Jan 17, 2024 · 3 comments

Comments

@wulffeld
Copy link

wulffeld commented Jan 17, 2024

I was using rspec-snapshot via this blog post https://www.bearer.com/blog/snapshot-testing-viewcomponents-with-rspec

This started to fail with 2.0.2. The workaround seems easy enough though:

config.after(:each, type: :component, snapshot: true) do |example|
  class_name = example.metadata[:described_class].name.underscore.tr("/", "_")
  test_name = example.metadata[:full_description].tr(example.metadata[:described_class].name, "").tr(" ", "_")
  raise "component snapshot has no content" if page.native.blank?

  expect(page.native).to match_snapshot("#{class_name}-#{test_name}")
end

Expected behaviour

It creates the folders below snapshot like <= 2.0.1 did.

@levinmr
Copy link
Owner

levinmr commented Jan 24, 2024

Thanks for bringing this to my attention. I wasn't aware that people were creating subfolders in this way. I'll fix the bug and note this behavior as a feature.

@colszowka
Copy link

colszowka commented Mar 7, 2024

Hi there, first of all thanks for the very useful library!

We have a similar case in that we're using example.full_description sometimes to automatically derive the snapshot name from the rspec example itself, and this currently fails when you have an API path in an acceptance spec context for example

It's easy enough to work around by using an explicit name, but it would be nice if this didn't crash :)

@levinmr
Copy link
Owner

levinmr commented Apr 2, 2024

@levinmr levinmr closed this as completed Apr 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants