discogs-wrapper 1.1.4 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (93) hide show
  1. data/LICENSE +9 -0
  2. data/README.markdown +123 -43
  3. data/lib/discogs-wrapper.rb +1 -0
  4. data/lib/discogs.rb +1 -0
  5. data/lib/wrapper/authentication.rb +56 -0
  6. data/lib/wrapper/wrapper.rb +732 -43
  7. data/spec/samples/valid_artist.json +1 -0
  8. data/spec/samples/valid_artist_releases.json +1 -0
  9. data/spec/samples/valid_fields.json +48 -0
  10. data/spec/samples/valid_folder.json +6 -0
  11. data/spec/samples/valid_identity.json +6 -0
  12. data/spec/samples/valid_label.json +1 -0
  13. data/spec/samples/valid_label_releases.json +1 -0
  14. data/spec/samples/valid_listing.json +1 -0
  15. data/spec/samples/valid_master_release.json +1 -0
  16. data/spec/samples/valid_master_release_versions.json +1 -0
  17. data/spec/samples/valid_order.json +57 -0
  18. data/spec/samples/valid_order_messages.json +102 -0
  19. data/spec/samples/valid_orders.json +68 -0
  20. data/spec/samples/valid_price_suggestions.json +34 -0
  21. data/spec/samples/valid_release.json +1 -0
  22. data/spec/samples/valid_search_results.json +1 -0
  23. data/spec/samples/valid_user.json +1 -0
  24. data/spec/samples/valid_user_collection.json +1 -0
  25. data/spec/samples/valid_user_folder.json +6 -0
  26. data/spec/samples/valid_user_folders.json +16 -0
  27. data/spec/samples/valid_user_inventory.json +41 -0
  28. data/spec/samples/valid_user_profile.json +25 -0
  29. data/spec/samples/valid_user_wantlist.json +1 -0
  30. data/spec/samples/valid_wantlist_release.json +41 -0
  31. data/spec/spec_helper.rb +4 -18
  32. data/spec/wrapper_methods/add_release_to_user_wantlist_spec.rb +42 -0
  33. data/spec/wrapper_methods/edit_release_in_user_wantlist_spec.rb +38 -0
  34. data/spec/wrapper_methods/edit_user_spec.rb +36 -0
  35. data/spec/wrapper_methods/get_artist_releases_spec.rb +49 -0
  36. data/spec/wrapper_methods/get_artist_spec.rb +15 -75
  37. data/spec/wrapper_methods/get_identity_spec.rb +35 -0
  38. data/spec/wrapper_methods/get_label_releases_spec.rb +49 -0
  39. data/spec/wrapper_methods/get_label_spec.rb +15 -28
  40. data/spec/wrapper_methods/get_listing_spec.rb +40 -0
  41. data/spec/wrapper_methods/get_master_release_spec.rb +16 -42
  42. data/spec/wrapper_methods/get_master_release_versions_spec.rb +49 -0
  43. data/spec/wrapper_methods/get_order_messages_spec.rb +36 -0
  44. data/spec/wrapper_methods/get_order_spec.rb +36 -0
  45. data/spec/wrapper_methods/get_price_suggestions_spec.rb +36 -0
  46. data/spec/wrapper_methods/get_release_spec.rb +26 -52
  47. data/spec/wrapper_methods/get_user_collection_spec.rb +41 -0
  48. data/spec/wrapper_methods/get_user_folder_spec.rb +46 -0
  49. data/spec/wrapper_methods/get_user_folders_spec.rb +42 -0
  50. data/spec/wrapper_methods/get_user_inventory_spec.rb +45 -0
  51. data/spec/wrapper_methods/get_user_spec.rb +45 -0
  52. data/spec/wrapper_methods/get_user_wantlist_spec.rb +49 -0
  53. data/spec/wrapper_methods/search_spec.rb +22 -293
  54. data/spec/wrapper_spec.rb +124 -45
  55. metadata +162 -67
  56. data/Rakefile +0 -26
  57. data/discogs.gemspec +0 -22
  58. data/lib/wrapper/resource.rb +0 -80
  59. data/lib/wrapper/resource_mappings.rb +0 -80
  60. data/lib/wrapper/resources/artist.rb +0 -40
  61. data/lib/wrapper/resources/artist_release.rb +0 -28
  62. data/lib/wrapper/resources/format.rb +0 -11
  63. data/lib/wrapper/resources/generic_list.rb +0 -29
  64. data/lib/wrapper/resources/image.rb +0 -11
  65. data/lib/wrapper/resources/label.rb +0 -16
  66. data/lib/wrapper/resources/label_release.rb +0 -17
  67. data/lib/wrapper/resources/master_release.rb +0 -19
  68. data/lib/wrapper/resources/master_release_version.rb +0 -17
  69. data/lib/wrapper/resources/release.rb +0 -25
  70. data/lib/wrapper/resources/release_artist.rb +0 -21
  71. data/lib/wrapper/resources/release_label.rb +0 -10
  72. data/lib/wrapper/resources/search.rb +0 -61
  73. data/lib/wrapper/resources/search_result.rb +0 -17
  74. data/lib/wrapper/resources/track.rb +0 -19
  75. data/lib/wrapper/resources/user.rb +0 -11
  76. data/lib/wrapper/resources/video.rb +0 -11
  77. data/spec/resource_spec.rb +0 -27
  78. data/spec/resources/artist_release_spec.rb +0 -59
  79. data/spec/resources/artist_spec.rb +0 -15
  80. data/spec/resources/format_spec.rb +0 -41
  81. data/spec/resources/generic_list_spec.rb +0 -66
  82. data/spec/resources/image_spec.rb +0 -43
  83. data/spec/resources/label_release_spec.rb +0 -55
  84. data/spec/resources/label_spec.rb +0 -15
  85. data/spec/resources/master_release_spec.rb +0 -15
  86. data/spec/resources/master_release_version_spec.rb +0 -55
  87. data/spec/resources/release_artist_spec.rb +0 -43
  88. data/spec/resources/release_label_spec.rb +0 -31
  89. data/spec/resources/release_spec.rb +0 -15
  90. data/spec/resources/search_result_spec.rb +0 -47
  91. data/spec/resources/search_spec.rb +0 -15
  92. data/spec/resources/track_spec.rb +0 -56
  93. data/spec/resources/video_spec.rb +0 -43
