Skip to content

Conversation

@lukearndt
Copy link

The awesome_print gem has not been maintained for several years.

There is now a successor gem named amazing_print, which implements the same API but is more actively maintained.

Updating a project to use this commit will require some snapshots to be regenerated because amazing_print produces a slightly different result from that of the awesome_print gem. For example, it can serialize hashes using the newer key: value syntax instead of hash rockets.

Context:

When `config.snapshot_dir` is set to `:relative` (the default option),
rspec-snapshot stores snapshots in a location relative to the spec file.

Prior to this commit, that relative snapshot location was hard-coded to
a `__snapshots__` subdirectory and the application had no way to choose
anything else.

Changes:

This commit adds a new config option that allows the caller to specify
a subdirectory when `config.snapshot_dir` is set to `:relative`.

The new config option supports the following values:

- String: a path to a different subdirectory

- nil: stores snapshot files in the same directory as each spec file

In all cases, the caller can still store the snapshot files in a further
subdirectory by calling `match_snapshot` with a nested snapshot name.
The `awesome_print` gem has not been maintained for several years.

There is now a successor gem named `amazing_print`, which implements the
same API but is more actively maintained.

Updating a project to use this commit will require some snapshots to be
regenerated because `amazing_print` produces a slightly different result
from that of the `awesome_print` gem. For example, it can serialize
hashes using the newer `key: value` syntax instead of hash rockets.
Context:

When `config.snapshot_dir` is set to `:relative` (the default option), rspec-snapshot stores snapshots in a location relative to the spec file.

Prior to this commit, that relative snapshot location was hard-coded to a `__snapshots__` subdirectory and the application had no way to choose anything else.

Changes:

This commit adds a new config option that allows the caller to specify a subdirectory when `config.snapshot_dir` is set to `:relative`.

The new config option supports the following values:

- String: a path to a different subdirectory

- nil: stores snapshot files in the same directory as each spec file

In all cases, the caller can still store the snapshot files in a further subdirectory by calling `match_snapshot` with a nested snapshot name.
@sonarqubecloud
Copy link

@tmimura39
Copy link

tmimura39 commented Nov 18, 2025

We would appreciate it if you would consider this proposal positively.

awesome_print does not work with the latest Rails main branch.
rails/rails#55900 (comment)

@levinmr
Copy link
Owner

levinmr commented Nov 18, 2025

I'll have to do some work on the CI jobs to get this to pass since ruby 2.7 runner is deprecated.

@DannyBen
Copy link

I'll have to do some work on the CI jobs to get this to pass since ruby 2.7 runner is deprecated.

Ruby 2.7 is EoL for almost 3 years. There is no good reason for anyone to keep using EoL Rubies. Even 3.2 is going to end in 4 months (and while at it, would be good to test against 3.4)

@tmimura39 tmimura39 mentioned this pull request Dec 3, 2025
@jeromedalbert
Copy link

jeromedalbert commented Dec 5, 2025

Updating a project to use this commit will require some snapshots to be regenerated because amazing_print produces a slightly different result from that of the awesome_print gem. For example, it can serialize hashes using the newer key: value syntax instead of hash rockets.

FYI users can configure amazing_print to produce a similar output/result as awesome_print by using the following configuration:

AmazingPrint.defaults = { hash_format: :rocket, colors: :values_only }

(the colors option is currently only available in amazing_print's main git branch, and not released yet)

I believe my comment is not actionable for this PR, since rspec-snapshot should probably not force or override any custom amazing_print config that users set. I am just posting this comment as a FYI.

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

Successfully merging this pull request may close these issues.

5 participants