philnash/meta-spotify — pull request #1 by amanelis (2012-02-28 04:18:34+00:00)
Title: Fixed a bad error on some nil returns

Was getting an error in the Track search method as follows. Simply wrote a ternary to catch any nil values from array [].

1.9.2p290 :001 > search = MetaSpotify::Artist.search('foo')
NoMethodError: You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.[]
from /Users/amanelis/.rvm/gems/ruby-1.9.2-p290@console/gems/meta-spotify-0.1.5/lib/meta-spotify.rb:45:in `search'
from (irb):1
from /Users/amanelis/.rvm/gems/ruby-1.9.2-p290@console/gems/railties-3.1.0/lib/rails/commands/console.rb:45:in `start'
from /Users/amanelis/.rvm/gems/ruby-1.9.2-p290@console/gems/railties-3.1.0/lib/rails/commands/console.rb:8:in `start'
from /Users/amanelis/.rvm/gems/ruby-1.9.2-p290@console/gems/railties-3.1.0/lib/rails/commands.rb:40:in `'
from script/rails:6:in `require'
from script/rails:6:in `

'
1.9.2p290 :002 > exit