@@ -0,0 +1 @@
1
+ {"wants": [{"rating": 0, "resource_url": "http://api.discogs.com/users/abuntine/wants/2360509", "basic_information": {"labels": [{"id": 6621, "resource_url": "http://api.discogs.com/labels/6621", "catno": "4 56 577", "name": "AMIGA", "entity_type": "1"}], "formats": [{"descriptions": ["7\"", "45 RPM", "Single"], "name": "Vinyl", "qty": "1"}], "thumb": "http://api.discogs.com/image/R-150-2360509-1279466424.jpeg", "title": "18 Jahre Sein / Mach Keine Wellen", "artists": [{"join": "", "name": "Formel 1 (2)", "anv": "", "tracks": "", "role": "", "resource_url": "http://api.discogs.com/artists/961630", "id": 961630}], "resource_url": "http://api.discogs.com/releases/2360509", "year": 1985, "id": 2360509}, "id": 2360509, "notes_public": false}, {"rating": 0, "resource_url": "http://api.discogs.com/users/abuntine/wants/2621680", "basic_information": {"labels": [{"id": 223844, "resource_url": "http://api.discogs.com/labels/223844", "catno": "WW8301", "name": "Ashbury Music", "entity_type": "1"}], "formats": [{"descriptions": ["LP", "Album"], "name": "Vinyl", "qty": "1"}], "thumb": "http://api.discogs.com/image/R-150-2621680-1368988727-3696.jpeg", "title": "Endless Skies", "artists": [{"join": "", "name": "Ashbury", "anv": "", "tracks": "", "role": "", "resource_url": "http://api.discogs.com/artists/703220", "id": 703220}], "resource_url": "http://api.discogs.com/releases/2621680", "year": 1983, "id": 2621680}, "id": 2621680, "notes_public": false}, {"rating": 0, "resource_url": "http://api.discogs.com/users/abuntine/wants/1898962", "basic_information": {"labels": [{"id": 162562, "resource_url": "http://api.discogs.com/labels/162562", "catno": "none", "name": "Atom Records (6)", "entity_type": ""}], "formats": [{"descriptions": ["Single Sided"], "name": "Cassette", "qty": "1"}], "thumb": "http://api.discogs.com/image/R-150-1898962-1251019631.jpeg", "title": "Breath Of Death", "artists": [{"join": "", "name": "Krabathor", "anv": "Krabator", "tracks": "", "role": "", "resource_url": "http://api.discogs.com/artists/265899", "id": 265899}], "resource_url": "http://api.discogs.com/releases/1898962", "year": 1988, "id": 1898962}, "id": 1898962, "notes_public": false}, {"rating": 0, "resource_url": "http://api.discogs.com/users/abuntine/wants/3161516", "basic_information": {"labels": [{"id": 227019, "resource_url": "http://api.discogs.com/labels/227019", "catno": "BLP-2", "name": "Barrabas Producciones", "entity_type": "1"}], "formats": [{"descriptions": ["LP"], "name": "Vinyl", "qty": "1"}], "thumb": "http://api.discogs.com/image/R-150-3161516-1318553455.jpeg", "title": "El Mensaje Del Mago", "artists": [{"join": "", "name": "\u00d1u", "anv": "", "tracks": "", "role": "", "resource_url": "http://api.discogs.com/artists/1249321", "id": 1249321}], "resource_url": "http://api.discogs.com/releases/3161516", "year": 1987, "id": 3161516}, "id": 3161516, "notes_public": false}, {"rating": 0, "resource_url": "http://api.discogs.com/users/abuntine/wants/1737331", "basic_information": {"labels": [{"id": 232190, "resource_url": "http://api.discogs.com/labels/232190", "catno": "J1 0018-1 311", "name": "Best IA", "entity_type": "1"}], "formats": [{"descriptions": ["LP"], "name": "Vinyl", "qty": "1"}], "thumb": "http://api.discogs.com/image/R-150-1737331-1336936053-3011.jpeg", "title": "Czech Masters Of Rock Guitar / \u010ce\u0161t\u00ed Mist\u0159i Rockov\u00e9 Kytary", "artists": [{"join": "", "name": "Various", "anv": "", "tracks": "", "role": "", "resource_url": "http://api.discogs.com/artists/194", "id": 194}], "resource_url": "http://api.discogs.com/releases/1737331", "year": 1992, "id": 1737331}, "id": 1737331, "notes_public": false}], "pagination": {"per_page": 5, "items": 77, "page": 1, "urls": {"last": "http://api.discogs.com/users/abuntine/wants?per_page=5&page=16", "next": "http://api.discogs.com/users/abuntine/wants?per_page=5&page=2"}, "pages": 16}}
@@ -0,0 +1,41 @@
1
+ {
2
+ "id": 1,
3
+ "rating": 0,
4
+ "notes": "This is a note",
5
+ "resource_url": "http://api.discogs.com/users/example/wants/1",
6
+ "basic_information": {
7
+ "id": 1,
8
+ "resource_url": "http://api.discogs.com/releases/1",
9
+ "thumb": "http://api.discogs.com/image/R-150-1-1193812031.jpeg",
10
+ "title": "Stockholm",
11
+ "year": 1999,
12
+ "formats": [
13
+ {
14
+ "qty": "2",
15
+ "descriptions": [ "12\"" ],
16
+ "name": "Vinyl"
17
+ }
18
+ ],
19
+ "labels": [
20
+ {
21
+ "name": "Svek",
22
+ "entity_type": "1",
23
+ "catno": "SK032",
24
+ "resource_url": "http://api.discogs.com/labels/5",
25
+ "id": 5,
26
+ "entity_type_name": "Label"
27
+ }
28
+ ],
29
+ "artists": [
30
+ {
31
+ "join": "",
32
+ "name": "Persuader, The",
33
+ "anv": "",
34
+ "tracks": "",
35
+ "role": "",
36
+ "resource_url": "http://api.discogs.com/artists/1",
37
+ "id": 1
38
+ }
39
+ ]
40
+ }
41
+ }
data/spec/spec_helper.rb CHANGED
@@ -6,28 +6,14 @@ require 'rubygems'
6
6
  require 'rspec'
