Forum: RSpec Cucumber features for RSS feeds

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
James B. (Guest)
on 2009-04-14 01:03
I am moving into yet another area that I possess absolutely no
experience with. In this case the realm of RSS feeds and Rails as the
consumer.

My first feature/scenario looks like this and, given the effort I had to
make to grasp the basics of features and scenarios in the crud world, I
thought it best to ask for comments before I get too far in.

Feature: Automatically Retrieve and Store Foreign Currency Exchange
Rates
  In order to set foreign currency exchange rates daily
  The automated system
  Should automatically retrieve and store central bank exchange rates
  To Reduce Costs and Protect Revenue

  Scenario:  Retrieve Exchange Rates from the Bank of Canada RSS feed
    Given an RSS feed
"http://www.bankofcanada.ca/rss/fx/noon/fx-noon-all.xml"
    When I access the RSS feed between Monday to Friday after "17:15UTC"
    Then I should see "Bank of Canada: Noon Foreign Exchange Rates"
      And I should see today's date in "yyyy-mm-dd" format

Basically, all this is doing is seeing if I can get the feed.  I suppose
that I could implement this as a direct controller call to the URL but
there is probably a better way of which I am presently unaware.  The
other thing for which I wish guidance is the proper method to parse the
feed.  I gather this is a case where I should be parsing the xml in
order to feed it to (ActiveResource?) and thence into the
currency_exchange_rates model.

Is there a recommended/preferred gem to handle this requirement?
James B. (Guest)
on 2009-04-15 20:17
Q. Is there anything special about the Rails test environment that would
inhibit an ActivieResource object from connecting to an outside URL?

I am presently working inside the console with this expression:

>> forex = ForexCASource.find

and receiving a 404 error.

The resource is defined as:

class ForexCASource < ActiveResource::Base
  self.site         =
'http://www.bankofcanada.ca/rss/fx/noon/fx-noon-all.xml'
end

I can reach the site url from a Firefox instance running on the same
host using cut and paste so the url in the site assignment is valid.
This topic is locked and can not be replied to.