test/youtube_test.rb in muri-0.0.4 vs test/youtube_test.rb in muri-0.0.5

- old
+ new

@@ -1,12 +1,38 @@ require 'lib/muri.rb' - shared_examples_for "Youtube parse" do it "should be Youtube service" do @a.service == 'Youtube' end + it "should be valid" do + @a.valid? == true + end +end + +shared_examples_for "Youtube parse single" do + it_should_behave_like "Youtube parse" + + it "should have media api type = YOUTUBE_VIDEO" do + @a.media_api_type == Muri::YOUTUBE_VIDEO + end +end + +shared_examples_for "Youtube parse playlist" do + it_should_behave_like "Youtube parse" + + it "should have media api type = YOUTUBE_PLAYLIST" do + @a.media_api_type == Muri::YOUTUBE_PLAYLIST + end +end + +describe "Youtube parse first" do + before(:all) do + @a = Muri.parse 'http://www.youtube.com/v/4CYDFoEz8rg&hl=en_US&fs=1&' + end + it_should_behave_like "Youtube parse single" + it "should have media id" do @a.media_id == '4CYDFoEz8rg' end it "should have media api id" do @@ -21,19 +47,77 @@ @a.media_url == 'http://www.youtube.com/v/4CYDFoEz8rg' end it "should have thumbnail" do @a.media_thumbnail == 'http://i.ytimg.com/vi/4CYDFoEz8rg/default.jpg' + end +end +describe "Youtube parse second" do + before(:all) do + @a = Muri.parse 'http://www.youtube.com/watch?v=4CYDFoEz8rg' end + it_should_behave_like "Youtube parse single" + + it "should have media id" do + @a.media_id == '4CYDFoEz8rg' + end + + it "should have media api id" do + @a.media_api_id == '4CYDFoEz8rg' + end + + it "should have media url" do + @a.website == 'http://www.youtube.com/watch?v=4CYDFoEz8rg' + end + + it "should have website" do + @a.media_url == 'http://www.youtube.com/v/4CYDFoEz8rg' + end + + it "should have thumbnail" do + @a.media_thumbnail == 'http://i.ytimg.com/vi/4CYDFoEz8rg/default.jpg' + end end -describe "Youtube parse first" do + +describe "Youtube parse playlist first" do before(:all) do - @a = Muri.parse 'http://www.youtube.com/v/4CYDFoEz8rg&hl=en_US&fs=1&' + @a = Muri.parse 'http://www.youtube.com/p/57633EC69B4A10A2&hl=en_US&fs=1' end - it_should_behave_like "Youtube parse" + it_should_behave_like "Youtube parse playlist" + it "should have media id" do + @a.media_id == '57633EC69B4A10A2' + end + + it "should have media api id" do + @a.media_api_id == '57633EC69B4A10A2' + end + + it "should have media url" do + @a.website == 'http://www.youtube.com/view_play_list?p=57633EC69B4A10A2' + end + + it "should have website" do + @a.media_url == 'http://www.youtube.com/p/57633EC69B4A10A2' + end end -describe "Youtube parse second" do + +describe "Youtube parse playlist second" do before(:all) do - @a = Muri.parse 'http://www.youtube.com/watch?v=4CYDFoEz8rg' + @a = Muri.parse 'http://www.youtube.com/view_play_list?p=57633EC69B4A10A2' end - it_should_behave_like "Youtube parse" -end \ No newline at end of file + it_should_behave_like "Youtube parse playlist" + it "should have media id" do + @a.media_id == '57633EC69B4A10A2' + end + + it "should have media api id" do + @a.media_api_id == '57633EC69B4A10A2' + end + + it "should have media url" do + @a.website == 'http://www.youtube.com/view_play_list?p=57633EC69B4A10A2' + end + + it "should have website" do + @a.media_url == 'http://www.youtube.com/p/57633EC69B4A10A2' + end +end