I'm building an http communicator class for a web service API wrapper and I'm trying to go through the BDD process in doing so. I'm having a bit of a struggle figuring out how to set up the tests in relation to isolating things appropriately as well as testing behavior vs testing implementation.
<br><br>Specifically, I&#39;m trying to set up a post method on my HttpCommunicator so I have the following:<br><br>describe FamilyTreeApi::HttpCommunicator, &quot;post&quot; do<br>it &quot;should accept an endpoint and an xml string to post&quot; # I&#39;m okay with this one
<br>it &quot;should perform post content to given endpoint&quot;<br>it &quot;should return a response object&quot;<br>end<br><br>I have written/passed the tests for the first spec, but I&#39;m having troubles figuring out how to verify behavior for the second and third, and how to mock/stub it up. I&#39;ll be using the &#39;net/https&#39; standard libraries to implement the POST action, and I know that it requires the use of a URI instance, a Net::HTTP instance, and a Net::HTTP::Post request instance. 
<br><br>I don&#39;t want to hit the actual web service each time I run the test, so I&#39;d like to stub or mock this in some way. I think I just need some guidance on how to approach something like this.<br><br>Do I just ignore the implementation details? 
<br>Do I push the actual posting of data to a private method and mock that method so that I can verify that it is being called? <br>Would you recommend I actually hit the web service?<br><br>Any help is greatly appreciated.
<br>-- <br>Jimmy Zimmerman<br><a href="http://jimmyzimmerman.com/blog/">http://jimmyzimmerman.com/blog/</a>