Skip to content

Add super_diff extension #197

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

Merged
merged 1 commit into from
Mar 9, 2025
Merged

Add super_diff extension #197

merged 1 commit into from
Mar 9, 2025

Conversation

flash-gordon
Copy link
Member

super_diff is very useful in combination with rspec. There's a simple way to integrate an existing class: adding attributes_for_super_diff method is enough.

Before:

       expected: #<Test::User name="Jane" age=22>
            got: #<Test::User name="Jane" age=21>

       (compared using eql?)

       Diff:
       @@ -1 +1 @@
       -#<Test::User name="Jane" age=22>
       +#<Test::User name="Jane" age=21>

After:

       expected: #<Test::User name: "Jane", age: 22>
            got: #<Test::User name: "Jane", age: 21>

       (compared using eql?)

       Diff:

        (Key) ──────────────────────────┐
        - in expected, not in actual  
        + in actual, not in expected  
          in both expected and actual 
       └─────────────────────────────────┘

         #<Test::User {
           name: "Jane",
       -   age: 22
       +   age: 21
         }>

To use this extension, add super_diff:

Gemfile

group :test do
  gem 'super_diff'
end

Then activate the extension:
spec_helper.rb

require 'dry/struct'
Dry::Struct.load_extensions(:super_diff)

@flash-gordon flash-gordon force-pushed the super_diff-extension branch 5 times, most recently from 277d0bd to baeb491 Compare March 9, 2025 18:39
@flash-gordon flash-gordon force-pushed the super_diff-extension branch from baeb491 to 5d7e013 Compare March 9, 2025 18:48
@flash-gordon flash-gordon merged commit 05d46b6 into main Mar 9, 2025
14 checks passed
@flash-gordon flash-gordon deleted the super_diff-extension branch March 9, 2025 18:49
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.

1 participant