Created
February 17, 2009 16:45
-
-
Save semanticart/65824 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# note that I copy and pasted the first entry's category tag and changed the second term to 'Robocop' to ensure that all items were being captured | |
describe "full example" do | |
before :each do | |
@xml = File.read('spec/sax-machine/atom.xml') | |
class AtomEntry | |
include SAXMachine | |
element :title | |
element :name, :as => :author | |
element "feedburner:origLink", :as => :url | |
element :summary | |
element :content | |
element :published | |
elements :category, :as => :categories, :value => :term | |
end | |
class Atom | |
include SAXMachine | |
element :title | |
element :link, :value => :href, :as => :url, :with => {:type => "text/html"} | |
element :link, :value => :href, :as => :feed_url, :with => {:type => "application/atom+xml"} | |
elements :entry, :as => :entries, :class => AtomEntry | |
end | |
end # before | |
it "should parse the url" do | |
f = Atom.parse(@xml) | |
f.url.should == "http://www.pauldix.net/" | |
end | |
it "should get the categories" do | |
f = Atom.parse(@xml) | |
f.entries.first.categories.should == ['Tahiti', 'Robocop'] | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment