Giter Site home page Giter Site logo

Comments (7)

bethesque avatar bethesque commented on September 13, 2024

Not sold on this idea, I think it would be even more awkward to specify matcher for every value than to specify a large hash. Imagine

$person.address.street => "...",
$person.address.suburb => "...",
$person.address.postcode => "...",
$person.address.state => "...",
$person.address.country => "...",

vs

{ "person" : 
{ "address" : {
  "street: "...',
  "suburb: "...',
  "postcode": "...',
  "state": "...',
  "country": "...'  }
}

This is a simple example, but imagine some deeply nested hashes - you'd have to repeat the full path to each node for each value, which would end up much more typing than just specifying a hash. Using a hash, you also get the benefit of human readable documentation - the JSON is much more communicative than json paths, in my opinion.

Maybe I've misunderstood what you mean though?

from pact-ruby.

uglyog avatar uglyog commented on September 13, 2024

We want the comparison to be composable. So for your example, we would do something like:

"/organisation/person" =>  {
    "address" : {
        "street: "...',
        "suburb: "...',
        "postcode": "...',
        "state": "...',
        "country": "...'  }
    }
},
"//product" => {
    ...
}

That may we're only validating the subset of the document we're interested in. For JSON it may not make much sense, but when you have a SOAP based service, you want to skip all the SOAP junk.

from pact-ruby.

bethesque avatar bethesque commented on September 13, 2024

You make a good point about the SOAP. Paths do make more sense for XML.

Generating the mock response would be a bit trickier though - would we put a product node in the top level of the response in your example above?

from pact-ruby.

uglyog avatar uglyog commented on September 13, 2024

No, the // means anywhere in the document.

The response for the client would have to be generated somehow. Maybe in a similar way to the Pact Terms.

Maybe we should look at how Brent is thinking of doing it in his project because he wants to do something similar.

from pact-ruby.

bethesque avatar bethesque commented on September 13, 2024

Yeah, I get the double slash - we'd have to pick an arbitrary place to put the hash in in the response though, which would be tricky. Deterministic/random? Good idea about talking to Brent.

from pact-ruby.

jagregory avatar jagregory commented on September 13, 2024

We should also bare in mind all the XML junk around namespaces and attributes. Do we validate using a query that contains that complexity (//v123:order[@type='online']) or by some simple query with a chunk of XML as a value? The more complex the query, the harder it would be to do any automagic generation of a response.

from pact-ruby.

YOU54F avatar YOU54F commented on September 13, 2024

Closing this as matching based on the 2.0 spec has been implemented

https://github.com/pact-foundation/pact-specification/tree/version-2?tab=readme-ov-file#supported-matchers

from pact-ruby.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.