bts-scrobbler2 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (107) hide show
  1. data/README.rdoc +155 -0
  2. data/Rakefile +8 -0
  3. data/VERSION.yml +4 -0
  4. data/generators/acceptance_test/USAGE +9 -0
  5. data/generators/acceptance_test/acceptance_test_generator.rb +57 -0
  6. data/generators/acceptance_test/templates/acceptance_test.rb.erb +14 -0
  7. data/generators/resource/USAGE +8 -0
  8. data/generators/resource/resource_generator.rb +47 -0
  9. data/generators/resource/templates/resource.rb.erb +11 -0
  10. data/generators/resource/templates/spec.rb.erb +22 -0
  11. data/lib/scrobbler2.rb +23 -0
  12. data/lib/scrobbler2/album.rb +11 -0
  13. data/lib/scrobbler2/artist.rb +26 -0
  14. data/lib/scrobbler2/auth.rb +19 -0
  15. data/lib/scrobbler2/base.rb +100 -0
  16. data/lib/scrobbler2/event.rb +12 -0
  17. data/lib/scrobbler2/geo.rb +15 -0
  18. data/lib/scrobbler2/group.rb +14 -0
  19. data/lib/scrobbler2/library.rb +12 -0
  20. data/lib/scrobbler2/playlist.rb +10 -0
  21. data/lib/scrobbler2/tag.rb +18 -0
  22. data/lib/scrobbler2/track.rb +13 -0
  23. data/lib/scrobbler2/user.rb +29 -0
  24. data/lib/scrobbler2/venue.rb +12 -0
  25. data/test/acceptance/album/info_test.rb +56 -0
  26. data/test/acceptance/artist/add_tags_test.rb +14 -0
  27. data/test/acceptance/artist/events_test.rb +47 -0
  28. data/test/acceptance/artist/info_test.rb +53 -0
  29. data/test/acceptance/artist/shouts_test.rb +48 -0
  30. data/test/acceptance/artist/similar_artists_test.rb +20 -0
  31. data/test/acceptance/artist/tags_test.rb +24 -0
  32. data/test/acceptance/artist/top_albums_test.rb +34 -0
  33. data/test/acceptance/artist/top_fans.rb +19 -0
  34. data/test/acceptance/artist/top_tags.rb +18 -0
  35. data/test/acceptance/artist/top_tracks.rb +47 -0
  36. data/test/acceptance/auth/auth_test.rb +21 -0
  37. data/test/acceptance/event/info_test.rb +66 -0
  38. data/test/acceptance/event/shouts_test.rb +49 -0
  39. data/test/acceptance/geo/events_test.rb +14 -0
  40. data/test/acceptance/geo/top_artists_test.rb +16 -0
  41. data/test/acceptance/geo/top_tracks_test.rb +16 -0
  42. data/test/acceptance/group/members_test.rb +60 -0
  43. data/test/acceptance/group/weekly_album_chart_test.rb +61 -0
  44. data/test/acceptance/group/weekly_artist_chart_test.rb +54 -0
  45. data/test/acceptance/group/weekly_chart_list_test.rb +39 -0
  46. data/test/acceptance/group/weekly_track_chart_test.rb +61 -0
  47. data/test/acceptance/library/albums_test.rb +34 -0
  48. data/test/acceptance/library/artists_test.rb +33 -0
  49. data/test/acceptance/library/tracks_test.rb +33 -0
  50. data/test/acceptance/playlist/fetch_test.rb +68 -0
  51. data/test/acceptance/shared/album.rb +41 -0
  52. data/test/acceptance/shared/artist.rb +16 -0
  53. data/test/acceptance/shared/paged_result.rb +16 -0
  54. data/test/acceptance/shared/top_fans.rb +29 -0
  55. data/test/acceptance/shared/top_tags.rb +23 -0
  56. data/test/acceptance/shared/track.rb +23 -0
  57. data/test/acceptance/tag/similar_test.rb +15 -0
  58. data/test/acceptance/tag/top_albums_test.rb +37 -0
  59. data/test/acceptance/tag/top_artists_test.rb +31 -0
  60. data/test/acceptance/tag/top_tags_test.rb +32 -0
  61. data/test/acceptance/tag/top_tracks_test.rb +33 -0
  62. data/test/acceptance/tag/weekly_artist_chart.rb +54 -0
  63. data/test/acceptance/tag/weekly_chart_list.rb +39 -0
  64. data/test/acceptance/test_helper.rb +15 -0
  65. data/test/acceptance/track/info_test.rb +47 -0
  66. data/test/acceptance/track/similar_test.rb +22 -0
  67. data/test/acceptance/track/top_fans_test.rb +23 -0
  68. data/test/acceptance/track/top_tags_test.rb +24 -0
  69. data/test/acceptance/user/events_test.rb +27 -0
  70. data/test/acceptance/user/friends_test.rb +14 -0
  71. data/test/acceptance/user/info_test.rb +19 -0
  72. data/test/acceptance/user/loved_tracks_test.rb +14 -0
  73. data/test/acceptance/user/neighbours_test.rb +14 -0
  74. data/test/acceptance/user/past_events_test.rb +14 -0
  75. data/test/acceptance/user/playlists_test.rb +14 -0
  76. data/test/acceptance/user/recent_tracks_test.rb +14 -0
  77. data/test/acceptance/user/recommended_artists_test.rb +16 -0
  78. data/test/acceptance/user/recommended_events_test.rb +16 -0
  79. data/test/acceptance/user/shouts_test.rb +14 -0
  80. data/test/acceptance/user/top_albums_test.rb +14 -0
  81. data/test/acceptance/user/top_artists_test.rb +14 -0
  82. data/test/acceptance/user/top_tags_test.rb +14 -0
  83. data/test/acceptance/user/top_tracks_test.rb +14 -0
  84. data/test/acceptance/user/weekly_album_chart_test.rb +14 -0
  85. data/test/acceptance/user/weekly_artist_chart_test.rb +14 -0
  86. data/test/acceptance/user/weekly_chart_list_test.rb +14 -0
  87. data/test/acceptance/user/weekly_track_chart_test.rb +14 -0
  88. data/test/acceptance/venue/events_test.rb +14 -0
  89. data/test/acceptance/venue/past_events_test.rb +14 -0
  90. data/test/generators/test_acceptance_test_generator.rb +46 -0
  91. data/test/generators/test_generator_helper.rb +29 -0
  92. data/test/generators/test_resource_generator.rb +71 -0
  93. data/test/unit/album_spec.rb +17 -0
  94. data/test/unit/artist_spec.rb +62 -0
  95. data/test/unit/auth_spec.rb +22 -0
  96. data/test/unit/base_spec.rb +193 -0
  97. data/test/unit/event_spec.rb +23 -0
  98. data/test/unit/geo_spec.rb +36 -0
  99. data/test/unit/group_spec.rb +38 -0
  100. data/test/unit/library_spec.rb +27 -0
  101. data/test/unit/playlist_spec.rb +18 -0
  102. data/test/unit/spec_helper.rb +7 -0
  103. data/test/unit/tag_spec.rb +50 -0
  104. data/test/unit/track_spec.rb +33 -0
  105. data/test/unit/user_spec.rb +148 -0
  106. data/test/unit/venue_spec.rb +29 -0
  107. metadata +260 -0
