rspec-snapshot 2.0.3 → 2.2.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: 4668f539ce7c95d76e77eab406e9b7dd1a8a5cf50265b60309b8da6d3c2564a1
4
- data.tar.gz: ecf7a28db05aa850e7fec2b413e9b13dfe9c917eee5747c68fb22eab3bf10471
3
+ metadata.gz: 300d9d55d1e789613b7f7948165e3b0b831b8b9e3489a2d28920d47a3b7d8e59
4
+ data.tar.gz: 6faa6c0db5d1f18faaa557fe86416219f976566e7b8d0060216db147bba9ebcd
5
5
  SHA512:
6
- metadata.gz: 5fa621abf5030844e59efe1e5b3c2846debaaf9905bc4506c5d4be6481e9f549b3b4df84365867e2ba7c021fcc56d3262f374c9d0fcd5cc2f0d53d7e4ed925d9
7
- data.tar.gz: 2b8425fad9b2f564d05b1d9ffbce831368d279321ccfb8747e25fce6f4c4e45a2e7ce44c79ab9b4ca803a4a20c8438f6e2c3d44555b458cb65789cda0fd1570d
6
+ metadata.gz: 14103a7f7c20ca7d42802ed7e29abb4981056aa0f97a7d0e4c5bc295d485c62bbef807acb0f3519b39e0fcab87fd8046c7382f35dedfc127b94802c5f79a0060
7
+ data.tar.gz: ecc8dcdbea6e13263ef9641ca0b0c269f649d8c56776711d5a09acee0f30e09529c9e4c0a45caf52bb2fc57e5b5cb69d1636a931627581b11302294baeeacad8
@@ -7,16 +7,16 @@ jobs:
7
7
  runs-on: ubuntu-latest
8
8
  strategy:
9
9
  matrix:
10
- ruby-version: ['3.3', '3.2', '3.1', '3.0', '2.7']
10
+ ruby-version: ['4.0', '3.4', '3.3']
11
11
  defaults:
12
12
  run:
13
13
  shell: bash
14
14
  steps:
15
- - uses: actions/checkout@v4
16
- - uses: ruby/setup-ruby@360dc864d5da99d54fcb8e9148c14a84b90d3e88
15
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
16
+ - uses: ruby/setup-ruby@ba696adf55506673e48342a66e30f1f53cadeae0
17
17
  with:
18
18
  ruby-version: ${{ matrix.ruby-version }}
19
- - run: gem install bundler:2.4.22
19
+ - run: gem install bundler:4.0.9
20
20
  - run: bundle install
21
21
  - run: bundle exec rubocop
22
22
 
@@ -25,16 +25,16 @@ jobs:
25
25
  runs-on: ubuntu-latest
26
26
  strategy:
27
27
  matrix:
28
- ruby-version: ['3.3', '3.2', '3.1', '3.0', '2.7']
28
+ ruby-version: ['4.0', '3.4', '3.3']
29
29
  defaults:
30
30
  run:
31
31
  shell: bash
32
32
  steps:
33
- - uses: actions/checkout@v4
34
- - uses: ruby/setup-ruby@360dc864d5da99d54fcb8e9148c14a84b90d3e88
33
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
34
+ - uses: ruby/setup-ruby@ba696adf55506673e48342a66e30f1f53cadeae0
35
35
  with:
36
36
  ruby-version: ${{ matrix.ruby-version }}
37
- - run: gem install bundler:2.4.22
37
+ - run: gem install bundler:4.0.9
38
38
  - run: bundle install
39
39
  - run: cat Gemfile.lock
40
40
  - run: bundle exec rspec
data/.rubocop.yml CHANGED
@@ -1,4 +1,4 @@
1
- require:
1
+ plugins:
2
2
  - rubocop-rake
3
3
  - rubocop-rspec
4
4
 
@@ -9,7 +9,7 @@ AllCops:
9
9
  - "Rakefile"
10
10
  - "bin/**/*"
11
11
  - "spec/fixtures/**/*"
12
- TargetRubyVersion: 2.5
12
+ TargetRubyVersion: 3.3
13
13
 
14
14
  Layout/EmptyLinesAroundAttributeAccessor:
15
15
  Enabled: true
@@ -42,10 +42,14 @@ RSpec/ContextWording:
42
42
  - and
43
43
  RSpec/ExampleLength:
44
44
  Enabled: true
45
- Max: 10
45
+ Max: 15 # Increased for integration tests
46
46
  RSpec/ExpectInHook:
47
+ Enabled: false # Disabled to allow expect in setup for integration tests
48
+ RSpec/ExpectInLet:
49
+ Enabled: false # Disabled to balance style guidelines with testing ease
50
+ RSpec/SpecFilePathFormat:
47
51
  Enabled: true
48
- RSpec/FilePath:
52
+ RSpec/SpecFilePathSuffix:
49
53
  Enabled: true
50
54
  RSpec/InstanceVariable:
51
55
  Enabled: true
@@ -56,7 +60,7 @@ RSpec/LetSetup:
56
60
  RSpec/MessageSpies:
57
61
  Enabled: true
