Comments (11)
This might help us
https://github.com/mbklein/equivalent-xml
But I'm not sure that it gives a diff, possibly just says whether they're equivalent or not. But it might be a useful building block.
from pact-ruby.
@thetrav and @uglyog. We should start working out an XML support battle plan, so that when someone comes to implement it, we have at least a rough idea of how to make it work.
As I see it, our options are:
- Embed the XML inside a JSON document in the body node.
- Embed the match information as xpaths.
- Create an XML pact.
Thoughts?
from pact-ruby.
I have a need to implement this for a project I'm working on where we are driving new soap endpoints. As a first go, I just shoved the escaped XML into the 'body', which of course works when we have an exact string match. I'm thinking of sticking with that approach (xml in the json pactfile) but using equivalent-xml (thanks for the pointer) to match in the request dispatch.
Any thoughts on this? Ideas on where to start?
from pact-ruby.
Yay! I have lots of thoughts. Firstly, let me do a quick refactor so that the differ can be configured based on content type. Secondly, while I'm doing that, have a look at the pact-specification repo, and have a think about the matching rules we want to use, based on the principles of "be strict with what we send out, and relaxed with what we accept". Thirdly, fork this repo https://github.com/bethesque/pact-xml Fourthly, fourthly sounds like a stupid word. Fifthly, if you're still up for it, implement the Differ and DiffFormatter with lots of lovely specs.
Lots of people have asked for this feature, so it will gain you lots of nerd karma if you pull it off. Lets keep "touching base" (wanky phrase alert) as you go (if I haven't scared you off. It's really straightforward, promise...)
from pact-ruby.
Thanks. That's awesome.
I started digging around in rack_request_helper to branch off for different content types. It's quite dirty right now, just to kind of get my head around the cycle and have some very basic xml->object hydration working.
I learned late yesterday that I have to get approval on this particular project/client to contribute upstream to OSS projects, so I'm working on that. Hopefully it won't be a problem.
from pact-ruby.
Ok, finger's crossed! You're not thinking of using Nokogiri?
from pact-ruby.
No thoughts at the moment on using Nokogiri. For the first stab I just used active support to_hash because it was there. I'm guessing you mean because Nokogiri would be pretty heavy-weight & you don't want to bring it in as a dependency?
from pact-ruby.
I have no problem with Nokogiri - equivalent-xml uses Nokogiri, which is what I thought you were planning on using. I wasn't sure why you were looking at doing custom parsing of the xml?
I'd actually prefer Nokogiri to ActiveSupport! ActiveSupport messes with the serialisation of the pact as it rudely overrides the to_json methods of various things without asking. If you have a look at the codebase, you'll find my ActiveSupportSupport code - the code you need to support you when you're using ActiveSupport!
from pact-ruby.
What I'm doing right now parallels the json path—hydrate & then diff the ruby objects. Does that seem like an approach that would work for the project? First-class XML diffing & diff printing seem like much harder problems that I don't think I can take on at this time.
from pact-ruby.
I haven't given it serious thought, but the first idea that popped into my head is that you'd parse both the expected XML and actual XML to Nokogiri documents, then step though the expected tree (the same way the json diff does) and compare the current node (and attributes) to the actual node (and attributes). It sounds like the same thing as you're doing, but using Nokogiri as the hydrated Ruby object.
You do make a reasonable point about including Nokogiri as a dependency. If you think it would be just as easy without it, then go for it. Are you thinking of reusing the json diff code, or copy/modifying it? I guess the XML attribute checking logic means you can't reuse it.
from pact-ruby.
Done. See https://github.com/bethesque/pact-xml for example.
from pact-ruby.
Related Issues (20)
- Add support for consumer version selectors for deployed and released versions
- Set "enable pending" to true by default HOT 1
- Let's Encrypt certificate verify failed September 30th HOT 28
- Ruby pact-provider-verifier --enable-pending returns non-zero exit code if pending pact provider state setup fails HOT 2
- Naming collision with term-ansicolor gem HOT 1
- app_version_branch is absent in MessageProviderDSL
- Service Provider and Message Provider seem incompatible in pact_helper HOT 8
- Support for provider states with no operations
- Pact v3 specification implementation for Pact Ruby HOT 2
- Pact v4 specification implementation for Pact Ruby HOT 3
- Verify when the provider has no matching Pacts HOT 1
- "Ignoring unsupported combine AND for path" on every property HOT 2
- Set order of interactions in Pact file HOT 2
- Service provider configuration overlaps with other service providers HOT 1
- undefined method `href' for nil:NilClass (NoMethodError)
- rails pact:verify runs tests and sends to broker, then hangs HOT 3
- Pact creating conflict when using Minitest on Rails 7.1 HOT 2
- Any plan for a new release with support of Rack 3? HOT 1
- Pact No such file or directory publish_dir HOT 1
- Need Guidance on Injecting Dynamic Authentication Headers in Provider Verification HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pact-ruby.