diff --git a/spec/fixtures/release_group/entity.xml b/spec/fixtures/release_group/entity.xml
new file mode 100644
index 0000000..2c83c1f
--- /dev/null
+++ b/spec/fixtures/release_group/entity.xml
@@ -0,0 +1,22 @@
+
+
+
+ Empire
+ 2006-08-28
+ Album
+
+
+ http://en.wikipedia.org/wiki/Empire_(Kasabian_album)
+
+
+ http://lyrics.wikia.com/Kasabian:Empire_(2006)
+
+
+ http://www.bbc.co.uk/music/reviews/389x
+
+
+ http://www.discogs.com/master/89980
+
+
+
+
diff --git a/spec/fixtures/release_group/search.xml b/spec/fixtures/release_group/search.xml
new file mode 100644
index 0000000..738ab9e
--- /dev/null
+++ b/spec/fixtures/release_group/search.xml
@@ -0,0 +1,79 @@
+
+
+
+
+ Empire
+ Album
+
+
+
+ Kasabian
+ Kasabian
+
+
+
+
+
+ Empire
+ Official
+
+
+ Empire
+ Official
+
+
+ Empire
+ Official
+
+
+ Empire
+ Official
+
+
+ Empire
+ Official
+
+
+ Empire
+ Official
+
+
+ Empire
+ Official
+
+
+
+
+ rock
+
+
+ alternative rock
+
+
+ indie
+
+
+ rock and indie
+
+
+
+
+ Empire
+ Single
+
+
+
+ Kasabian
+ Kasabian
+
+
+
+
+
+ Empire
+ Official
+
+
+
+
+
diff --git a/spec/models/release_group_spec.rb b/spec/models/release_group_spec.rb
index fccd221..2d565e0 100644
--- a/spec/models/release_group_spec.rb
+++ b/spec/models/release_group_spec.rb
@@ -28,10 +28,14 @@ describe MusicBrainz::ReleaseGroup do
describe '.search' do
context 'without type filter' do
it "searches release group by artist name and title" do
+ response = File.open(File.join(File.dirname(__FILE__), "../fixtures/release_group/search.xml")).read
+ MusicBrainz::Client.any_instance.stub(:get_contents).with('http://musicbrainz.org/ws/2/release-group?query=artist:"Kasabian" AND releasegroup:"Empire"&limit=10').
+ and_return({ status: 200, body: response})
+
matches = MusicBrainz::ReleaseGroup.search('Kasabian', 'Empire')
matches.length.should be > 0
matches.first[:title].should == 'Empire'
- matches.first[:type].should == 'Single'
+ matches.first[:type].should == 'Album'
end
end
@@ -47,8 +51,16 @@ describe MusicBrainz::ReleaseGroup do
describe '.find_by_artist_and_title' do
it "gets first release group by artist name and title" do
+ response = File.open(File.join(File.dirname(__FILE__), "../fixtures/release_group/search.xml")).read
+ MusicBrainz::Client.any_instance.stub(:get_contents).with('http://musicbrainz.org/ws/2/release-group?query=artist:"Kasabian" AND releasegroup:"Empire"&limit=10').
+ and_return({ status: 200, body: response})
+
+ response = File.open(File.join(File.dirname(__FILE__), "../fixtures/release_group/entity.xml")).read
+ MusicBrainz::Client.any_instance.stub(:get_contents).with('http://musicbrainz.org/ws/2/release-group/6f33e0f0-cde2-38f9-9aee-2c60af8d1a61?inc=url-rels').
+ and_return({ status: 200, body: response})
+
release_group = MusicBrainz::ReleaseGroup.find_by_artist_and_title('Kasabian', 'Empire')
- release_group.id.should == '246bc928-2dc8-35ba-80ee-7a0079de1632'
+ release_group.id.should == '6f33e0f0-cde2-38f9-9aee-2c60af8d1a61'
end
end