Sha256: 81dd6faf7e0c46f9994d09ce2864ce537a71f5e1e9787cfa8c283164c99d38f6

Contents?: true

Size: 1.34 KB

Versions: 1

Compression:

Stored size: 1.34 KB

Contents

require "spec_helper"

describe MusicBrainz::Recording do
  describe '.find' do
    before(:each) {
      mock url: 'http://musicbrainz.org/ws/2/recording/b3015bab-1540-4d4e-9f30-14872a1525f7?',
           fixture: 'recording/find_b3015bab-1540-4d4e-9f30-14872a1525f7.xml'
    }
    let(:recording) {
      MusicBrainz::Recording.find("b3015bab-1540-4d4e-9f30-14872a1525f7")
    }

    it "gets no exception while loading release info" do
      expect{ recording }.to_not raise_error(Exception)
    end

    it "gets correct instance" do
      expect(recording).to be_an_instance_of(MusicBrainz::Recording)
    end

    it "gets correct track data" do
      expect(recording.title).to eq "Empire"
    end
  end

  describe '.search' do
    before(:each) {
      mock url: 'http://musicbrainz.org/ws/2/recording?query=recording:"Bound+for+the+floor" AND artist:"Local+H"&limit=10',
           fixture: 'recording/search_bound_for_the_floor_local_h.xml'
    }
    let(:matches) {
      MusicBrainz::Recording.search('Bound for the floor', 'Local H')
    }

    it "searches tracks (aka recordings) by artist name and title" do
      expect(matches).to_not be_empty
      expect(matches.first[:id]).to eq 'bb940e26-4265-4909-b128-4906d8b1079e'
      expect(matches.first[:title]).to eq "Bound for the Floor"
      expect(matches.first[:artist]).to eq "Local H"
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
musicbrainz-0.8.0 spec/models/recording_spec.rb