-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4f3d793
commit a9060d2
Showing
4 changed files
with
85 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
module Scrobbler2 | ||
class Album < Base | ||
|
||
def initialize(artist, album) | ||
@query = {:artist => artist, :album => album} | ||
end | ||
|
||
get_resource :info, :root => 'album' | ||
|
||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
require File.dirname(__FILE__) + '/../test_helper.rb' | ||
|
||
describe "Album info for Ride the Lightning" do | ||
|
||
before(:all) do #We only want to hit the webservice once. | ||
@album = Scrobbler2::Album.new "Metallica", "Ride The Lightning" | ||
@info = @album.info | ||
# puts "INFO: #{@info.inspect} \n" | ||
end | ||
|
||
it "should be hash" do | ||
@info.should be_kind_of Hash | ||
end | ||
|
||
it "should have name 'Metallica'" do | ||
@info["name"].should == "Ride the Lightning" | ||
end | ||
|
||
it "should have artist 'Metallica'" do | ||
@info["artist"].should == "Metallica" | ||
end | ||
|
||
|
||
it "should have mbid '456efd39-f0dc-4b4d-87c7-82bbc562d8f3'" do | ||
@info["mbid"].should == '456efd39-f0dc-4b4d-87c7-82bbc562d8f3' | ||
end | ||
|
||
it "should have url 'http://www.last.fm/music/Metallica'" do | ||
@info["url"].should == 'http://www.last.fm/music/Metallica/Ride+the+Lightning' | ||
end | ||
|
||
it "should have listeners" do | ||
@info.should have_key("listeners") | ||
end | ||
|
||
it "should have playcount" do | ||
@info.should have_key("playcount") | ||
end | ||
|
||
it "should have images" do | ||
@info["image"].should be_kind_of Array | ||
@info["image"][0].should be_kind_of Hash | ||
@info["image"][0]['size'].should be_kind_of String | ||
@info["image"][0]['#text'].should be_kind_of String | ||
#@info["image"][0]['#text'].should == 'http://userserve-ak.last.fm/serve/34/9527793.jpg' | ||
end | ||
|
||
it "should have toptags" do | ||
pending "TopTags breaks parser" do | ||
@info["toptags"].should be_kind_of Hash | ||
@info["toptags"]["tags"].should be_kind_of Array | ||
@info["toptags"]["tags"][0].should have_key('name') | ||
@info["toptags"]["tags"][0].should have_key('url') | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
require File.dirname(__FILE__) + "/spec_helper.rb" | ||
|
||
describe "Album" do | ||
before(:each) do | ||
@album = Scrobbler2::Album.new "Metallica", "Ride The Lightning" | ||
@album.class.stub!(:get).and_return Hash.new | ||
end | ||
|
||
it "should have a default query {:artist => 'Metallica', :album => 'Ride The Lightning'}" do | ||
@album.instance_variable_get(:@query).should == {:artist => 'Metallica', :album => 'Ride The Lightning'} | ||
end | ||
|
||
it "info should call get with 'album.getInfo' with query params :artist => @artist, :album => @album" do | ||
@album.class.should_receive(:get).with('album.getinfo', {:artist => "Metallica", :album => "Ride The Lightning"}, {}).and_return Hash.new | ||
@album.info | ||
end | ||
end |