Skip to content
Browse files

Added track.top_fans

  • Loading branch information...
1 parent dcaaece commit ad125a200d148c052371e2ad9979ad2dbef0b25e @gingerhendrix committed
View
5 TODO
@@ -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}
@@ -32,4 +31,4 @@
{album|artist|tag|track|venue}.search
Add README
Simple website
- Release
+ Release
View
3 lib/scrobbler2/track.rb
@@ -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
View
24 test/acceptance/artist/top_fans.rb
@@ -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
View
29 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
View
1 test/acceptance/test_helper.rb
@@ -1,5 +1,6 @@
require 'rubygems'
require 'spec'
+require 'spec/interop/test'
$: << File.dirname(__FILE__) + "/../../lib/"
View
23 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
View
1 test/unit/spec_helper.rb
@@ -1,5 +1,6 @@
require 'rubygems'
require 'spec'
+require 'spec/interop/test'
$: << File.dirname(__FILE__) + "/../../lib/"
View
5 test/unit/track_spec.rb
@@ -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.
Something went wrong with that request. Please try again.