guilhermesad/rspotify — pull request #3 by TrevorS (2014-07-08 16:19:04+00:00)
Title: Permit searching across artists + albums + tracks.

Spotify's Web API permits searching artists, albums, and tracks with the same query. The [documentation](https://developer.spotify.com/web-api/search-item/) describes the `type` parameter as *a comma-separated list of item types to search across*.

`RSpotify::Base.search` can now take a comma separated list of types and returns an `Array` of all matching results.

For example:
```ruby
results = RSpotify::Base.search('Opeth', 'album, artist')
results.size #=> 21
# Example matching Album
results.first.name #=> "Heritage (Special Edition)"
results.first.class #=> RSpotify::Album
# Example matching Artist
results.last.name #=> "Opeth"
results.last.class #=> RSpotify::Artist
```

All related specs pass, however I do get 2-3 intermittent unrelated failures:
```
./Users/trevor/Projects/rspotify/lib/rspotify/artist.rb:66: warning: instance variable @albums not initialized
................FFF

Failures:

1) RSpotify::Playlist Playlist::find should find playlist with correct owner
Failure/Error: @playlist = RSpotify::Playlist.find('wizzler', '00wHcTN0zQiun4xri9pmvX')
RestClient::GatewayTimeout:
504 Gateway Timeout
# ./lib/rspotify.rb:31:in `block (2 levels) in '
# ./lib/rspotify.rb:38:in `block (2 levels) in '
# ./lib/rspotify/playlist.rb:24:in `find'
# ./spec/lib/rspotify/playlist_spec.rb:12:in `block (3 levels) in '

2) RSpotify::Playlist Playlist::find should find playlist with correct attributes
Failure/Error: @playlist = RSpotify::Playlist.find('wizzler', '00wHcTN0zQiun4xri9pmvX')
RestClient::GatewayTimeout:
504 Gateway Timeout
# ./lib/rspotify.rb:31:in `block (2 levels) in '
# ./lib/rspotify.rb:38:in `block (2 levels) in '
# ./lib/rspotify/playlist.rb:24:in `find'
# ./spec/lib/rspotify/playlist_spec.rb:12:in `block (3 levels) in '

3) RSpotify::Playlist Playlist::find should find playlist with correct tracks
Failure/Error: @playlist = RSpotify::Playlist.find('wizzler', '00wHcTN0zQiun4xri9pmvX')
RestClient::GatewayTimeout:
504 Gateway Timeout
# ./lib/rspotify.rb:31:in `block (2 levels) in '
# ./lib/rspotify.rb:38:in `block (2 levels) in '
# ./lib/rspotify/playlist.rb:24:in `find'
# ./spec/lib/rspotify/playlist_spec.rb:12:in `block (3 levels) in '

Finished in 19.45 seconds (files took 0.18931 seconds to load)
20 examples, 3 failures

Failed examples:

rspec ./spec/lib/rspotify/playlist_spec.rb:29 # RSpotify::Playlist Playlist::find should find playlist with correct owner
rspec ./spec/lib/rspotify/playlist_spec.rb:15 # RSpotify::Playlist Playlist::find should find playlist with correct attributes
rspec ./spec/lib/rspotify/playlist_spec.rb:35 # RSpotify::Playlist Playlist::find should find playlist with correct tracks
```