spec/itunes/client_spec.rb in itunes-0.4.1 vs spec/itunes/client_spec.rb in itunes-0.5.0

- old
+ new

@@ -1,79 +1,89 @@ require 'spec_helper' describe ITunes::Client do + before(:each) do + @client = ITunes::Client.new + end use_vcr_cassette :record => :new_episodes, :match_requests_on => [:uri, :method] describe ".lookup" do - before(:each) do - @client = ITunes::Client.new - end - it "should return results for valid ids" do item = @client.lookup('396405320') item.results.first.collection_name.should == 'Hold it Down - Single' item.results.first.primary_genre_name == 'Dance' end - describe "when using amg ids" do - describe "artist ids" do - it "should return a valid item when passed a single id" do - items = @client.lookup('468749', :id_type => :amg_artist) - items.result_count.should == 2 - end + describe "when passing an id_type other than amg or upc" do + it "should raise an error" do + lambda { + @client.lookup('1235', :id_type => :lastfm) + }.should raise_error + end + end + end - it "should return a results when passed a comma separated string of ids" do - items = @client.lookup('468749,5723', :id_type => :amg_artist) - items.result_count.should == 3 - end + describe '.amg_artist' do + it "should return a valid item when passed a single id" do + items = @client.amg_artist('792844') + items.result_count.should == 1 + end - it "should return results when passed an array of ids" do - items = @client.lookup(['468749','5723'], :id_type => :amg_artist) - items.result_count.should == 3 - end - end + it "should return results when passed a comma separated string of ids" do + items = @client.amg_artist('468749,5723') + items.result_count.should == 2 + end + it "should return results when passed an array of ids" do + items = @client.amg_artist(['468749','5723']) + items.result_count.should == 2 + end - describe "album ids" do - it "should return a valid item when passed a single id" do - items = @client.lookup('15197', :id_type => :amg_album) - items.results.first.artist_name.should == 'Wilson Pickett' - end + it 'should be aliased as amg_artists' do + @client.amg_artist(['468749','5723']).should == @client.amg_artists(['468749','5723']) + end + end - it "should return a results when passed a comma separated string of ids" do - items = @client.lookup('15197,15198', :id_type => :amg_album) - items.results.first.artist_name.should == 'Wilson Pickett' - end + describe '.amg_album' do + it "should return a valid item when passed a single id" do + items = @client.amg_album('15197') + items.results.first.artist_name.should == 'Wilson Pickett' + end - it "should return results when passed an array of ids" do - items = @client.lookup(['15197','15198'], :id_type => :amg_album) - items.results.first.artist_name.should == 'Wilson Pickett' - end - end + it "should return results when passed a comma separated string of ids" do + items = @client.amg_album('15197,15198') + items.results.first.artist_name.should == 'Wilson Pickett' end - describe "when using a upc id" do - it "should return a valid item when passed a single id" do - items = @client.lookup('075678317729', :id_type => :upc) - end + it "should return results when passed an array of ids" do + items = @client.amg_album(['15197','15198']) + items.results.first.artist_name.should == 'Wilson Pickett' end - describe "when passing an id_type other than amg or upc" do - it "should raise an error" do - lambda { - @client.lookup('1235', :id_type => :lastfm) - }.should raise_error - end + it 'should be aliased as amg_albums' do + @client.amg_album(['15197','15198']).should == @client.amg_albums(['15197','15198']) end end - describe "search" do - before(:each) do - @client = ITunes::Client.new + describe '.upc' do + it "should return a valid item when passed a single id" do + item = @client.upc('5024545486520') + item.results.first.collection_name.should == 'Untrue' + item.results.first.artist_name.should == 'Burial' end + end + describe '.isbn' do + it 'should return a valid item when passed a single id' do + item = @client.isbn('9780316069359') + item.results.first.kind.should == 'ebook' + item.results.first.track_name.should == 'The Fifth Witness' + end + end + + describe "search" do describe ".all" do it "should raise an ArgumentError when passed a nil search term" do lambda { @client.all(nil) }.should raise_error @@ -99,11 +109,11 @@ describe ".music" do it "should return music results" do response = @client.music('Jose James') response.results.each do |result| - result.kind.should == 'song' + ['music-artist', 'music-track', 'album', 'music-video', 'mix', 'song'].should include(result.kind) end end end describe ".podcast" do @@ -154,9 +164,27 @@ describe ".tv_show" do it "should return tv show results" do response = @client.tv_show('Lost') response.results.each do |result| result.kind.should == 'tv-episode' + end + end + end + + describe ".software" do + it "should return tv show results" do + response = @client.software('Doodle Jump') + response.results.each do |result| + ['software', 'iPadSoftware', 'macSoftware'].should include(result.kind) + end + end + end + + describe ".ebook" do + it "should return ebook results" do + response = @client.ebook('Alice in Wonderland') + response.results.each do |result| + result.kind.should == 'ebook' end end end end \ No newline at end of file