@@ -0,0 +1,14 @@
1
+ require File.dirname(__FILE__) + '/../test_helper.rb'
2
+
3
+ describe "neighbours for user gingerhendrix" do
4
+
5
+ before(:all) do #We only want to hit the webservice once.
6
+ @user = Scrobbler2::User.new "gingerhendrix"
7
+ @neighbours = @user.neighbours
8
+ end
9
+
10
+ it "should be hash" do
11
+ @neighbours.should be_kind_of Hash
12
+ end
13
+
14
+ end
@@ -0,0 +1,14 @@
1
+ require File.dirname(__FILE__) + '/../test_helper.rb'
2
+
3
+ describe "past_events for user 'gingerhendrix'" do
4
+
5
+ before(:all) do #We only want to hit the webservice once.
6
+ @user = Scrobbler2::User.new "gingerhendrix"
7
+ @past_events = @user.past_events
8
+ end
9
+
10
+ it "should be hash" do
11
+ @past_events.should be_kind_of Hash
12
+ end
13
+
14
+ end
@@ -0,0 +1,14 @@
1
+ require File.dirname(__FILE__) + '/../test_helper.rb'
2
+
3
+ describe "playlists for user gingerhendrix" do
4
+
5
+ before(:all) do #We only want to hit the webservice once.
6
+ @user = Scrobbler2::User.new "gingerhendrix"
7
+ @playlists = @user.playlists
8
+ end
9
+
10
+ it "should be hash" do
11
+ @playlists.should be_kind_of Hash
12
+ end
13
+
14
+ end
@@ -0,0 +1,14 @@
1
+ require File.dirname(__FILE__) + '/../test_helper.rb'
2
+
3
+ describe "recent_tracks for user 'gingerhendrix'" do
4
+
5
+ before(:all) do #We only want to hit the webservice once.
6
+ @user = Scrobbler2::User.new "gingerhendrix"
7
+ @recent_tracks = @user.recent_tracks
8
+ end
9
+
10
+ it "should be hash" do
11
+ @recent_tracks.should be_kind_of Hash
12
+ end
13
+
14
+ end
@@ -0,0 +1,16 @@
1
+ require File.dirname(__FILE__) + '/../test_helper.rb'
2
+
3
+ describe "recommended_artists for user gingerhendrix" do
4
+
5
+ before(:all) do #We only want to hit the webservice once.
6
+ @user = Scrobbler2::User.new "gingerhendrix"
7
+ @recommended_artists = @user.recommended_artists
8
+ end
9
+
10
+ it "should be hash" do
11
+ pending "Auth doesn't seem to be working" do
12
+ @recommended_artists.should be_kind_of Hash
13
+ end
14
+ end
15
+
16
+ end
@@ -0,0 +1,16 @@
1
+ require File.dirname(__FILE__) + '/../test_helper.rb'
2
+
3
+ describe "recommended_events for user gingerhendrix" do
4
+
5
+ before(:all) do #We only want to hit the webservice once.
6
+ @user = Scrobbler2::User.new "gingerhendrix"
7
+ @recommended_events = @user.recommended_events
8
+ end
9
+
10
+ it "should be hash" do
11
+ pending "auth doesn't seem to be working" do
12
+ @recommended_events.should be_kind_of Hash
13
+ end
14
+ end
15
+
16
+ end
@@ -0,0 +1,14 @@
1
+ require File.dirname(__FILE__) + '/../test_helper.rb'
2
+
3
+ describe "shouts for user gingerhendrix" do
4
+
5
+ before(:all) do #We only want to hit the webservice once.
6
+ @user = Scrobbler2::User.new "gingerhendrix"
7
+ @shouts = @user.shouts
8
+ end
9
+
10
+ it "should be hash" do
11
+ @shouts.should be_kind_of Hash
12
+ end
13
+
14
+ end
@@ -0,0 +1,14 @@
1
+ require File.dirname(__FILE__) + '/../test_helper.rb'
2
+
3
+ describe "top_albums for user gingerhendrix" do
4
+
5
+ before(:all) do #We only want to hit the webservice once.
6
+ @user = Scrobbler2::User.new "gingerhendrix"
7
+ @top_albums = @user.top_albums
8
+ end
9
+
10
+ it "should be hash" do
11
+ @top_albums.should be_kind_of Hash
12
+ end
13
+
14
+ end
@@ -0,0 +1,14 @@
1
+ require File.dirname(__FILE__) + '/../test_helper.rb'
2
+
3
+ describe "top_artists for user gingerhendrix" do
4
+
5
+ before(:all) do #We only want to hit the webservice once.
6
+ @user = Scrobbler2::User.new "gingerhendrix"
7
+ @top_artists = @user.top_artists
8
+ end
9
+
10
+ it "should be hash" do
11
+ @top_artists.should be_kind_of Hash
12
+ end
13
+
14
+ end
@@ -0,0 +1,14 @@
1
+ require File.dirname(__FILE__) + '/../test_helper.rb'
2
+
3
+ describe "top_tags for user gingerhendrix" do
4
+
5
+ before(:all) do #We only want to hit the webservice once.
6
+ @user = Scrobbler2::User.new "gingerhendrix"
7
+ @top_tags = @user.top_tags
8
+ end
9
+
10
+ it "should be hash" do
11
+ @top_tags.should be_kind_of Hash
12
+ end
13
+
14
+ end
@@ -0,0 +1,14 @@
1
+ require File.dirname(__FILE__) + '/../test_helper.rb'
2
+
3
+ describe "top_tracks for user gingerhendrix" do
4
+
5
+ before(:all) do #We only want to hit the webservice once.
6
+ @user = Scrobbler2::User.new "gingerhendrix"
7
+ @top_tracks = @user.top_tracks
8
+ end
9
+
10
+ it "should be hash" do
11
+ @top_tracks.should be_kind_of Hash
12
+ end
13
+
14
+ end
@@ -0,0 +1,14 @@
1
+ require File.dirname(__FILE__) + '/../test_helper.rb'
2
+
3
+ describe "weekly_album_chart for user gingerhendrix" do
4
+
5
+ before(:all) do #We only want to hit the webservice once.
6
+ @user = Scrobbler2::User.new "gingerhendrix"
7
+ @weekly_album_chart = @user.weekly_album_chart
8
+ end
9
+
10
+ it "should be hash" do
11
+ @weekly_album_chart.should be_kind_of Hash
12
+ end
13
+
14
+ end
@@ -0,0 +1,14 @@
1
+ require File.dirname(__FILE__) + '/../test_helper.rb'
2
+
3
+ describe "weekly_artist_chart for user gingerhendrix" do
4
+
5
+ before(:all) do #We only want to hit the webservice once.
6
+ @user = Scrobbler2::User.new "gingerhendrix"
7
+ @weekly_artist_chart = @user.weekly_artist_chart
8
+ end
9
+
10
+ it "should be hash" do
11
+ @weekly_artist_chart.should be_kind_of Hash
12
+ end
13
+
14
+ end
@@ -0,0 +1,14 @@
1
+ require File.dirname(__FILE__) + '/../test_helper.rb'
2
+
3
+ describe "weekly_chart_list for user gingerhendrix" do
4
+
5
+ before(:all) do #We only want to hit the webservice once.
6
+ @user = Scrobbler2::User.new "gingerhendrix"
7
+ @weekly_chart_list = @user.weekly_chart_list
8
+ end
9
+
10
+ it "should be hash" do
11
+ @weekly_chart_list.should be_kind_of Hash
12
+ end
13
+
14
+ end
@@ -0,0 +1,14 @@
1
+ require File.dirname(__FILE__) + '/../test_helper.rb'
2
+
3
+ describe "weekly_track_chart for user gingerhendrix" do
4
+
5
+ before(:all) do #We only want to hit the webservice once.
6
+ @user = Scrobbler2::User.new "gingerhendrix"
7
+ @weekly_track_chart = @user.weekly_track_chart
8
+ end
9
+
10
+ it "should be hash" do
11
+ @weekly_track_chart.should be_kind_of Hash
12
+ end
13
+
14
+ end
@@ -0,0 +1,14 @@
1
+ require File.dirname(__FILE__) + '/../test_helper.rb'
2
+
3
+ describe "events for venue 8929268 (The Menagerie)" do
4
+
5
+ before(:all) do #We only want to hit the webservice once.
6
+ @venue = Scrobbler2::Venue.new "8929268"
7
+ @events = @venue.events
8
+ end
9
+
10
+ it "should be hash" do
11
+ @events.should be_kind_of Hash
12
+ end
13
+
14
+ end
@@ -0,0 +1,14 @@
1
+ require File.dirname(__FILE__) + '/../test_helper.rb'
2
+
3
+ describe "past_events for venue 8929268 (The Menagerie)" do
4
+
5
+ before(:all) do #We only want to hit the webservice once.
6
+ @venue = Scrobbler2::Venue.new "8929268"
7
+ @past_events = @venue.past_events
8
+ end
9
+
10
+ it "should be hash" do
11
+ @past_events.should be_kind_of Hash
12
+ end
13
+
14
+ end
@@ -0,0 +1,46 @@
1
+ require File.join(File.dirname(__FILE__), "test_generator_helper.rb")
2
+
3
+
4
+ class TestAcceptanceTestGenerator < Test::Unit::TestCase
5
+ include RubiGen::GeneratorTestHelper
6
+
7
+ def setup
8
+ bare_setup
9
+ end
10
+
11
+ def teardown
12
+ bare_teardown
13
+ end
14
+
15
+ # Some generator-related assertions:
16
+ # assert_generated_file(name, &block) # block passed the file contents
17
+ # assert_directory_exists(name)
18
+ # assert_generated_class(name, &block)
19
+ # assert_generated_module(name, &block)
20
+ # assert_generated_test_for(name, &block)
21
+ # The assert_generated_(class|module|test_for) &block is passed the body of the class/module within the file
22
+ # assert_has_method(body, *methods) # check that the body has a list of methods (methods with parentheses not supported yet)
23
+ #
24
+ # Other helper methods are:
25
+ # app_root_files - put this in teardown to show files generated by the test method (e.g. p app_root_files)
26
+ # bare_setup - place this in setup method to create the APP_ROOT folder for each test
27
+ # bare_teardown - place this in teardown method to destroy the TMP_ROOT or APP_ROOT folder after each test
28
+
29
+ def test_generator_without_options
30
+ resource = "resource"
31
+ method = "method"
32
+ run_generator('acceptance_test', [resource, method], sources)
33
+ assert_directory_exists "test/acceptance/#{resource}"
34
+ assert_generated_file "test/acceptance/#{resource}/#{method}_test.rb"
35
+ end
36
+
37
+ private
38
+ def sources
39
+ [RubiGen::PathSource.new(:test, File.join(File.dirname(__FILE__),"../..", generator_path))
40
+ ]
41
+ end
42
+
43
+ def generator_path
44
+ "generators"
45
+ end
46
+ end
@@ -0,0 +1,29 @@
1
+ begin
2
+ require File.dirname(__FILE__) + '/test_helper'
3
+ rescue LoadError
4
+ require 'test/unit'
5
+ end
6
+ require 'fileutils'
7
+
8
+ # Must set before requiring generator libs.
9
+ TMP_ROOT = File.dirname(__FILE__) + "/tmp" unless defined?(TMP_ROOT)
10
+ PROJECT_NAME = "myproject" unless defined?(PROJECT_NAME)
11
+ app_root = File.join(TMP_ROOT, PROJECT_NAME)
12
+ if defined?(APP_ROOT)
13
+ APP_ROOT.replace(app_root)
14
+ else
15
+ APP_ROOT = app_root
16
+ end
17
+ if defined?(RAILS_ROOT)
18
+ RAILS_ROOT.replace(app_root)
19
+ else
20
+ RAILS_ROOT = app_root
21
+ end
22
+
23
+ begin
24
+ require 'rubigen'
25
+ rescue LoadError
26
+ require 'rubygems'
27
+ require 'rubigen'
28
+ end
29
+ require 'rubigen/helpers/generator_test_helper'
@@ -0,0 +1,71 @@
1
+ require File.join(File.dirname(__FILE__), "test_generator_helper.rb")
2
+
3
+
4
+ class TestResourceGenerator < Test::Unit::TestCase
5
+ include RubiGen::GeneratorTestHelper
6
+
7
+ def setup
8
+ bare_setup
9
+ end
10
+
11
+ def teardown
12
+ bare_teardown
13
+ end
14
+
15
+ # Some generator-related assertions:
16
+ # assert_generated_file(name, &block) # block passed the file contents
17
+ # assert_directory_exists(name)
18
+ # assert_generated_class(name, &block)
19
+ # assert_generated_module(name, &block)
20
+ # assert_generated_test_for(name, &block)
21
+ # The assert_generated_(class|module|test_for) &block is passed the body of the class/module within the file
22
+ # assert_has_method(body, *methods) # check that the body has a list of methods (methods with parentheses not supported yet)
23
+ #
24
+ # Other helper methods are:
25
+ # app_root_files - put this in teardown to show files generated by the test method (e.g. p app_root_files)
26
+ # bare_setup - place this in setup method to create the APP_ROOT folder for each test
27
+ # bare_teardown - place this in teardown method to destroy the TMP_ROOT or APP_ROOT folder after each test
28
+
29
+ def test_generator_without_options
30
+ resource = "resource"
31
+ funcs = ["method1", "method2"]
32
+ run_generator('resource', funcs.unshift(resource), sources)
33
+ assert_generated_file "lib/scrobbler2/resource.rb" do |file|
34
+ assert file.include?("class Resource < Base")
35
+ assert file.include?("has_resource :method1, :root => \"method1\"")
36
+ assert file.include?("has_resource :method2, :root => \"method2\"")
37
+ end
38
+
39
+ assert_generated_file "test/unit/resource_spec.rb" do |file|
40
+ assert file.include?("describe \"Resource\"")
41
+
42
+ assert file.include?("@resource = Scrobbler2::Resource.new \"...\"")
43
+ assert file.include?("@resource.class.stub!(:get).and_return Hash.new")
44
+
45
+ assert file.include?("it \"should have a default query {TODO}\" do")
46
+ assert file.include?("@resource.instance_variable_get(:@query).should == {}")
47
+
48
+ assert file.include?("it \"method1 should call get with 'resource.getmethod1'\" do")
49
+ assert file.include?("@resource.class.should_receive(:get).with('resource.getmethod1', anything(), anything()).and_return Hash.new")
50
+ assert file.include?("@resource.method1")
51
+
52
+ assert file.include?("it \"method2 should call get with 'resource.getmethod2'\" do")
53
+ assert file.include?("@resource.class.should_receive(:get).with('resource.getmethod2', anything(), anything()).and_return Hash.new")
54
+ assert file.include?("@resource.method2")
55
+ end
56
+
57
+ assert_directory_exists("test/acceptance/resource")
58
+ assert_generated_file "test/acceptance/resource/method1_test.rb"
59
+ assert_generated_file "test/acceptance/resource/method2_test.rb"
60
+ end
61
+
62
+ private
63
+ def sources
64
+ [RubiGen::PathSource.new(:test, File.join(File.dirname(__FILE__),"../..", generator_path))
65
+ ]
66
+ end
67
+
68
+ def generator_path
69
+ "generators"
70
+ end
71
+ end
@@ -0,0 +1,17 @@
1
+ require File.dirname(__FILE__) + "/spec_helper.rb"
2
+
3
+ describe "Album" do
4
+ before(:each) do
5
+ @album = Scrobbler2::Album.new "Metallica", "Ride The Lightning"
6
+ @album.class.stub!(:get).and_return Hash.new
7
+ end
8
+
9
+ it "should have a default query {:artist => 'Metallica', :album => 'Ride The Lightning'}" do
10
+ @album.instance_variable_get(:@query).should == {:artist => 'Metallica', :album => 'Ride The Lightning'}
11
+ end
12
+
13
+ it "info should call get with 'album.getInfo' with query params :artist => @artist, :album => @album" do
14
+ @album.class.should_receive(:get).with('album.getinfo', {:artist => "Metallica", :album => "Ride The Lightning"}, {}).and_return Hash.new
15
+ @album.info
16
+ end
17
+ end