Refactored Release and Track models, fixed tests
This commit is contained in:
Vendored
+1
@@ -0,0 +1 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?><metadata xmlns="http://musicbrainz.org/ns/mmd-2.0#"><artist type="Group" id="69b39eab-6577-46a4-a9f5-817839092033"><name>Kasabian</name><sort-name>Kasabian</sort-name><country>GB</country><life-span><begin>1999</begin></life-span><relation-list target-type="url"><relation type="allmusic"><target>http://allmusic.com/artist/p678134</target></relation><relation type="wikipedia"><target>http://en.wikipedia.org/wiki/Kasabian</target></relation><relation type="microblog"><target>http://twitter.com/kasabianhq</target></relation><relation type="BBC Music page"><target>http://www.bbc.co.uk/music/artists/69b39eab-6577-46a4-a9f5-817839092033</target></relation><relation type="discogs"><target>http://www.discogs.com/artist/Kasabian</target></relation><relation type="social network"><target>http://www.facebook.com/kasabian</target></relation><relation type="IMDb"><target>http://www.imdb.com/name/nm1868442/</target></relation><relation type="official homepage"><target>http://www.kasabian.co.uk/</target></relation><relation type="myspace"><target>http://www.myspace.com/kasabian</target></relation><relation type="youtube"><target>http://www.youtube.com/kasabianvevo</target></relation><relation type="youtube"><target>http://www.youtube.com/user/KasabianTour</target></relation></relation-list></artist></metadata>
|
||||
@@ -1,20 +1,35 @@
|
||||
require "spec_helper"
|
||||
|
||||
describe MusicBrainz do
|
||||
before(:all) {
|
||||
@old_cache_path = MusicBrainz::Tools::Cache.cache_path
|
||||
}
|
||||
|
||||
before(:each) {
|
||||
STDOUT.stub!(:puts)
|
||||
$stdout.stub!(:puts)
|
||||
MusicBrainz::Tools::Cache.cache_path = nil
|
||||
}
|
||||
|
||||
after(:all) {
|
||||
MusicBrainz.cache_path.nil
|
||||
MusicBrainz::Tools::Cache.cache_path = @old_cache_path
|
||||
}
|
||||
|
||||
it "allows deprecated use of cache_path" do
|
||||
MusicBrainz::Tools::Cache.cache_path = "some/path"
|
||||
MusicBrainz::cache_path.should == "some/path"
|
||||
end
|
||||
|
||||
it "allows deprecated use of cache_path=" do
|
||||
MusicBrainz.cache_path = "some/path"
|
||||
MusicBrainz::Tools::Cache.cache_path.should == "some/path"
|
||||
end
|
||||
|
||||
it "allows deprecated use of query_interval" do
|
||||
MusicBrainz::Tools::Proxy.query_interval = 2
|
||||
MusicBrainz::query_interval.should == 2
|
||||
end
|
||||
|
||||
it "allows deprecated use of query_interval=" do
|
||||
MusicBrainz.query_interval = 2
|
||||
MusicBrainz::Tools::Proxy.query_interval.should == 2
|
||||
end
|
||||
|
||||
@@ -11,32 +11,17 @@ describe MusicBrainz::Tools::Cache do
|
||||
end
|
||||
|
||||
before(:each) do
|
||||
@test_response = ::StringIO.new('<?xml version="1.0" encoding="UTF-8"?>'+
|
||||
'<metadata xmlns="http://musicbrainz.org/ns/mmd-2.0#">'+
|
||||
'<artist type="Group" id="69b39eab-6577-46a4-a9f5-817839092033">'+
|
||||
'<name>Kasabian</name><sort-name>Kasabian</sort-name><country>GB</country>'+
|
||||
'<life-span><begin>1999</begin></life-span><relation-list target-type="url">'+
|
||||
'<relation type="allmusic"><target>http://allmusic.com/artist/p678134</target>'+
|
||||
'</relation><relation type="wikipedia"><target>http://en.wikipedia.org/wiki/Kasabian</target>'+
|
||||
'</relation><relation type="microblog"><target>http://twitter.com/kasabianhq</target>'+
|
||||
'</relation><relation type="BBC Music page"><target>'+
|
||||
'http://www.bbc.co.uk/music/artists/69b39eab-6577-46a4-a9f5-817839092033</target></relation>'+
|
||||
'<relation type="discogs"><target>http://www.discogs.com/artist/Kasabian</target></relation>'+
|
||||
'<relation type="social network"><target>http://www.facebook.com/kasabian</target></relation>'+
|
||||
'<relation type="IMDb"><target>http://www.imdb.com/name/nm1868442/</target></relation>'+
|
||||
'<relation type="official homepage"><target>http://www.kasabian.co.uk/</target></relation>'+
|
||||
'<relation type="myspace"><target>http://www.myspace.com/kasabian</target></relation>'+
|
||||
'<relation type="youtube"><target>http://www.youtube.com/kasabianvevo</target></relation>'+
|
||||
'<relation type="youtube"><target>http://www.youtube.com/user/KasabianTour</target></relation>'+
|
||||
'</relation-list></artist></metadata>')
|
||||
file_path = File.join(File.dirname(__FILE__), "../fixtures/kasabian.xml")
|
||||
@test_response = ::StringIO.new(File.open(file_path).gets)
|
||||
end
|
||||
|
||||
context "with cache enabled" do
|
||||
it "calls get contents only once when requesting the resource twice" do
|
||||
MusicBrainz::Tools::Cache.cache_path = @tmp_cache_path
|
||||
mbid = "69b39eab-6577-46a4-a9f5-817839092033"
|
||||
|
||||
MusicBrainz::Tools::Proxy.stub(:get_contents).and_return(@test_response)
|
||||
MusicBrainz::Tools::Proxy.should_receive(:get_contents).once
|
||||
mbid = "69b39eab-6577-46a4-a9f5-817839092033"
|
||||
|
||||
File.exist?("#{@tmp_cache_path}/artist/#{mbid}?inc=url-rels").should be_false
|
||||
artist = MusicBrainz::Artist.find(mbid)
|
||||
@@ -53,9 +38,10 @@ describe MusicBrainz::Tools::Cache do
|
||||
context "with cache disabled" do
|
||||
it "calls get contents twice when requesting the resource twice" do
|
||||
MusicBrainz::Tools::Cache.cache_path = nil
|
||||
mbid = "69b39eab-6577-46a4-a9f5-817839092033"
|
||||
|
||||
MusicBrainz::Tools::Proxy.stub(:get_contents).and_return(@test_response)
|
||||
MusicBrainz::Tools::Proxy.should_receive(:get_contents).twice
|
||||
mbid = "69b39eab-6577-46a4-a9f5-817839092033"
|
||||
|
||||
File.exist?("#{@tmp_cache_path}/artist/#{mbid}?inc=url-rels").should be_false
|
||||
artist = MusicBrainz::Artist.find(mbid)
|
||||
|
||||
Reference in New Issue
Block a user