Skip to content

Added super_diff gem for improved diffing in tests #953

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 4 commits into from
May 18, 2025

Conversation

numbata
Copy link
Contributor

@numbata numbata commented May 9, 2025

Leverage the super_diff gem to significantly enhance the clarity of diffs in failing RSpec tests.

Before:

       expected: [{"in"=>"header", "name"=>"postMultipleNestedParamsInBody", "required"=>true, "schema"=>{"$ref"=>"#/definitions/postMultipleNestedParamsInBody"}}]
            got: [{"in"=>"body", "name"=>"postMultipleNestedParamsInBody", "required"=>true, "schema"=>{"$ref"=>"#/definitions/postMultipleNestedParamsInBody"}}]

       (compared using eql?)

       Diff:
       @@ -1,4 +1,4 @@
       -[{"in"=>"header",
       +[{"in"=>"body",
          "name"=>"postMultipleNestedParamsInBody",
          "required"=>true,
          "schema"=>{"$ref"=>"#/definitions/postMultipleNestedParamsInBody"}}]

After:

       expected: [{ "name" => "postMultipleNestedParamsInBody", "in" => "header", "required" => true, "schema" => { "$ref" => "#/definitions/postMultipleNestedParamsInBody" } }]
            got: [{ "name" => "postMultipleNestedParamsInBody", "in" => "body", "required" => true, "schema" => { "$ref" => "#/definitions/postMultipleNestedParamsInBody" } }]

       (compared using eql?)

       Diff:

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

         [
           {
             "name" => "postMultipleNestedParamsInBody",
       -     "in" => "header",
       +     "in" => "body",
             "required" => true,
             "schema" => {
               "$ref" => "#/definitions/postMultipleNestedParamsInBody"
             }
           }
         ]

@dblock
Copy link
Member

dblock commented May 11, 2025

Any reason not to require it all the time?

@numbata numbata changed the title Improved spec diffing with optional super_diff Added super_diff extension for improved diffing in tests May 12, 2025
@numbata numbata changed the title Added super_diff extension for improved diffing in tests Added super_diff gem for improved diffing in tests May 12, 2025
@numbata
Copy link
Contributor Author

numbata commented May 12, 2025

@dblock actually, no real reason. It can makes the diffs a bit longer, and if core code has issues the report can grow indefinitely.

@olivier-thatch
Copy link

👍 Nice change, I was also annoyed by how hard the diffs were to parse when working on #951.

@dblock
Copy link
Member

dblock commented May 13, 2025

CI looks borked :(

@numbata
Copy link
Contributor Author

numbata commented May 13, 2025

@dblock true. Because of fresh changes in ruby-dev. #954 should fix it.

@dblock
Copy link
Member

dblock commented May 14, 2025

Rebase this one?

@numbata numbata force-pushed the super_diff_usage branch from 9cde5ae to 4bcab24 Compare May 14, 2025 20:09
@numbata
Copy link
Contributor Author

numbata commented May 14, 2025

@dblock done

@dblock dblock merged commit e0282ab into ruby-grape:master May 18, 2025
21 checks passed
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.

3 participants