7
7
  require File.dirname(__FILE__) + '/../lib/discogs'
8
8
 
9
- def valid_release_xml
10
- read_sample "valid_release.xml"
11
- end
12
-
13
- def valid_master_release_xml
14
- read_sample "valid_master_release.xml"
15
- end
16
-
17
- def valid_artist_xml
18
- read_sample "valid_artist.xml"
19
- end
20
-
21
- def valid_label_xml
22
- read_sample "valid_label.xml"
23
- end
24
-
9
+ # TODO: Remove after searhc is re-implemented.
25
10
  def valid_search_xml(page=1)
26
- read_sample "valid_search_results_#{page}.xml"
11
+ data = File.read(File.join(File.dirname(__FILE__), "samples", "valid_search_results_#{page}.xml"))
12
+ data.gsub /\n/, ''
27
13
  end
28
14
 
29
15
  def read_sample(filename)
30
- data = File.read(File.join(File.dirname(__FILE__), "samples", filename))
16
+ data = File.read(File.join(File.dirname(__FILE__), "samples", "valid_#{filename}.json"))
31
17
  data.gsub /\n/, ''
32
18
  end
33
19
 
@@ -0,0 +1,42 @@
1
+ require 'spec_helper'
2
+
3
+ describe Discogs::Wrapper do
4
+
5
+ before do
6
+ @oauth_access_token = mock(OAuth::AccessToken)
7
+ @wrapper = Discogs::Wrapper.new("some_user_agent", @oauth_access_token)
8
+
9
+ @username = "abuntine"
10
+ @release_id = "1"
11
+ end
12
+
13
+ describe ".add_release_to_user_wantlist" do
14
+
15
+ before do
16
+ @oauth_response = mock(OAuth::AccessToken, :code => "200", :body => read_sample("wantlist_release"))
17
+ @oauth_response_as_file = mock(StringIO, :read => read_sample("wantlist_release"))
18
+ Zlib::GzipReader.should_receive(:new).and_return(@oauth_response_as_file)
19
+ @oauth_access_token.should_receive(:put).and_return(@oauth_response)
20
+
21
+ @wantlist_release = @wrapper.add_release_to_user_wantlist(@username, @release_id)
22
+ end
23
+
24
+ describe "when calling simple wantlist release attributes" do
25
+
26
+ it "should have an id" do
27
+ @wantlist_release.id.should == 1
28
+ end
29
+
30
+ it "should have a rating" do
31
+ @wantlist_release.rating.should == 0
32
+ end
33
+
34
+ it "should have some basic information" do
35
+ @wantlist_release.basic_information.title.should == "Stockholm"
36
+ end
37
+
38
+ end
39
+
40
+ end
41
+
42
+ end
@@ -0,0 +1,38 @@
1
+ require 'spec_helper'
2
+
3
+ describe Discogs::Wrapper do
4
+
5
+ before do
6
+ @oauth_access_token = mock(OAuth::AccessToken)
7
+ @wrapper = Discogs::Wrapper.new("some_user_agent", @oauth_access_token)
8
+
9
+ @username = "abuntine"
10
+ @release_id = "1"
11
+ end
12
+
13
+ describe ".edit_release_in_user_wantlist" do
14
+
15
+ before do
16
+ @oauth_response = mock(OAuth::AccessToken, :code => "200", :body => read_sample("wantlist_release"))
17
+ @oauth_response_as_file = mock(StringIO, :read => read_sample("wantlist_release"))
18
+ Zlib::GzipReader.should_receive(:new).and_return(@oauth_response_as_file)
19
+ @oauth_access_token.should_receive(:post).and_return(@oauth_response)
20
+
21
+ @wantlist_release = @wrapper.edit_release_in_user_wantlist(@username, @release_id, {:notes => "This is a note"})
22
+ end
23
+
24
+ describe "when calling simple wantlist release attributes" do
25
+
26
+ it "should have an id" do
27
+ @wantlist_release.id.should == 1
28
+ end
29
+
30
+ it "should have a some notes" do
31
+ @wantlist_release.notes.should == "This is a note"
32
+ end
33
+
34
+ end
35
+
36
+ end
37
+
38
+ end
@@ -0,0 +1,36 @@
1
+ require 'spec_helper'
2
+
3
+ describe Discogs::Wrapper do
4
+
5
+ before do
6
+ @oauth_access_token = mock(OAuth::AccessToken)
7
+ @wrapper = Discogs::Wrapper.new("some_user_agent", @oauth_access_token)
8
+ @username = "abuntine"
9
+ end
10
+
11
+ describe ".edit_user" do
12
+
13
+ before do
14
+ @oauth_response = mock(OAuth::AccessToken, :code => "200", :body => read_sample("user_profile"))
15
+ @oauth_response_as_file = mock(StringIO, :read => read_sample("user_profile"))
16
+ Zlib::GzipReader.should_receive(:new).and_return(@oauth_response_as_file)
17
+ @oauth_access_token.should_receive(:post).and_return(@oauth_response)
18
+
19
+ @user_profile = @wrapper.edit_user(@username, {:profile => "This is a new profile"})
20
+ end
21
+
22
+ describe "when calling simple user profile attributes" do
23
+
24
+ it "should have a username" do
25
+ @user_profile.username.should == "abuntine"
26
+ end
27
+
28
+ it "should have a new profile" do
29
+ @user_profile.profile.should == "This is a new profile"
30
+ end
31
+
32
+ end
33
+
34
+ end
35
+
36
+ end
@@ -0,0 +1,49 @@
1
+ require 'spec_helper'
2
+
3
+ describe Discogs::Wrapper do
4
+
5
+ before do
6
+ @wrapper = Discogs::Wrapper.new("some_user_agent")
7
+ @artist_id = "313929"
8
+ end
9
+
10
+ describe ".get_artists_releases" do
11
+
12
+ before do
13
+ @http_request = mock(Net::HTTP)
14
+ @http_response = mock(Net::HTTPResponse, :code => "200", :body => read_sample("artist_releases"))
15
+ @http_response_as_file = mock(StringIO, :read => read_sample("artist_releases"))
16
+ Zlib::GzipReader.should_receive(:new).and_return(@http_response_as_file)
17
+ @http_request.should_receive(:start).and_return(@http_response)
18
+ Net::HTTP.should_receive(:new).and_return(@http_request)
19
+
20
+ @artist_releases = @wrapper.get_artist_releases(@artist_id)
21
+ end
22
+
23
+ describe "when calling simple releases attributes" do
24
+
25
+ it "should have 37 releases per page" do
26
+ @artist_releases.releases.length.should == 37
27
+ end
28
+
29
+ it "should have 37 releases total" do
30
+ @artist_releases.pagination.items.should == 37
31
+ end
32
+
33
+ it "should have a first release with a title" do
34
+ @artist_releases.releases.first.title.should == "Frost And Fire"
35
+ end
36
+
37
+ it "should have a first release with a type" do
38
+ @artist_releases.releases.first.type.should == "master"
39
+ end
40
+
41
+ it "should not have a bogus attribute" do
42
+ @artist_releases.bogus_attr.should be_nil
43
+ end
44
+
45
+ end
46
+
47
+ end
48
+
49
+ end
@@ -4,72 +4,47 @@ describe Discogs::Wrapper do
4
4
 
