On May 4, 2009, at 1:28 AM, aslak hellesoy wrote:
Is there a good rule of thumb for when you make exceptions to the
‘no stubbing’ philosophy of Cucumber?
This is the rule of thumb: http://wiki.github.com/aslakhellesoy/cucumber/mocking-and-stubbing-with-cucumber
I’m in a similar boat as Matt. My app does geocoding using Andre
Lewis’ excellent geokit gem (and the Rails plugin). That stuff hits
web-based geocoders (Google in my case). I also scrape other web sites.
So, in order to make my testing executable without a net connection
and avoid extra traffic on other folks’ sites from my tests, I stub
out the actual net call with code like this:
@xml = File.read(RAILS_ROOT + “/spec/fixtures/geocodes/” + datafile)
response = MockSuccess.new
I also make use of FakeWeb in a couple places to do a similar thing
for the scraping of sites. I have a rake task that grabs fresh
versions of the pages I’m going to scrape and deposits it into my spec/
fixtures directory. If I run that every couple of days, I reduce my
risk of having my fixture data diverge too far from what the
production app actually sees.