Ruby on Rails Saturday, January 29, 2011

So first, thanks in no small part to Marnen's rants, I've become a
complete RSpec / FactoryGirl / TDD convert. Hey, autotest coupled with
Growl is the bee knees! And I've even started pushing builds out to
Heroku to keep me honest.

Now I feel uneasy when I've written a piece of code that isn't covered
by an effective test. That's how it should be.

But I'm stumped on how to test the following, so I turn to the
collective wisdom of the RoR forum.

My app periodically needs to fetch XML data from external sites. To
avoid inadvertently pummeling the external servers, I've written some
extensions to Mechanize that observe the following rules:

- any XML data I fetch from the external site is cached
- I will NOT fetch if the most recent attempt was less than K hours ago
- I will fetch the data if it's absent or stale (i.e. older then J days)

Testing it manually, it works like a champ. But how the heck do I
automate the testing? It seems I need to fake up the Mechanize GET
method so I can simulate various failure modes, etc. Do I create a
FactoryGirl stub (or mock???). So I'm looking for suggestions and
(ideally) examples of how experienced testers would test this.

TIA.

- ff

--
Posted via http://www.ruby-forum.com/.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

No comments:

Post a Comment