require File.dirname(__FILE__) + '/test_helper.rb'
class TestYahooMusicRelease < Test::Unit::TestCase
def test_video_initialization_from_alias
flexmock(Video).should_receive(:fetch_and_parse).
once.with("video/hznHivqrbHHZBZNXB").
and_return(Hpricot::XML(fixture(:there_there)))
assert_nothing_raised do
@video = Video.new("hznHivqrbHHZBZNXB")
end
end
def test_artist_nonexistent_id_error
flexmock(Video).should_receive(:fetch_and_parse).
once.with("video/nil").
and_return(Hpricot::XML(fixture(:nil_video)))
assert_raise MTVNetworkServiceError do
@artist = Video.new("nil")
end
end
def test_video_class_attributes_and_associations
flexmock(Video).should_receive(:fetch_and_parse).
once.with("video/hznHivqrbHHZBZNXB").
and_return(Hpricot::XML(fixture(:there_there)))
assert_nothing_raised do
@video = Video.new("hznHivqrbHHZBZNXB")
end
assert ! Video.attributes.empty?
Video.attributes.keys.each do |attribute|
assert_respond_to @video, attribute
end
end
def test_video_instance_variables
flexmock(Video).should_receive(:fetch_and_parse).
once.with("video/hznHivqrbHHZBZNXB").
and_return(Hpricot::XML(fixture(:there_there)))
assert_nothing_raised do
@video = Video.new("hznHivqrbHHZBZNXB")
end
assert_equal @video.id, "hznHivqrbHHZDPSP"
assert_equal @video.title, "There There"
assert_equal @video.director, "Chris Hopewell"
end
end