5
5
  before do
6
6
  @wrapper = Discogs::Wrapper.new("some_user_agent")
7
- @artist_name = "Root"
7
+ @artist_id = 313929 # Cirith Ungol
8
8
  end
9
9
 
10
- describe "when asking for artist information" do
10
+ describe ".get_artist" do
11
11
 
12
12
  before do
13
13
  @http_request = mock(Net::HTTP)
14
- @http_response = mock(Net::HTTPResponse, :code => "200", :body => valid_artist_xml)
15
- @http_response_as_file = mock(StringIO, :read => valid_artist_xml)
14
+ @http_response = mock(Net::HTTPResponse, :code => "200", :body => read_sample("artist"))
15
+ @http_response_as_file = mock(StringIO, :read => read_sample("artist"))
16
16
  Zlib::GzipReader.should_receive(:new).and_return(@http_response_as_file)
17
17
  @http_request.should_receive(:start).and_return(@http_response)
18
18
  Net::HTTP.should_receive(:new).and_return(@http_request)
19
19
 
20
- @artist = @wrapper.get_artist(@artist_name)
20
+ @artist = @wrapper.get_artist(@artist_id)
21
21
  end
22
22
 
23
23
  describe "when calling simple artist attributes" do
24
24
 
25
25
  it "should have a name attribute" do
