Skip to content

Commit

Permalink
Added track.top_fans
Browse files Browse the repository at this point in the history
  • Loading branch information
gingerhendrix committed Apr 21, 2009
1 parent dcaaece commit ad125a2
Show file tree
Hide file tree
Showing 8 changed files with 64 additions and 27 deletions.
5 changes: 2 additions & 3 deletions TODO
Expand Up @@ -15,14 +15,13 @@
Acceptance Test +done
Unit Test +done
Implementation +done
Track.getTags
Track.getTopFans
Track.getTopTags
User.get*
Venue.get*
Geo.get*
Post Requests
{artist|album|track}.{add|remove}Tag
{artist|album|track}.{get|add|remove}Tag
{artist|track|event}.share
track.{love|ban}
library.add{Artist|Album|Track}
Expand All @@ -32,4 +31,4 @@
{album|artist|tag|track|venue}.search
Add README
Simple website
Release
Release
3 changes: 2 additions & 1 deletion lib/scrobbler2/track.rb
Expand Up @@ -7,6 +7,7 @@ def initialize(artist, track)

get_resource :info, :root => 'track'
get_resource :similar, :root => 'similartracks'

get_resource :top_fans, :root => 'topfans'

end
end
24 changes: 1 addition & 23 deletions test/acceptance/artist/top_fans.rb
Expand Up @@ -14,28 +14,6 @@
@fans['artist'].should == "Metallica"
end

it "should have array of users" do
@fans.should have_key('user')
@fans['user'].should be_a_kind_of(Array)
@fans['user'].length.should > 0
end

describe "a fan" do
it_should_behave_like "Top Fans"

before(:each) do
@fan = @fans['user'][0]
end

it "should have a name" do
@event.should have_key('name')
end

it "should have a url" do
@event.should have_key('url')
end

it "should have a weight" do
@event.should have_key('weight')
end
end
end
29 changes: 29 additions & 0 deletions test/acceptance/shared/top_fans.rb
@@ -0,0 +1,29 @@

describe "Top Fans", :shared => true do

it "should have array of users" do
@fans.should have_key('user')
@fans['user'].should be_a_kind_of(Array)
@fans['user'].length.should > 0
end

describe "a fan" do

before(:each) do
@fan = @fans['user'][0]
end

it "should have a name" do
@fan.should have_key('name')
end

it "should have a url" do
@fan.should have_key('url')
end

it "should have a weight" do
@fan.should have_key('weight')
end
end

end
1 change: 1 addition & 0 deletions test/acceptance/test_helper.rb
@@ -1,5 +1,6 @@
require 'rubygems'
require 'spec'
require 'spec/interop/test'

$: << File.dirname(__FILE__) + "/../../lib/"

Expand Down
23 changes: 23 additions & 0 deletions test/acceptance/track/top_fans_test.rb
@@ -0,0 +1,23 @@
require File.dirname(__FILE__) + '/../test_helper.rb'

describe "top_fans for track Metallica - Blackened" do

before(:all) do #We only want to hit the webservice once.
@track = Scrobbler2::Track.new "Metallic", "Blackened"
@fans = @track.top_fans
end

it "should be hash" do
@fans.should be_kind_of Hash
end

it "should have artist" do
@fans.should have_key('artist')
end

it "should have track" do
@fans.should have_key('track')
end

it_should_behave_like "Top Fans"
end
1 change: 1 addition & 0 deletions test/unit/spec_helper.rb
@@ -1,5 +1,6 @@
require 'rubygems'
require 'spec'
require 'spec/interop/test'

$: << File.dirname(__FILE__) + "/../../lib/"

Expand Down
5 changes: 5 additions & 0 deletions test/unit/track_spec.rb
Expand Up @@ -19,5 +19,10 @@
@track.class.should_receive(:get).with('track.getsimilar', {:artist => "Metallica", :track => "Blackened"}, {}).and_return Hash.new
@track.similar
end

it "top_fans should call get with 'track.getTopFans' with query params :artist => @artist, :track => @album" do
@track.class.should_receive(:get).with('track.gettopfans', {:artist => "Metallica", :track => "Blackened"}, {}).and_return Hash.new
@track.top_fans
end

end

0 comments on commit ad125a2

Please sign in to comment.