Join GitHub today
Needs tests, but would like comments. Launch visual diff tool for comparing registered stub bodies and attempted request #138
I found myself debugging some XML for an external service and found it very difficult doing a spot-the-difference on a huge wall of text.
This will popup opendiff against all the registered stubs and the attempted request.
Very cool idea with using the diff tool to spot the differences. It can be very useful in some circumstances.
I'm not sure webmock should depend on any external tools, but I can see you made it configurable, so it's an option.
Maybe it would be better to declare a need to use diff tool as webmock configuration. I.e WebMock.use_diff_tool or something.
I'm not sure the diff tool should be initialized within exception constructor. I would rather imagine that the exception is
If I have 5 stubs declared, it is going to open 5 windows at once, right? Did you test it with just one registered stub or many?
Thanks for your comments.
I.e. in my case only fire up for "application/xml"
It's a pain as it actually opens up windows which block the thread at the moment, so I'd like to tackle that issue too.
My first attempt was trying to parse and diff the xml tree but this approach is more pragmatic.
I'll take a look at your points and incorporate them and get back to you with an updated pull request.
I should imagine it being as useful for json.
Another approach which would be less intrusive (but more work), would be to do some nice diffing and colouring in the terminal output.
Another improvement to the output would be optional Ruby 1.9 hash syntax in the example stubs.
This comment has been minimized.
This comment has been minimized.Show comment Hide comment
I'm actually going to close this pull request as I've no immediate need to introduce this functionality and so don't intend to put the time in to do the necessary cleanup. I have found that complementing WebMock with https://github.com/myronmarston/vcr solves my issue in a human-friendly way.
I may reopen if I decide to clean up the code. Thanks for the comments.