26
- @artist.name.should == "Root"
26
+ @artist.name.should == "Cirith Ungol"
27
27
  end
28
28
 
29
29
  it "should have an id attribute" do
30
- @artist.id.should == "123"
30
+ @artist.id.should == @artist_id
31
31
  end
32
32
 
33
- it "should have a realname attribute" do
34
- @artist.realname.should == "Rootan"
35
- end
36
-
37
33
  it "should have a profile attribute" do
38
- @artist.profile.should == "Richard David James was born to Welsh parents"
34
+ @artist.profile[0..15].should == "Heavy metal band"
39
35
  end
40
36
 
41
37
  it "should have a data_quality attribute" do
42
- @artist.data_quality.should == "Needs Vote"
43
- end
44
-
45
- it "should have one or more aliases" do
46
- @artist.aliases.should be_instance_of(Array)
47
- @artist.aliases[0].should == "Roooot"
48
- end
49
-
50
- it "should have one or more name variations" do
51
- @artist.namevariations.should be_instance_of(Array)
52
- @artist.namevariations[0].should == "Rootan"
38
+ @artist.data_quality.should == "Correct"
53
39
  end
54
40
 
55
41
  it "should have one or more members" do
56
42
  @artist.members.should be_instance_of(Array)
57
- @artist.members[0].should == "Big Boss"
43
+ @artist.members[0].name.should == "Greg Lindstrom"
58
44
  end