58
62
  RSpec/MultipleExpectations:
59
- Enabled: true
63
+ Max: 5 # Increased for integration tests that verify multiple aspects
60
64
  RSpec/MultipleMemoizedHelpers:
61
65
  Enabled: false
62
66
  RSpec/NamedSubject:
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 3.2.2
1
+ 3.4.2
data/Gemfile CHANGED
@@ -4,11 +4,12 @@ source 'https://rubygems.org'
4
4
  gemspec
5
5
 
6
6
  # Development dependencies
7
- gem 'bundler', '~> 2.3'
8
- gem 'byebug'
9
- gem 'pry-byebug'
7
+ gem 'bundler', '~> 4.0'
8
+ gem 'byebug', '~> 13.0'
9
+ gem 'logger' # Required for Ruby 4.0+ (no longer in stdlib)
10
+ gem 'pry-byebug', '~> 3.12'
10
11
  gem 'rake', '~> 13.0'
11
- gem 'rubocop', '~> 1.59'
12
- gem 'rubocop-rake', '~> 0.6.0'
13
- gem 'rubocop-rspec', '~> 2.16'
14
- gem 'simplecov'
12
+ gem 'rubocop', '~> 1.86'
13
+ gem 'rubocop-rake', '~> 0.6'
14
+ gem 'rubocop-rspec', '~> 3.0'
15
+ gem 'simplecov'
@@ -0,0 +1,77 @@
1
+ # Migration Guide: awesome_print to amazing_print
2
+
3
+ ## Overview
4
+
5
+ Starting with version 2.1.0, rspec-snapshot has migrated from `awesome_print` to `amazing_print`. The `amazing_print` gem is an actively maintained fork of `awesome_print`, which is no longer maintained.
6
+
7
+ ## Backward Compatibility
8
+
9
+ **Good news!** You do **NOT** need to update your existing snapshots. The gem defaults to the classic hash syntax (`:foo => value`) for backward compatibility with existing snapshots created using `awesome_print`.
10
+
11
+ ## Configuration Options
12
+
13
+ ### Classic Syntax (Default)
14
+
15
+ By default, the gem uses classic hash rocket syntax to maintain compatibility with existing snapshots:
16
+
17
+ ```ruby
18
+ {
19
+ :foo => {
20
+ :bar => [
21
+ [0] 1,
22
+ [1] 2,
23
+ [2] 3
24
+ ]
25
+ },
26
+ :baz => true
27
+ }
28
+ ```
29
+
30
+ This is the default behavior - no configuration needed.
31
+
32
+ ### Modern Syntax (Optional)
33
+
34
+ If you want to use the modern Ruby 2.0+ hash syntax in your snapshots, you can opt-in by configuring RSpec:
35
+
36
+ ```ruby
37
+ RSpec.configure do |config|
38
+ config.snapshot_hash_syntax = :modern
39
+ end
40
+ ```
41
+
42
+ This will produce:
43
+
44
+ ```ruby
45
+ {
46
+ foo: {
47
+ bar: [
48
+ [0] 1,
49
+ [1] 2,
50
+ [2] 3
51
+ ]
52
+ },
53
+ baz: true
54
+ }
55
+ ```
56
+
57
+ **Note:** If you switch to modern syntax, you'll need to regenerate all your snapshots:
58
+
59
+ ```bash
60
+ UPDATE_SNAPSHOTS=true bundle exec rspec
61
+ ```
62
+
63
+ ## For New Projects
64
+
65
+ New projects can choose either syntax style. We recommend using `:modern` syntax for new projects as it's more consistent with modern Ruby code style.
66
+
67
+ ## Gem Compatibility
68
+
69
+ The gem will work with either `amazing_print` or `awesome_print`:
70
+
71
+ - If `amazing_print` is available, it will be used
72
+ - If only `awesome_print` is available, it will fall back to that
73
+ - The gem automatically handles the syntax conversion based on your configuration
74
+
75
+ ## Questions?
76
+
77
+ If you have any issues with the migration, please open an issue on GitHub.
data/README.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  Adds snapshot testing to RSpec, inspired by [Jest](https://jestjs.io/).
4
4
 
5
+ **This project is looking for a new maintainer, create an issue in the repo if you are interested.**
6
+
5
7
  ## Installation
6
8
 
7
9
  Add this line to your application's Gemfile:
@@ -8,6 +8,11 @@ module RSpec
8
8
  config.add_setting :snapshot_dir, default: :relative
9
9
 
10
10
  config.add_setting :snapshot_serializer, default: nil
11
+
12
+ # Hash syntax style for serialized output
13
+ # :classic uses hash rockets (:foo => value) for backward compatibility
14
+ # :modern uses Ruby 2.0+ syntax (foo: value)
15
+ config.add_setting :snapshot_hash_syntax, default: :classic
11
16
  end
12
17
  end
13
18
 
@@ -1,16 +1,43 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'awesome_print'
3
+ begin
4
+ require 'amazing_print'
5
+ PRINT_GEM = :amazing_print
6
+ rescue LoadError
7
+ require 'awesome_print'
8
+ PRINT_GEM = :awesome_print
9
+ end
4
10
 
5
11
  module RSpec
6
12
  module Snapshot
7
13
  # Serializes values in a human readable way for snapshots using the
8
- # awesome_print gem
14
+ # amazing_print gem (or awesome_print for backward compatibility)
9
15
  class DefaultSerializer
10
16
  # @param [*] value The value to serialize.
11
17
  # @return [String] The serialized value.
12
18
  def dump(value)
13
- value.ai(plain: true, indent: 2)
19
+ output = value.ai(plain: true, indent: 2)
20
+
21
+ # Convert modern syntax to classic syntax for backward compatibility
22
+ if use_classic_syntax? && PRINT_GEM == :amazing_print
23
+ output = convert_to_classic_syntax(output)
24
+ end
25
+
26
+ output
27
+ end
28
+
29
+ private
30
+
31
+ def use_classic_syntax?
32
+ RSpec.configuration.snapshot_hash_syntax == :classic
33
+ end
34
+
35
+ # Converts modern Ruby hash syntax (foo:) to classic syntax (:foo =>)
36
+ # for backward compatibility with existing snapshots
37
+ def convert_to_classic_syntax(output)
38
+ # Match lines with symbol keys in modern syntax
39
+ # e.g., " foo: {" becomes " :foo => {"
40
+ output.gsub(/^(\s+)(\w+):(\s)/, '\1:\2 =>\3')
14
41
  end
15
42
  end
16
43
  end
@@ -6,6 +6,8 @@ module RSpec
6
6
  module Snapshot
7
7
  # Handles File IO for snapshots
8
8
  class FileOperator
9
+ attr_reader :snapshot_path
10
+
9
11
  # Initializes the class instance, and creates the snapshot directory for
10
12
  # the current test if needed.
11
13
  #
@@ -48,7 +48,7 @@ module RSpec
48
48
  end
49
49
 
50
50
  def description
51
- "to match a snapshot containing: \"#{@expected}\""
51
+ "to match a snapshot: '#{@file_operator.snapshot_path}'"
52
52
  end
53
53
 
54
54
  def diffable?
@@ -2,6 +2,6 @@
2
2
 
3
3
  module RSpec
4
4
  module Snapshot
5
- VERSION = '2.0.3'
5
+ VERSION = '2.2.0'
6
6
  end
7
7
  end
@@ -22,9 +22,9 @@ Gem::Specification.new do |spec|
22
22
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
23
23
  spec.require_paths = ['lib']
24
24
 
25
- spec.required_ruby_version = '>= 2.5.0'
25
+ spec.required_ruby_version = '>= 3.3.0'
26
26
 
27
- spec.add_dependency 'awesome_print', '> 1.0.0'
27
+ spec.add_dependency 'amazing_print', '~> 2.0'
28
28
  spec.add_dependency 'rspec', '> 3.0.0'
29
29
  spec.metadata['rubygems_mfa_required'] = 'true'
30
30
  end
metadata CHANGED
@@ -1,29 +1,28 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-snapshot
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.3
4
+ version: 2.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Levin
8
- autorequire:
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 2024-04-02 00:00:00.000000000 Z
10
+ date: 2026-04-03 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
- name: awesome_print
13
+ name: amazing_print
15
14
  requirement: !ruby/object:Gem::Requirement
16
15
  requirements:
17
- - - ">"
16
+ - - "~>"
18
17
  - !ruby/object:Gem::Version
19
- version: 1.0.0
18
+ version: '2.0'
20
19
  type: :runtime
21
20
  prerelease: false
22
21
  version_requirements: !ruby/object:Gem::Requirement
23
22
  requirements:
24
- - - ">"
23
+ - - "~>"
25
24
  - !ruby/object:Gem::Version
26
- version: 1.0.0
25
+ version: '2.0'
27
26
  - !ruby/object:Gem::Dependency
28
27
  name: rspec
29
28
  requirement: !ruby/object:Gem::Requirement
@@ -53,6 +52,7 @@ files:
53
52
  - ".ruby-version"
54
53
  - Gemfile
55
54
  - LICENSE.md
55
+ - MIGRATION_GUIDE.md
56
56
  - README.md
57
57
  - Rakefile
58
58
  - bin/console
@@ -70,7 +70,6 @@ licenses:
70
70
  - MIT
71
71
  metadata:
72
72
  rubygems_mfa_required: 'true'
73
- post_install_message:
74
73
  rdoc_options: []
75
74
  require_paths:
76
75
  - lib
@@ -78,15 +77,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
78
77
  requirements:
79
78
  - - ">="
80
79
  - !ruby/object:Gem::Version
81
- version: 2.5.0
80
+ version: 3.3.0
82
81
  required_rubygems_version: !ruby/object:Gem::Requirement
83
82
  requirements:
84
83
  - - ">="
85
84
  - !ruby/object:Gem::Version
86
85
  version: '0'
87
86
  requirements: []
88
- rubygems_version: 3.4.10
89
- signing_key:
87
+ rubygems_version: 3.6.2
90
88
  specification_version: 4
91
89
  summary: RSpec Snapshot Matcher
92
90
  test_files: []