Permalink
Browse files

adds some initial specs around the libxml formatter

  • Loading branch information...
1 parent 6413984 commit f99e738be14291d2e7b4ac8265ffb64f2c52ae73 @jspillers jspillers committed Feb 3, 2010
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="utf-8" standalone="yes"?>
+<oembed>
+ <version>1.0</version>
+ <type>photo</type>
+ <title>Bacon Lollys</title>
+ <author_name>‮‭‬bees‬</author_name>
+ <author_url>http://www.flickr.com/photos/bees/</author_url>
+
+ <cache_age>3600</cache_age>
+ <provider_name>Flickr</provider_name>
+ <provider_url>http://www.flickr.com/</provider_url>
+ <width>500</width>
+ <height>375</height>
+ <url>http://farm4.static.flickr.com/3040/2362225867_4a87ab8baf.jpg</url>
+</oembed>
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<oembed><provider_url>http://www.hulu.com/</provider_url><type>video</type><height>296</height><author_name>NBC</author_name><cache_age>3600</cache_age><thumbnail_url>http://thumbnails.hulu.com/8/500/23678_145x80_manicured__SIXr9mO9sUO3dYt+S-XTIw.jpg</thumbnail_url><html>&lt;object width="512" height="296"&gt;&lt;param name="movie" value="http://www.hulu.com/embed/0-njKp22bl4GivFXH0lh5w"&gt;&lt;/param&gt;&lt;embed src="http://www.hulu.com/embed/0-njKp22bl4GivFXH0lh5w" type="application/x-shockwave-flash" width="512" height="296"&gt;&lt;/embed&gt;&lt;/object&gt;</html><width>512</width><thumbnail_width>145</thumbnail_width><version>1.0</version><thumbnail_height>80</thumbnail_height><provider_name>Hulu</provider_name><title>Wed, May 21, 2008 (Late Night with Conan O'Brien)</title></oembed>
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<oembed>
+ <version>1.0</version>
+ <type>video</type>
+ <width>437</width>
+ <height>288</height>
+ <title>iPhone macro lens demonstration</title>
+
+ <url>http://www.viddler.com/explore/cdevroe/videos/424/</url>
+ <author_name>cdevroe</author_name>
+ <author_url>http://www.viddler.com/explore/cdevroe/</author_url>
+ <provider>Viddler</provider>
+ <provider_url>http://www.viddler.com/</provider_url>
+ <thumbnail_url>http://cdn-thumbs.viddler.com/thumbnail_2_1646c55_v1.jpg</thumbnail_url>
+
+ <thumbnail_width>437</thumbnail_width>
+ <thumbnail_height>288</thumbnail_height>
+ <html><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width=
+"437" height="288" id="viddlerplayer-1646c55"><param name="movie" value="http://www.viddler.com/player/1646c55/" /><param name="allowScriptAccess" value="always" /><param name="wmode" value="transparent" /><param name="allowFullScreen" value="true" /><embed src="http://www.viddler.com/player/1646c55/" width="437" height="288" type="application/x-shockwave-flash" allowScriptAccess="always" allowFullScreen="true" wmode="transparent" name="viddlerplayer-1646c55" ></embed></object></html>
+</oembed>
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="utf-8"?>
+<oembed><provider_url>http://www.youtube.com/</provider_url><title>Auto-Tune the News #8: dragons. geese. Michael Vick. (ft. T-Pain)</title><html>&lt;object width="425" height="344"&gt;&lt;param name="movie" value="http://www.youtube.com/v/bDOYN-6gdRE&amp;fs=1"&gt;&lt;/param&gt;&lt;param name="allowFullScreen" value="true"&gt;&lt;/param&gt;&lt;param name="allowscriptaccess" value="always"&gt;&lt;/param&gt;&lt;embed src="http://www.youtube.com/v/bDOYN-6gdRE&amp;fs=1" type="application/x-shockwave-flash" width="425" height="344" allowscriptaccess="always" allowfullscreen="true"&gt;&lt;/embed&gt;&lt;/object&gt;</html><author_name>schmoyoho</author_name><height>344</height><width>425</width><version>1.0</version><author_url>http://www.youtube.com/user/schmoyoho</author_url><provider_name>YouTube</provider_name><type>video</type></oembed>
@@ -0,0 +1,62 @@
+require File.join(File.dirname(__FILE__), "../spec_helper")
+require File.join(File.dirname(__FILE__), "../../lib/oembed_links/formatters/lib_xml.rb")
+
+describe OEmbed::Formatters::LibXML do
+
+ describe "raw xml from youtube" do
+ before(:each) do
+ @youtube_xml = File.open(
+ File.join(File.dirname(__FILE__), "example_xml/youtube.xml"),
+ "rb"
+ ).read
+ @result = OEmbed::Formatters::LibXML.new.format(@youtube_xml)
+ end
+
+ it "parsed raw xml should contain some html" do
+ @result["html"].empty?.should_not be_true
+ end
+ end
+
+ describe "raw xml from flickr" do
+ before(:each) do
+ @flickr_xml = File.open(
+ File.join(File.dirname(__FILE__), "example_xml/flickr.xml"),
+ "rb"
+ ).read
+ @result = OEmbed::Formatters::LibXML.new.format(@flickr_xml)
+ end
+
+ it "parsed raw xml should contain a url" do
+ @result["url"].should == "http://farm4.static.flickr.com/3040/2362225867_4a87ab8baf.jpg"
+ end
+ end
+
+ describe "raw xml from viddler" do
+ before(:each) do
+ @viddler_xml = File.open(
+ File.join(File.dirname(__FILE__), "example_xml/viddler.xml"),
+ "rb"
+ ).read
+ @result = OEmbed::Formatters::LibXML.new.format(@viddler_xml)
+ end
+
+ it "parsed raw xml should contain some html" do
+ @result["html"].empty?.should_not be_true
+ end
+ end
+
+ describe "raw xml from hulu" do
+ before(:each) do
+ @hulu_xml = File.open(
+ File.join(File.dirname(__FILE__), "example_xml/hulu.xml"),
+ "rb"
+ ).read
+ @result = OEmbed::Formatters::LibXML.new.format(@hulu_xml)
+ end
+
+ it "parsed raw xml should contain some html" do
+ @result["html"].empty?.should_not be_true
+ end
+ end
+
+end # Oembed

0 comments on commit f99e738

Please sign in to comment.