Sha256: 2116eba5c13b9b4392529b3523dd54b0f9d6badb9f6a2b73430c60a9f69b1a25

Contents?: true

Size: 1.77 KB

Versions: 8

Compression:

Stored size: 1.77 KB

Contents

describe RSpotify::Recommendations do

  let(:client_id) { '5ac1cda2ad354aeaa1ad2693d33bb98c' }
  let(:client_secret) { '155fc038a85840679b55a1822ef36b9b' }

  before do
    VCR.use_cassette('authenticate:client') do
      RSpotify.authenticate(client_id, client_secret)
    end
  end

  describe 'Recommendations::available_genre_seeds' do
    subject do
      VCR.use_cassette('recommendations:available_genre_seeds') do
        RSpotify::Recommendations.available_genre_seeds
      end
    end

    it 'retrieves a list of available genres seed parameter values' do
      available_genre_seeds = subject
      expect(available_genre_seeds.size) .to eq 126
      expect(available_genre_seeds)      .to include('black-metal', 'industrial', 'trip-hop')
    end
  end

  describe 'Recommendations::generate' do
    subject do
      VCR.use_cassette('recommendations_generate') do
        RSpotify::Recommendations.generate(
          limit: 20,
          seed_artists: ['0X380XXQSNBYuleKzav5UO', '6FXMGgJwohJLUSr5nVlf9X'], 
          seed_genres: ['electronic', 'industrial', 'trip-hop'], 
          market: 'US',
          min_danceability: 0.2, 
          target_valence: 0.6
        )
      end
    end 

    it 'generates a list of recommended tracks' do
      tracks = subject.tracks
      expect(tracks.count)                     .to eq(20)
      expect(tracks.map { |track| track.name }).to include('Bonfire', 'All The Love In The World', 'Splitting The Atom')
    end

    it 'generates a list of recommendation seeds' do
      seeds = subject.seeds
      expect(seeds.count)                                                         .to eq(5)
      expect(seeds.select { |seed| seed.type == 'ARTIST' }.map { |seed| seed.id }).to include('0X380XXQSNBYuleKzav5UO', '6FXMGgJwohJLUSr5nVlf9X')
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
rspotify-1.23.0 spec/lib/rspotify/recommendations_spec.rb
rspotify-1.22.1 spec/lib/rspotify/recommendations_spec.rb
rspotify-1.22.0 spec/lib/rspotify/recommendations_spec.rb
rspotify-1.21.0 spec/lib/rspotify/recommendations_spec.rb
rspotify-1.20.0 spec/lib/rspotify/recommendations_spec.rb
rspotify-1.19.1 spec/lib/rspotify/recommendations_spec.rb
rspotify-1.19.0 spec/lib/rspotify/recommendations_spec.rb
rspotify-1.18.0 spec/lib/rspotify/recommendations_spec.rb