diff --git a/models/artist.rb b/models/artist.rb index db1e556..dcf564e 100644 --- a/models/artist.rb +++ b/models/artist.rb @@ -7,10 +7,6 @@ class Artist @name = name end - def <=>(artist) - name <=> artist.name - end - def self.all MPDConnection.mpd.artists.sort.map { |artist| Artist.new(artist) } end diff --git a/spec/models/artist_spec.rb b/spec/models/artist_spec.rb index 655e610..ac7559c 100644 --- a/spec/models/artist_spec.rb +++ b/spec/models/artist_spec.rb @@ -3,9 +3,16 @@ require 'spec_helper' describe Artist do let(:artist) { Artist.new('Alice Cooper') } + let(:artists) { ['Alice Cooper', 'Jimmy Eat World', 'Dream Theater'] } it 'has attributes' do expect(artist.name).to eq('Alice Cooper') end + it 'returns all artists' do + MPDConnection.mpd.stub(:artists).and_return(artists) + expect(Artist.all).to have(3).items + expect(Artist.all.map(&:name)).to eq(artists.sort) + end + end