diff --git a/spec/formatters/example_xml/flickr.xml b/spec/formatters/example_xml/flickr.xml new file mode 100644 index 0000000..dcc53a3 --- /dev/null +++ b/spec/formatters/example_xml/flickr.xml @@ -0,0 +1,15 @@ + + + 1.0 + photo + Bacon Lollys + ‮‭‬bees‬ + http://www.flickr.com/photos/bees/ + + 3600 + Flickr + http://www.flickr.com/ + 500 + 375 + http://farm4.static.flickr.com/3040/2362225867_4a87ab8baf.jpg + diff --git a/spec/formatters/example_xml/hulu.xml b/spec/formatters/example_xml/hulu.xml new file mode 100644 index 0000000..55a5e38 --- /dev/null +++ b/spec/formatters/example_xml/hulu.xml @@ -0,0 +1,2 @@ + +http://www.hulu.com/video296NBC3600http://thumbnails.hulu.com/8/500/23678_145x80_manicured__SIXr9mO9sUO3dYt+S-XTIw.jpg<object width="512" height="296"><param name="movie" value="http://www.hulu.com/embed/0-njKp22bl4GivFXH0lh5w"></param><embed src="http://www.hulu.com/embed/0-njKp22bl4GivFXH0lh5w" type="application/x-shockwave-flash" width="512" height="296"></embed></object>5121451.080HuluWed, May 21, 2008 (Late Night with Conan O'Brien) diff --git a/spec/formatters/example_xml/viddler.xml b/spec/formatters/example_xml/viddler.xml new file mode 100644 index 0000000..7ecf858 --- /dev/null +++ b/spec/formatters/example_xml/viddler.xml @@ -0,0 +1,20 @@ + + + 1.0 + video + 437 + 288 + iPhone macro lens demonstration + + http://www.viddler.com/explore/cdevroe/videos/424/ + cdevroe + http://www.viddler.com/explore/cdevroe/ + Viddler + http://www.viddler.com/ + http://cdn-thumbs.viddler.com/thumbnail_2_1646c55_v1.jpg + + 437 + 288 + + diff --git a/spec/formatters/example_xml/youtube.xml b/spec/formatters/example_xml/youtube.xml new file mode 100644 index 0000000..88415ab --- /dev/null +++ b/spec/formatters/example_xml/youtube.xml @@ -0,0 +1,2 @@ + +http://www.youtube.com/Auto-Tune the News #8: dragons. geese. Michael Vick. (ft. T-Pain)<object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/bDOYN-6gdRE&fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/bDOYN-6gdRE&fs=1" type="application/x-shockwave-flash" width="425" height="344" allowscriptaccess="always" allowfullscreen="true"></embed></object>schmoyoho3444251.0http://www.youtube.com/user/schmoyohoYouTubevideo diff --git a/spec/formatters/lib_xml_spec.rb b/spec/formatters/lib_xml_spec.rb new file mode 100644 index 0000000..6204fd3 --- /dev/null +++ b/spec/formatters/lib_xml_spec.rb @@ -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