Skip to content

Instantly share code, notes, and snippets.

@semanticart
Created February 17, 2009 16:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save semanticart/65824 to your computer and use it in GitHub Desktop.
Save semanticart/65824 to your computer and use it in GitHub Desktop.
# 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