Skip to content

Commit

Permalink
add proper specs
Browse files Browse the repository at this point in the history
  • Loading branch information
grosser committed Dec 28, 2011
1 parent e1de65d commit 49cbd7c
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions spec/youtube_search_spec.rb
Expand Up @@ -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"
Expand All @@ -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('</entry>','<yt:noembed/></entry>')
video = YoutubeSearch.parse(xml).first
video["embeddable"].should == false
end

it "is not embeddable if private is set" do
xml = canned_xml.sub('</entry>','<yt:private/></entry>')
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"
Expand Down

0 comments on commit 49cbd7c

Please sign in to comment.