59
45
 
60
- it "should be able to filter non-main releases" do
61
- @artist.main_releases.should be_instance_of(Array)
62
- @artist.main_releases.length.should == 4
63
- end
64
-
65
- it "should be able to filter non-bootleg releases" do
66
- @artist.bootlegs.should be_instance_of(Array)
67
- @artist.bootlegs.length.should == 1
68
- end
69
-
70
- it "should be able to filter non-main releases" do
71
- @artist.appearances.should be_instance_of(Array)
72
- @artist.appearances.length.should == 1
46
+ it "should have a releases_url attribute" do
47
+ @artist.releases_url.should =~ /artists\/313929\/releases/
73
48
  end
74
49
 
75
50
  end
@@ -78,17 +53,16 @@ describe Discogs::Wrapper do
78
53
 
79
54
  it "should have a traversible list of URLs" do
80
55
  @artist.urls.should be_instance_of(Array)
81
- @artist.urls[0].should == "http://www.root.net"
82
- @artist.urls[1].should == "http://www.rootan.com"
56
+ @artist.urls[0].should == "http://www.truemetal.org/cirithungol"
57
+ @artist.urls[1].should == "http://www.myspace.com/cirithungol"
83
58
  end
84
59
 
85
60
  it "should have a traversible list of images" do
86
61
  @artist.images.should be_instance_of(Array)
87
- @artist.images[0].should be_instance_of(Discogs::Image)
88
62
  end
89
63
 
90
64
  it "should have specifications for each image" do
91
- specs = [ [ '350', '240', 'secondary' ], [ '222', '226', 'secondary' ], [ '600', '600', 'primary' ] ]
65
+ specs = [ [ 360, 288, 'secondary' ], [ 170, 176, 'secondary' ] ]
92
66
  @artist.images.each_with_index do |image, index|
93
67
  image.width.should == specs[index][0]
94
68
  image.height.should == specs[index][1]
@@ -96,40 +70,6 @@ describe Discogs::Wrapper do
96
70
  end
97
71
  end
98
72
 
