From cb79a3ae6b4217f5a92839c9ba8811bd8a69756d Mon Sep 17 00:00:00 2001 From: Phan Le Date: Fri, 24 Feb 2012 08:12:09 -0800 Subject: [PATCH] More changes --- feed_parser.rb | 17 +---------------- feed_parser_spec.rb | 5 +++-- 2 files changed, 4 insertions(+), 18 deletions(-) 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