diff --git a/spec/youtube_search_spec.rb b/spec/youtube_search_spec.rb index 2e6459f..4939ab7 100644 --- a/spec/youtube_search_spec.rb +++ b/spec/youtube_search_spec.rb @@ -6,12 +6,13 @@ end describe 'parse' do + let(:canned_xml){ File.read('spec/fixtures/search_boat.xml') } + it "can parse xml from a search" do # convert to array so we get a nice diff in case of errors - video = YoutubeSearch.parse(File.read('spec/fixtures/search_boat.xml')).first + video = YoutubeSearch.parse(canned_xml).first video["content"].should == "Top YouTube Videos on tubecrunch.blogspot.com A killer whale swims right up to a boat and shows off his best sounding motor impression." video["duration"].should == "75" - video["embeddable"].should == false video["id"].should == "http://gdata.youtube.com/feeds/api/videos/0b2U5r7Jwkc" video["published"].should == "2011-09-29T15:30:43.000Z" video["title"].should == "Killer Whale Imitates Boat Motor" @@ -20,6 +21,25 @@ video["raw"].elements.should_not == nil end + context "embeddable" do + it "is embeddable if neither private nor noembed are set" do + video = YoutubeSearch.parse(canned_xml).last + video["embeddable"].should == true + end + + it "is not embeddable if noembed is set" do + xml = canned_xml.sub('','') + video = YoutubeSearch.parse(xml).first + video["embeddable"].should == false + end + + it "is not embeddable if private is set" do + xml = canned_xml.sub('','') + video = YoutubeSearch.parse(xml).first + video["embeddable"].should == false + end + end + it "can parse xml from a playlist" do video = YoutubeSearch.parse(File.read('spec/fixtures/playlist_5F23DAF4BFE3D14C.xml'), :type => :playlist).first video["duration"].should == "192"