99
- it "should have a traversible list of releases" do
100
- @artist.releases.should be_instance_of(Array)
101
- @artist.releases.length.should == 6
102
- @artist.releases[0].should be_instance_of(Discogs::Artist::Release)
103
- end
104
-
105
- it "should have an ID for the first release" do
106
- @artist.releases[0].id.should == "1805661"
107
- end
108
-
109
- it "should have a type for the first release" do
110
- @artist.releases[0].release_type.should == "release"
111
- end
112
-
113
- it "should have a type for the second release" do
114
- @artist.releases[1].release_type.should == "master"
115
- end
116
-
117
- it "should have a main release for the second release" do
118
- @artist.releases[1].main_release.should == "12345"
119
- end
120
-
121
- it "should have a thumb for the second release" do
122
- @artist.releases[1].thumb.should == "http://images"
123
- end
124
-
125
- it "should have a year for the first release" do
126
- @artist.releases[0].year.should == "1991"
127
- end
128
-
129
- it "should have a label for the third release" do
130
- @artist.releases[2].label.should == "Apollo"
131
- end
132
-
133
73
  end
134
74
 
135
75
  end
@@ -0,0 +1,35 @@
1
+ require 'spec_helper'
2
+
3
+ describe Discogs::Wrapper do
4
+
5
+ before do
6
+ @oauth_access_token = mock(OAuth::AccessToken)
7
+ @wrapper = Discogs::Wrapper.new("some_user_agent", @oauth_access_token)
8
+ end
9
+
10
+ describe ".get_identity" do
11
+
12
+ before do
13
+ @oauth_response = mock(OAuth::AccessToken, :code => "200", :body => read_sample("identity"))
14
+ @oauth_response_as_file = mock(StringIO, :read => read_sample("identity"))
15
+ Zlib::GzipReader.should_receive(:new).and_return(@oauth_response_as_file)
16
+ @oauth_access_token.should_receive(:get).and_return(@oauth_response)
17
+
18
+ @identity = @wrapper.get_identity
19
+ end
20
+
21
+ describe "when calling simple identity attributes" do
22
+
23
+ it "should have a username" do
24
+ @identity.username.should == "example"
25
+ end
26
+
27
+ it "should have a consumer_name" do
28
+ @identity.consumer_name.should == "Your Application Name"
29
+ end
30
+
31
+ end
32
+
33
+ end
34
+
35
+ end
@@ -0,0 +1,49 @@
1
+ require 'spec_helper'
2
+
3
+ describe Discogs::Wrapper do
4
+
5
+ before do
6
+ @wrapper = Discogs::Wrapper.new("some_user_agent")
7
+ @label_id = "9800"
8
+ end
9
+
10
+ describe ".get_labels_releases" do
11
+
12
+ before do
13
+ @http_request = mock(Net::HTTP)
14
+ @http_response = mock(Net::HTTPResponse, :code => "200", :body => read_sample("label_releases"))
15
+ @http_response_as_file = mock(StringIO, :read => read_sample("label_releases"))
16
+ Zlib::GzipReader.should_receive(:new).and_return(@http_response_as_file)
17
+ @http_request.should_receive(:start).and_return(@http_response)
18
+ Net::HTTP.should_receive(:new).and_return(@http_request)
19
+
20
+ @label_releases = @wrapper.get_label_releases(@label_id)
21
+ end
22
+
23
+ describe "when calling simple releases attributes" do
24
+
25
+ it "should have 8 releases per page" do
26
+ @label_releases.releases.length.should == 8
27
+ end
28
+
29
+ it "should have 8 releases total" do
30
+ @label_releases.pagination.items.should == 8
31
+ end
32
+
33
+ it "should have a first release with a Cat No" do
34
+ @label_releases.releases.first.catno.should == "SSS 001"
35
+ end
36
+
37
+ it "should have a first release with a status" do
38
+ @label_releases.releases.first.status.should == "Accepted"
39
+ end
40
+
41
+ it "should not have a bogus attribute" do
42
+ @label_releases.bogus_attribute.should be_nil
43
+ end
44
+
45
+ end
46
+
47
+ end
48
+
49
+ end