diff --git a/feed_parser.rb b/feed_parser.rb index 3d6e9a9..8959923 100644 --- a/feed_parser.rb +++ b/feed_parser.rb @@ -1,26 +1,11 @@ require 'rubygems' require 'nokogiri' -class FeedParser - attr_reader :file - def initialize(file) - @file = file - end - - def parse - f = File.open(file) - doc = Nokogiri::XML(f) - f.close - root = doc.css('channel') - return NewSource.new(root.css("title").first.text, root.css("link").first.text) - end - -end - class NewSource attr_reader :name, :root_url def initialize(name, root_url) @name = name @root_url = root_url end + end diff --git a/feed_parser_spec.rb b/feed_parser_spec.rb index 84beceb..33ee03b 100644 --- a/feed_parser_spec.rb +++ b/feed_parser_spec.rb @@ -1,5 +1,3 @@ -require 'rubygems' -require 'awesome_print' require File.join(File.dirname(__FILE__), 'feed_parser') describe FeedParser do @@ -16,4 +14,7 @@ subject.root_url.should == 'http://quechoa.info' end + it "has multiple news items" do + subject.should have(3).items + end end