Skip to content
Browse files

Generated a skeleton for user

  • Loading branch information...
1 parent 45e154d commit 3a91a566499141e9eb48ad1e336cd021d9bd6722 @gingerhendrix committed Apr 22, 2009
View
48 lib/scrobbler2/user.rb
@@ -1,15 +1,47 @@
module Scrobbler2
class User < Base
- def initialize(username)
- @username = username
+ def initialize()
+ @query = {}#TODO eg. {:artist => artist, :track => track}
end
- def info(options={}, query={})
- return @info if @info && !options[:force]
- @info = self.class.get_with_auth("user.getinfo", query, options)["lfm"]["user"]
- end
-
-
+ get_resource :events, :root => "events"
+
+ get_resource :info, :root => "info"
+
+ get_resource :friends, :root => "friends"
+
+ get_resource :loved_tracks, :root => "loved_tracks"
+
+ get_resource :neighbours, :root => "neighbours"
+
+ get_resource :past_events, :root => "past_events"
+
+ get_resource :playlists, :root => "playlists"
+
+ get_resource :recent_tracks, :root => "recent_tracks"
+
+ get_resource :recommended_artists, :root => "recommended_artists"
+
+ get_resource :recommended_events, :root => "recommended_events"
+
+ get_resource :shouts, :root => "shouts"
+
+ get_resource :top_albums, :root => "top_albums"
+
+ get_resource :top_artists, :root => "top_artists"
+
+ get_resource :top_tags, :root => "top_tags"
+
+ get_resource :top_tracks, :root => "top_tracks"
+
+ get_resource :weekly_album_chart, :root => "weekly_album_chart"
+
+ get_resource :weekly_artist_chart, :root => "weekly_artist_chart"
+
+ get_resource :weekly_chart_list, :root => "weekly_chart_list"
+
+ get_resource :weekly_track_chart, :root => "weekly_track_chart"
+
end
end
View
14 test/acceptance/user/events_test.rb
@@ -0,0 +1,14 @@
+require File.dirname(__FILE__) + '/../test_helper.rb'
+
+describe "events for user ..." do
+
+ before(:all) do #We only want to hit the webservice once.
+ @user = Scrobbler2::user.new "..."
+ @events = @user.events
+ end
+
+ it "should be hash" do
+ @events.should be_kind_of Hash
+ end
+
+end
View
14 test/acceptance/user/friends_test.rb
@@ -0,0 +1,14 @@
+require File.dirname(__FILE__) + '/../test_helper.rb'
+
+describe "friends for user ..." do
+
+ before(:all) do #We only want to hit the webservice once.
+ @user = Scrobbler2::user.new "..."
+ @friends = @user.friends
+ end
+
+ it "should be hash" do
+ @friends.should be_kind_of Hash
+ end
+
+end
View
14 test/acceptance/user/loved_tracks_test.rb
@@ -0,0 +1,14 @@
+require File.dirname(__FILE__) + '/../test_helper.rb'
+
+describe "loved_tracks for user ..." do
+
+ before(:all) do #We only want to hit the webservice once.
+ @user = Scrobbler2::user.new "..."
+ @loved_tracks = @user.loved_tracks
+ end
+
+ it "should be hash" do
+ @loved_tracks.should be_kind_of Hash
+ end
+
+end
View
14 test/acceptance/user/neighbours_test.rb
@@ -0,0 +1,14 @@
+require File.dirname(__FILE__) + '/../test_helper.rb'
+
+describe "neighbours for user ..." do
+
+ before(:all) do #We only want to hit the webservice once.
+ @user = Scrobbler2::user.new "..."
+ @neighbours = @user.neighbours
+ end
+
+ it "should be hash" do
+ @neighbours.should be_kind_of Hash
+ end
+
+end
View
14 test/acceptance/user/past_events_test.rb
@@ -0,0 +1,14 @@
+require File.dirname(__FILE__) + '/../test_helper.rb'
+
+describe "past_events for user ..." do
+
+ before(:all) do #We only want to hit the webservice once.
+ @user = Scrobbler2::user.new "..."
+ @past_events = @user.past_events
+ end
+
+ it "should be hash" do
+ @past_events.should be_kind_of Hash
+ end
+
+end
View
14 test/acceptance/user/playlists_test.rb
@@ -0,0 +1,14 @@
+require File.dirname(__FILE__) + '/../test_helper.rb'
+
+describe "playlists for user ..." do
+
+ before(:all) do #We only want to hit the webservice once.
+ @user = Scrobbler2::user.new "..."
+ @playlists = @user.playlists
+ end
+
+ it "should be hash" do
+ @playlists.should be_kind_of Hash
+ end
+
+end
View
14 test/acceptance/user/recent_tracks_test.rb
@@ -0,0 +1,14 @@
+require File.dirname(__FILE__) + '/../test_helper.rb'
+
+describe "recent_tracks for user ..." do
+
+ before(:all) do #We only want to hit the webservice once.
+ @user = Scrobbler2::user.new "..."
+ @recent_tracks = @user.recent_tracks
+ end
+
+ it "should be hash" do
+ @recent_tracks.should be_kind_of Hash
+ end
+
+end
View
14 test/acceptance/user/recommended_artists_test.rb
@@ -0,0 +1,14 @@
+require File.dirname(__FILE__) + '/../test_helper.rb'
+
+describe "recommended_artists for user ..." do
+
+ before(:all) do #We only want to hit the webservice once.
+ @user = Scrobbler2::user.new "..."
+ @recommended_artists = @user.recommended_artists
+ end
+
+ it "should be hash" do
+ @recommended_artists.should be_kind_of Hash
+ end
+
+end
View
14 test/acceptance/user/recommended_events_test.rb
@@ -0,0 +1,14 @@
+require File.dirname(__FILE__) + '/../test_helper.rb'
+
+describe "recommended_events for user ..." do
+
+ before(:all) do #We only want to hit the webservice once.
+ @user = Scrobbler2::user.new "..."
+ @recommended_events = @user.recommended_events
+ end
+
+ it "should be hash" do
+ @recommended_events.should be_kind_of Hash
+ end
+
+end
View
14 test/acceptance/user/shouts_test.rb
@@ -0,0 +1,14 @@
+require File.dirname(__FILE__) + '/../test_helper.rb'
+
+describe "shouts for user ..." do
+
+ before(:all) do #We only want to hit the webservice once.
+ @user = Scrobbler2::user.new "..."
+ @shouts = @user.shouts
+ end
+
+ it "should be hash" do
+ @shouts.should be_kind_of Hash
+ end
+
+end
View
14 test/acceptance/user/top_albums_test.rb
@@ -0,0 +1,14 @@
+require File.dirname(__FILE__) + '/../test_helper.rb'
+
+describe "top_albums for user ..." do
+
+ before(:all) do #We only want to hit the webservice once.
+ @user = Scrobbler2::user.new "..."
+ @top_albums = @user.top_albums
+ end
+
+ it "should be hash" do
+ @top_albums.should be_kind_of Hash
+ end
+
+end
View
14 test/acceptance/user/top_artists_test.rb
@@ -0,0 +1,14 @@
+require File.dirname(__FILE__) + '/../test_helper.rb'
+
+describe "top_artists for user ..." do
+
+ before(:all) do #We only want to hit the webservice once.
+ @user = Scrobbler2::user.new "..."
+ @top_artists = @user.top_artists
+ end
+
+ it "should be hash" do
+ @top_artists.should be_kind_of Hash
+ end
+
+end
View
14 test/acceptance/user/top_tags_test.rb
@@ -0,0 +1,14 @@
+require File.dirname(__FILE__) + '/../test_helper.rb'
+
+describe "top_tags for user ..." do
+
+ before(:all) do #We only want to hit the webservice once.
+ @user = Scrobbler2::user.new "..."
+ @top_tags = @user.top_tags
+ end
+
+ it "should be hash" do
+ @top_tags.should be_kind_of Hash
+ end
+
+end
View
14 test/acceptance/user/top_tracks_test.rb
@@ -0,0 +1,14 @@
+require File.dirname(__FILE__) + '/../test_helper.rb'
+
+describe "top_tracks for user ..." do
+
+ before(:all) do #We only want to hit the webservice once.
+ @user = Scrobbler2::user.new "..."
+ @top_tracks = @user.top_tracks
+ end
+
+ it "should be hash" do
+ @top_tracks.should be_kind_of Hash
+ end
+
+end
View
14 test/acceptance/user/weekly_album_chart_test.rb
@@ -0,0 +1,14 @@
+require File.dirname(__FILE__) + '/../test_helper.rb'
+
+describe "weekly_album_chart for user ..." do
+
+ before(:all) do #We only want to hit the webservice once.
+ @user = Scrobbler2::user.new "..."
+ @weekly_album_chart = @user.weekly_album_chart
+ end
+
+ it "should be hash" do
+ @weekly_album_chart.should be_kind_of Hash
+ end
+
+end
View
14 test/acceptance/user/weekly_artist_chart_test.rb
@@ -0,0 +1,14 @@
+require File.dirname(__FILE__) + '/../test_helper.rb'
+
+describe "weekly_artist_chart for user ..." do
+
+ before(:all) do #We only want to hit the webservice once.
+ @user = Scrobbler2::user.new "..."
+ @weekly_artist_chart = @user.weekly_artist_chart
+ end
+
+ it "should be hash" do
+ @weekly_artist_chart.should be_kind_of Hash
+ end
+
+end
View
14 test/acceptance/user/weekly_chart_list_test.rb
@@ -0,0 +1,14 @@
+require File.dirname(__FILE__) + '/../test_helper.rb'
+
+describe "weekly_chart_list for user ..." do
+
+ before(:all) do #We only want to hit the webservice once.
+ @user = Scrobbler2::user.new "..."
+ @weekly_chart_list = @user.weekly_chart_list
+ end
+
+ it "should be hash" do
+ @weekly_chart_list.should be_kind_of Hash
+ end
+
+end
View
14 test/acceptance/user/weekly_track_chart_test.rb
@@ -0,0 +1,14 @@
+require File.dirname(__FILE__) + '/../test_helper.rb'
+
+describe "weekly_track_chart for user ..." do
+
+ before(:all) do #We only want to hit the webservice once.
+ @user = Scrobbler2::user.new "..."
+ @weekly_track_chart = @user.weekly_track_chart
+ end
+
+ it "should be hash" do
+ @weekly_track_chart.should be_kind_of Hash
+ end
+
+end
View
148 test/unit/user_spec.rb
@@ -0,0 +1,148 @@
+require File.dirname(__FILE__) + "/spec_helper.rb"
+
+describe "User" do
+ before(:each) do
+ @user = Scrobbler2::User.new "..."
+ @user.class.stub!(:get).and_return Hash.new
+ end
+
+ it "should have a default query {TODO}" do
+ @user.instance_variable_get(:@query).should == {}
+ end
+
+
+
+ it "events should call get with 'user.getevents'" do
+ @user.class.should_receive(:get).with('user.getevents', anything(), anything()).and_return Hash.new
+ @user.events
+ end
+
+
+
+ it "info should call get with 'user.getinfo'" do
+ @user.class.should_receive(:get).with('user.getinfo', anything(), anything()).and_return Hash.new
+ @user.info
+ end
+
+
+
+ it "friends should call get with 'user.getfriends'" do
+ @user.class.should_receive(:get).with('user.getfriends', anything(), anything()).and_return Hash.new
+ @user.friends
+ end
+
+
+
+ it "loved_tracks should call get with 'user.getloved_tracks'" do
+ @user.class.should_receive(:get).with('user.getloved_tracks', anything(), anything()).and_return Hash.new
+ @user.loved_tracks
+ end
+
+
+
+ it "neighbours should call get with 'user.getneighbours'" do
+ @user.class.should_receive(:get).with('user.getneighbours', anything(), anything()).and_return Hash.new
+ @user.neighbours
+ end
+
+
+
+ it "past_events should call get with 'user.getpast_events'" do
+ @user.class.should_receive(:get).with('user.getpast_events', anything(), anything()).and_return Hash.new
+ @user.past_events
+ end
+
+
+
+ it "playlists should call get with 'user.getplaylists'" do
+ @user.class.should_receive(:get).with('user.getplaylists', anything(), anything()).and_return Hash.new
+ @user.playlists
+ end
+
+
+
+ it "recent_tracks should call get with 'user.getrecent_tracks'" do
+ @user.class.should_receive(:get).with('user.getrecent_tracks', anything(), anything()).and_return Hash.new
+ @user.recent_tracks
+ end
+
+
+
+ it "recommended_artists should call get with 'user.getrecommended_artists'" do
+ @user.class.should_receive(:get).with('user.getrecommended_artists', anything(), anything()).and_return Hash.new
+ @user.recommended_artists
+ end
+
+
+
+ it "recommended_events should call get with 'user.getrecommended_events'" do
+ @user.class.should_receive(:get).with('user.getrecommended_events', anything(), anything()).and_return Hash.new
+ @user.recommended_events
+ end
+
+
+
+ it "shouts should call get with 'user.getshouts'" do
+ @user.class.should_receive(:get).with('user.getshouts', anything(), anything()).and_return Hash.new
+ @user.shouts
+ end
+
+
+
+ it "top_albums should call get with 'user.gettop_albums'" do
+ @user.class.should_receive(:get).with('user.gettop_albums', anything(), anything()).and_return Hash.new
+ @user.top_albums
+ end
+
+
+
+ it "top_artists should call get with 'user.gettop_artists'" do
+ @user.class.should_receive(:get).with('user.gettop_artists', anything(), anything()).and_return Hash.new
+ @user.top_artists
+ end
+
+
+
+ it "top_tags should call get with 'user.gettop_tags'" do
+ @user.class.should_receive(:get).with('user.gettop_tags', anything(), anything()).and_return Hash.new
+ @user.top_tags
+ end
+
+
+
+ it "top_tracks should call get with 'user.gettop_tracks'" do
+ @user.class.should_receive(:get).with('user.gettop_tracks', anything(), anything()).and_return Hash.new
+ @user.top_tracks
+ end
+
+
+
+ it "weekly_album_chart should call get with 'user.getweekly_album_chart'" do
+ @user.class.should_receive(:get).with('user.getweekly_album_chart', anything(), anything()).and_return Hash.new
+ @user.weekly_album_chart
+ end
+
+
+
+ it "weekly_artist_chart should call get with 'user.getweekly_artist_chart'" do
+ @user.class.should_receive(:get).with('user.getweekly_artist_chart', anything(), anything()).and_return Hash.new
+ @user.weekly_artist_chart
+ end
+
+
+
+ it "weekly_chart_list should call get with 'user.getweekly_chart_list'" do
+ @user.class.should_receive(:get).with('user.getweekly_chart_list', anything(), anything()).and_return Hash.new
+ @user.weekly_chart_list
+ end
+
+
+
+ it "weekly_track_chart should call get with 'user.getweekly_track_chart'" do
+ @user.class.should_receive(:get).with('user.getweekly_track_chart', anything(), anything()).and_return Hash.new
+ @user.weekly_track_chart
+ end
+
+
+
+end

0 comments on commit 3a91a56

Please sign in to comment.
Something went wrong with that request. Please try again.