Permalink
Browse files

Added tests for Columbus class.

  • Loading branch information...
1 parent 5dc615d commit 3a0be890c50db406f578c52cb3f85aaa71785849 @jnunemaker committed Mar 26, 2009
Showing with 326 additions and 10 deletions.
  1. +9 −8 lib/columbus.rb
  2. +22 −2 test/columbus_test.rb
  3. +295 −0 test/fixtures/railsquicktips.html
View
@@ -33,14 +33,15 @@ def all
end
end
- def link_to_feed(element)
- link = Link.new(url, element.attributes['href'], element.attributes['title'])
- Feed.new(link.absolute_url, link.clean_title)
- end
+ private
+ def link_to_feed(element)
+ link = Link.new(url, element.attributes['href'], element.attributes['title'])
+ Feed.new(link.absolute_url, link.clean_title)
+ end
- def parse_links(html)
- Hpricot(html).search('link').select do |link|
- link.attributes['type'] =~ /application\/(rss|atom)\+xml/i
+ def parse_links(html)
+ Hpricot(html).search('link').select do |link|
+ link.attributes['type'] =~ /application\/(rss|atom)\+xml/i
+ end
end
- end
end
View
@@ -1,7 +1,27 @@
require 'test_helper'
class ColumbusTest < Test::Unit::TestCase
- should "probably rename this file and start testing for real" do
- flunk "hey buddy, you should probably rename this file and start testing for real"
+ context "Initialization" do
+ should "accept a url" do
+ Columbus.new('http://foobar.com').url.should == 'http://foobar.com'
+ end
end
+
+ should "be able to get primary feed" do
+ FakeWeb.register_uri(:get, "http://railstips.org/", :string => fixture_file('railstips.html'))
+ FakeWeb.register_uri(:get, "http://feeds.feedburner.com/railstips", :string => fixture_file('railstips_feedburner.html'))
+ expected = Columbus::Feed.new('http://feeds.feedburner.com/railstips', 'Railstips Articles')
+ Columbus.new('http://railstips.org').primary.should == expected
+ end
+
+ should "be able to get all feeds" do
+ FakeWeb.register_uri(:get, "http://railstips.org/", :string => fixture_file('railstips.html'))
+ FakeWeb.register_uri(:get, "http://feeds.feedburner.com/railstips", :string => fixture_file('railstips_feedburner.html'))
+ FakeWeb.register_uri(:get, "http://feeds.feedburner.com/railsquicktips", :string => fixture_file('railsquicktips.html'))
+ Columbus.new('http://railstips.org').all.should == [
+ Columbus::Feed.new('http://feeds.feedburner.com/railstips', 'Railstips Articles'),
+ Columbus::Feed.new('http://feeds.feedburner.com/railsquicktips', 'Rails Quick Tips (links)')
+ ]
+ end
+
end
Oops, something went wrong.

0 comments on commit 3a0be89

Please sign in to comment.