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.
- data/LICENSE +9 -0
- data/README.markdown +123 -43
- data/lib/discogs-wrapper.rb +1 -0
- data/lib/discogs.rb +1 -0
- data/lib/wrapper/authentication.rb +56 -0
- data/lib/wrapper/wrapper.rb +732 -43
- data/spec/samples/valid_artist.json +1 -0
- data/spec/samples/valid_artist_releases.json +1 -0
- data/spec/samples/valid_fields.json +48 -0
- data/spec/samples/valid_folder.json +6 -0
- data/spec/samples/valid_identity.json +6 -0
- data/spec/samples/valid_label.json +1 -0
- data/spec/samples/valid_label_releases.json +1 -0
- data/spec/samples/valid_listing.json +1 -0
- data/spec/samples/valid_master_release.json +1 -0
- data/spec/samples/valid_master_release_versions.json +1 -0
- data/spec/samples/valid_order.json +57 -0
- data/spec/samples/valid_order_messages.json +102 -0
- data/spec/samples/valid_orders.json +68 -0
- data/spec/samples/valid_price_suggestions.json +34 -0
- data/spec/samples/valid_release.json +1 -0
- data/spec/samples/valid_search_results.json +1 -0
- data/spec/samples/valid_user.json +1 -0
- data/spec/samples/valid_user_collection.json +1 -0
- data/spec/samples/valid_user_folder.json +6 -0
- data/spec/samples/valid_user_folders.json +16 -0
- data/spec/samples/valid_user_inventory.json +41 -0
- data/spec/samples/valid_user_profile.json +25 -0
- data/spec/samples/valid_user_wantlist.json +1 -0
- data/spec/samples/valid_wantlist_release.json +41 -0
- data/spec/spec_helper.rb +4 -18
- data/spec/wrapper_methods/add_release_to_user_wantlist_spec.rb +42 -0
- data/spec/wrapper_methods/edit_release_in_user_wantlist_spec.rb +38 -0
- data/spec/wrapper_methods/edit_user_spec.rb +36 -0
- data/spec/wrapper_methods/get_artist_releases_spec.rb +49 -0
- data/spec/wrapper_methods/get_artist_spec.rb +15 -75
- data/spec/wrapper_methods/get_identity_spec.rb +35 -0
- data/spec/wrapper_methods/get_label_releases_spec.rb +49 -0
- data/spec/wrapper_methods/get_label_spec.rb +15 -28
- data/spec/wrapper_methods/get_listing_spec.rb +40 -0
- data/spec/wrapper_methods/get_master_release_spec.rb +16 -42
- data/spec/wrapper_methods/get_master_release_versions_spec.rb +49 -0
- data/spec/wrapper_methods/get_order_messages_spec.rb +36 -0
- data/spec/wrapper_methods/get_order_spec.rb +36 -0
- data/spec/wrapper_methods/get_price_suggestions_spec.rb +36 -0
- data/spec/wrapper_methods/get_release_spec.rb +26 -52
- data/spec/wrapper_methods/get_user_collection_spec.rb +41 -0
- data/spec/wrapper_methods/get_user_folder_spec.rb +46 -0
- data/spec/wrapper_methods/get_user_folders_spec.rb +42 -0
- data/spec/wrapper_methods/get_user_inventory_spec.rb +45 -0
- data/spec/wrapper_methods/get_user_spec.rb +45 -0
- data/spec/wrapper_methods/get_user_wantlist_spec.rb +49 -0
- data/spec/wrapper_methods/search_spec.rb +22 -293
- data/spec/wrapper_spec.rb +124 -45
- metadata +162 -67
- data/Rakefile +0 -26
- data/discogs.gemspec +0 -22
- data/lib/wrapper/resource.rb +0 -80
- data/lib/wrapper/resource_mappings.rb +0 -80
- data/lib/wrapper/resources/artist.rb +0 -40
- data/lib/wrapper/resources/artist_release.rb +0 -28
- data/lib/wrapper/resources/format.rb +0 -11
- data/lib/wrapper/resources/generic_list.rb +0 -29
- data/lib/wrapper/resources/image.rb +0 -11
- data/lib/wrapper/resources/label.rb +0 -16
- data/lib/wrapper/resources/label_release.rb +0 -17
- data/lib/wrapper/resources/master_release.rb +0 -19
- data/lib/wrapper/resources/master_release_version.rb +0 -17
- data/lib/wrapper/resources/release.rb +0 -25
- data/lib/wrapper/resources/release_artist.rb +0 -21
- data/lib/wrapper/resources/release_label.rb +0 -10
- data/lib/wrapper/resources/search.rb +0 -61
- data/lib/wrapper/resources/search_result.rb +0 -17
- data/lib/wrapper/resources/track.rb +0 -19
- data/lib/wrapper/resources/user.rb +0 -11
- data/lib/wrapper/resources/video.rb +0 -11
- data/spec/resource_spec.rb +0 -27
- data/spec/resources/artist_release_spec.rb +0 -59
- data/spec/resources/artist_spec.rb +0 -15
- data/spec/resources/format_spec.rb +0 -41
- data/spec/resources/generic_list_spec.rb +0 -66
- data/spec/resources/image_spec.rb +0 -43
- data/spec/resources/label_release_spec.rb +0 -55
- data/spec/resources/label_spec.rb +0 -15
- data/spec/resources/master_release_spec.rb +0 -15
- data/spec/resources/master_release_version_spec.rb +0 -55
- data/spec/resources/release_artist_spec.rb +0 -43
- data/spec/resources/release_label_spec.rb +0 -31
- data/spec/resources/release_spec.rb +0 -15
- data/spec/resources/search_result_spec.rb +0 -47
- data/spec/resources/search_spec.rb +0 -15
- data/spec/resources/track_spec.rb +0 -56
- data/spec/resources/video_spec.rb +0 -43
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Discogs::Wrapper do
|
4
|
+
|
5
|
+
before do
|
6
|
+
@wrapper = Discogs::Wrapper.new("some_user_agent")
|
7
|
+
@user_name = "mintfloss"
|
8
|
+
end
|
9
|
+
|
10
|
+
describe ".get_user_collection" do
|
11
|
+
|
12
|
+
before do
|
13
|
+
@http_request = mock(Net::HTTP)
|
14
|
+
@http_response = mock(Net::HTTPResponse, :code => "200", :body => read_sample("user_collection"))
|
15
|
+
@http_response_as_file = mock(StringIO, :read => read_sample("user_collection"))
|
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
|
+
@user_collection = @wrapper.get_user_collection(@user_name)
|
21
|
+
end
|
22
|
+
|
23
|
+
describe "when calling simple collection attributes" do
|
24
|
+
|
25
|
+
it "should have 5 releases per page" do
|
26
|
+
@user_collection.releases.length.should == 5
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should have 309 releases total" do
|
30
|
+
@user_collection.pagination.items.should == 309
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should not have a bogus attribute" do
|
34
|
+
@user_collection.bogus_attr.should be_nil
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Discogs::Wrapper do
|
4
|
+
|
5
|
+
before do
|
6
|
+
@wrapper = Discogs::Wrapper.new("some_user_agent")
|
7
|
+
@user_name = "mintfloss"
|
8
|
+
@folder_id = 0
|
9
|
+
end
|
10
|
+
|
11
|
+
describe ".get_user_folder" do
|
12
|
+
|
13
|
+
before do
|
14
|
+
@http_request = mock(Net::HTTP)
|
15
|
+
@http_response = mock(Net::HTTPResponse, :code => "200", :body => read_sample("user_folder"))
|
16
|
+
@http_response_as_file = mock(StringIO, :read => read_sample("user_folder"))
|
17
|
+
Zlib::GzipReader.should_receive(:new).and_return(@http_response_as_file)
|
18
|
+
@http_request.should_receive(:start).and_return(@http_response)
|
19
|
+
Net::HTTP.should_receive(:new).and_return(@http_request)
|
20
|
+
|
21
|
+
@user_folder = @wrapper.get_user_folder(@user_name, @folder_id)
|
22
|
+
end
|
23
|
+
|
24
|
+
describe "when calling simple folder attributes" do
|
25
|
+
|
26
|
+
it "should have a name" do
|
27
|
+
@user_folder.name.should == "Uncategorized"
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should have a count" do
|
31
|
+
@user_folder[:count].should == 20
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should not have a bogus attribute" do
|
35
|
+
@user_folder.bogus_attr.should be_nil
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should raise error if attempting to list non-0 folder" do
|
39
|
+
lambda { @wrapper.get_user_folder(@user_name, 1) }.should raise_error(Discogs::AuthenticationError)
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Discogs::Wrapper do
|
4
|
+
|
5
|
+
before do
|
6
|
+
@wrapper = Discogs::Wrapper.new("some_user_agent")
|
7
|
+
@user_name = "mintfloss"
|
8
|
+
end
|
9
|
+
|
10
|
+
describe ".get_user_folders" do
|
11
|
+
|
12
|
+
before do
|
13
|
+
@http_request = mock(Net::HTTP)
|
14
|
+
@http_response = mock(Net::HTTPResponse, :code => "200", :body => read_sample("user_folders"))
|
15
|
+
@http_response_as_file = mock(StringIO, :read => read_sample("user_folders"))
|
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
|
+
@user_folders = @wrapper.get_user_folders(@user_name)
|
21
|
+
end
|
22
|
+
|
23
|
+
describe "when calling simple folders attributes" do
|
24
|
+
|
25
|
+
it "should have 2 folders" do
|
26
|
+
@user_folders.folders.length.should == 2
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should have a name for each folder" do
|
30
|
+
@user_folders.folders[0].name.should == "All"
|
31
|
+
@user_folders.folders[1].name.should == "Uncategorized"
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should not have a bogus attribute" do
|
35
|
+
@user_folders.bogus_attribute.should be_nil
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Discogs::Wrapper do
|
4
|
+
|
5
|
+
before do
|
6
|
+
@wrapper = Discogs::Wrapper.new("some_user_agent")
|
7
|
+
@user_name = "abuntine"
|
8
|
+
end
|
9
|
+
|
10
|
+
describe ".get_user_inventory" do
|
11
|
+
|
12
|
+
before do
|
13
|
+
@http_request = mock(Net::HTTP)
|
14
|
+
@http_response = mock(Net::HTTPResponse, :code => "200", :body => read_sample("user_inventory"))
|
15
|
+
@http_response_as_file = mock(StringIO, :read => read_sample("user_inventory"))
|
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
|
+
@user_inventory = @wrapper.get_user_inventory(@user_name)
|
21
|
+
end
|
22
|
+
|
23
|
+
describe "when calling simple inventory attributes" do
|
24
|
+
|
25
|
+
it "should have 1 listing in total" do
|
26
|
+
@user_inventory.listings.length.should == 1
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should have a For Sale listing" do
|
30
|
+
@user_inventory.listings[0].status.should == "For Sale"
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should have a price for the first listing" do
|
34
|
+
@user_inventory.listings[0].price.value.should == 23.0
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should not have a bogus attribute" do
|
38
|
+
@user_inventory.bogus_attr.should be_nil
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Discogs::Wrapper do
|
4
|
+
|
5
|
+
before do
|
6
|
+
@wrapper = Discogs::Wrapper.new("some_user_agent")
|
7
|
+
@user_name = "abuntine"
|
8
|
+
end
|
9
|
+
|
10
|
+
describe ".get_user" do
|
11
|
+
|
12
|
+
before do
|
13
|
+
@http_request = mock(Net::HTTP)
|
14
|
+
@http_response = mock(Net::HTTPResponse, :code => "200", :body => read_sample("user"))
|
15
|
+
@http_response_as_file = mock(StringIO, :read => read_sample("user"))
|
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
|
+
@user = @wrapper.get_user(@user_name)
|
21
|
+
end
|
22
|
+
|
23
|
+
describe "when calling simple user attributes" do
|
24
|
+
|
25
|
+
it "should have a rank" do
|
26
|
+
@user.rank.should == 1.0
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should have a username" do
|
30
|
+
@user.username.should == "abuntine"
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should have a uri" do
|
34
|
+
@user.uri.should == "http://www.discogs.com/user/abuntine"
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should not have a bogus attribute" do
|
38
|
+
@user.bogus_attribute.should be_nil
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
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
|
+
@user_name = "mintfloss"
|
8
|
+
end
|
9
|
+
|
10
|
+
describe ".get_user_wantlist" do
|
11
|
+
|
12
|
+
before do
|
13
|
+
@http_request = mock(Net::HTTP)
|
14
|
+
@http_response = mock(Net::HTTPResponse, :code => "200", :body => read_sample("user_wantlist"))
|
15
|
+
@http_response_as_file = mock(StringIO, :read => read_sample("user_wantlist"))
|
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
|
+
@user_wantlist = @wrapper.get_user_wantlist(@user_name)
|
21
|
+
end
|
22
|
+
|
23
|
+
describe "when calling simple wantlist attributes" do
|
24
|
+
|
25
|
+
it "should have 5 wants per page" do
|
26
|
+
@user_wantlist.wants.length.should == 5
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should have 77 wants total" do
|
30
|
+
@user_wantlist.pagination.items.should == 77
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should have a want with a zero rating" do
|
34
|
+
@user_wantlist.wants.first.rating.should == 0
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should have a want with some basic information" do
|
38
|
+
@user_wantlist.wants.first.basic_information.title.should == "18 Jahre Sein / Mach Keine Wellen"
|
39
|
+
end
|
40
|
+
|
41
|
+
it "should not have a bogus attribute" do
|
42
|
+
@user_wantlist.bogus_attr.should be_nil
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
@@ -4,323 +4,52 @@ describe Discogs::Wrapper do
|
|
4
4
|
|
5
5
|
before do
|
6
6
|
@wrapper = Discogs::Wrapper.new("some_user_agent")
|
7
|
-
@search_term = "
|
8
|
-
|
9
|
-
|
10
|
-
def mock_search(page)
|
11
|
-
@http_request = mock(Net::HTTP)
|
12
|
-
@http_response = mock(Net::HTTPResponse, :code => "200", :body => valid_search_xml(page))
|
13
|
-
@http_response_as_file = mock(StringIO, :read => valid_search_xml(page))
|
14
|
-
Zlib::GzipReader.should_receive(:new).and_return(@http_response_as_file)
|
15
|
-
@http_request.should_receive(:start).and_return(@http_response)
|
16
|
-
Net::HTTP.should_receive(:new).and_return(@http_request)
|
7
|
+
@search_term = "Winter Falls Over the Land"
|
8
|
+
@search_type = "release"
|
17
9
|
end
|
18
10
|
|
19
11
|
describe "when asking for search result information" do
|
20
12
|
|
21
13
|
before do
|
22
|
-
|
23
|
-
|
24
|
-
@
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
@search.current_page.should == 1
|
31
|
-
end
|
32
|
-
|
33
|
-
it "should be able to report if this is the last page" do
|
34
|
-
@search.last_page?.should be_false
|
35
|
-
end
|
36
|
-
|
14
|
+
@http_request = mock(Net::HTTP)
|
15
|
+
@http_response = mock(Net::HTTPResponse, :code => "200", :body => read_sample("search_results"))
|
16
|
+
@http_response_as_file = mock(StringIO, :read => read_sample("search_results"))
|
17
|
+
Zlib::GzipReader.should_receive(:new).and_return(@http_response_as_file)
|
18
|
+
@http_request.should_receive(:start).and_return(@http_response)
|
19
|
+
Net::HTTP.should_receive(:new).and_return(@http_request)
|
20
|
+
|
21
|
+
@search = @wrapper.search(@search_term, :type => @search_type)
|
37
22
|
end
|
38
23
|
|
39
24
|
describe "when handling exact results" do
|
40
25
|
|
41
|
-
it "should have the
|
42
|
-
@search.exactresults.should be_instance_of(Array)
|
43
|
-
end
|
44
|
-
|
45
|
-
it "should be stored as result objects" do
|
46
|
-
@search.exactresults.each do |result|
|
47
|
-
result.should be_instance_of(Discogs::Search::Result)
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
it "should have a incrementing num for each exact result" do
|
52
|
-
@search.exactresults.each_with_index do |result, index|
|
53
|
-
result.num.should == (index + 1).to_s
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
it "should have a type for the first result" do
|
58
|
-
@search.exactresults[0].type.should == "artist"
|
59
|
-
end
|
60
|
-
|
61
|
-
it "should have an anv for the fifth result" do
|
62
|
-
@search.exactresults[5].anv.should == "Slaughter"
|
63
|
-
end
|
64
|
-
|
65
|
-
it "should be able to filter all non-artists from exact results" do
|
66
|
-
@search.exact(:artist).should be_instance_of(Array)
|
67
|
-
@search.exact(:artist).length.should == 6
|
68
|
-
end
|
69
|
-
|
70
|
-
it "should be able to filter all non-releases from exact results" do
|
71
|
-
@search.exact(:release).should be_instance_of(Array)
|
72
|
-
@search.exact(:release).length.should == 1
|
73
|
-
end
|
74
|
-
|
75
|
-
it "should be able to filter all non-labels from exact results" do
|
76
|
-
@search.exact(:label).should be_instance_of(Array)
|
77
|
-
@search.exact(:label).length.should == 1
|
78
|
-
end
|
79
|
-
|
80
|
-
it "should return an empty array on a junk filter" do
|
81
|
-
@search.exact(:cheesecake).should be_instance_of(Array)
|
82
|
-
@search.exact(:cheesecake).should be_empty
|
83
|
-
end
|
84
|
-
|
85
|
-
it "should simply return all exact results without a filter" do
|
86
|
-
@search.exact.should be_instance_of(Array)
|
87
|
-
@search.exact.length.should == 8
|
88
|
-
end
|
89
|
-
|
90
|
-
it "should have a shortcut for accessing the first exact artist" do
|
91
|
-
@search.closest(:artist).should be_instance_of(Discogs::Search::Result)
|
92
|
-
@search.closest(:artist).should == @search.exact(:artist)[0]
|
93
|
-
end
|
94
|
-
|
95
|
-
it "should have a shortcut for accessing the first exact release" do
|
96
|
-
@search.closest(:release).should be_instance_of(Discogs::Search::Result)
|
97
|
-
@search.closest(:release).should == @search.exact(:release)[0]
|
98
|
-
end
|
99
|
-
|
100
|
-
it "should have a shortcut for accessing the first exact label" do
|
101
|
-
@search.closest(:label).should be_instance_of(Discogs::Search::Result)
|
102
|
-
@search.closest(:label).should == @search.exact(:label)[0]
|
103
|
-
end
|
104
|
-
|
105
|
-
it "should return nil on junk filter for closest match" do
|
106
|
-
@search.closest(:alcoholic).should be_nil
|
107
|
-
end
|
108
|
-
|
109
|
-
end
|
110
|
-
|
111
|
-
describe "when handling search results" do
|
112
|
-
|
113
|
-
it "should have a start attribute" do
|
114
|
-
@search.start.should == "1"
|
115
|
-
end
|
116
|
-
|
117
|
-
it "should have an end attribute" do
|
118
|
-
@search.end.should == "20"
|
119
|
-
end
|
120
|
-
|
121
|
-
it "should have number of results attribute" do
|
122
|
-
@search.total_results.should == 1846
|
123
|
-
end
|
124
|
-
|
125
|
-
it "should have number of pages attribute" do
|
126
|
-
@search.total_pages.should == 93
|
127
|
-
end
|
128
|
-
|
129
|
-
it "should have the search results stored as an array" do
|
130
|
-
@search.searchresults.should be_instance_of(Array)
|
131
|
-
end
|
132
|
-
|
133
|
-
it "should be stored as result objects" do
|
134
|
-
@search.searchresults.each do |result|
|
135
|
-
result.should be_instance_of(Discogs::Search::Result)
|
136
|
-
end
|
137
|
-
end
|
138
|
-
|
139
|
-
end
|
140
|
-
|
141
|
-
describe "when handling search results" do
|
142
|
-
|
143
|
-
it "should have a start attribute" do
|
144
|
-
@search.start.should == "1"
|
145
|
-
end
|
146
|
-
|
147
|
-
it "should have an end attribute" do
|
148
|
-
@search.end.should == "20"
|
149
|
-
end
|
150
|
-
|
151
|
-
it "should have number of results attribute" do
|
152
|
-
@search.total_results.should == 1846
|
153
|
-
end
|
154
|
-
|
155
|
-
it "should have number of pages attribute" do
|
156
|
-
@search.total_pages.should == 93
|
157
|
-
end
|
158
|
-
|
159
|
-
it "should have the search results stored as an array" do
|
160
|
-
@search.searchresults.should be_instance_of(Array)
|
161
|
-
end
|
162
|
-
|
163
|
-
it "should be stored as result objects" do
|
164
|
-
@search.searchresults.each do |result|
|
165
|
-
result.should be_instance_of(Discogs::Search::Result)
|
166
|
-
end
|
167
|
-
end
|
168
|
-
|
169
|
-
end
|
170
|
-
|
171
|
-
describe "when handling search results" do
|
172
|
-
|
173
|
-
it "should have a start attribute" do
|
174
|
-
@search.start.should == "1"
|
175
|
-
end
|
176
|
-
|
177
|
-
it "should have an end attribute" do
|
178
|
-
@search.end.should == "20"
|
179
|
-
end
|
180
|
-
|
181
|
-
it "should have number of results attribute" do
|
182
|
-
@search.total_results.should == 1846
|
183
|
-
end
|
184
|
-
|
185
|
-
it "should have number of pages attribute" do
|
186
|
-
@search.total_pages.should == 93
|
187
|
-
end
|
188
|
-
|
189
|
-
it "should have the search results stored as an array" do
|
190
|
-
@search.searchresults.should be_instance_of(Array)
|
191
|
-
end
|
192
|
-
|
193
|
-
it "should be stored as result objects" do
|
194
|
-
@search.searchresults.each do |result|
|
195
|
-
result.should be_instance_of(Discogs::Search::Result)
|
196
|
-
end
|
197
|
-
end
|
198
|
-
|
199
|
-
it "should have a incrementing num for each search result" do
|
200
|
-
@search.searchresults.each_with_index do |result, index|
|
201
|
-
result.num.should == (index + 1).to_s
|
202
|
-
end
|
203
|
-
end
|
204
|
-
|
205
|
-
it "should have a type for the third result" do
|
206
|
-
@search.searchresults[2].type.should == "label"
|
207
|
-
end
|
208
|
-
|
209
|
-
it "should have a title for the fourth result" do
|
210
|
-
@search.searchresults[3].title.should == "Satanic Slaughter"
|
211
|
-
end
|
212
|
-
|
213
|
-
it "should have a summary for the sixth result" do
|
214
|
-
@search.searchresults[5].summary.should == "Gary Slaughter"
|
215
|
-
end
|
216
|
-
|
217
|
-
it "should be able to filter all non-artists from extended results" do
|
218
|
-
@search.results(:artist).should be_instance_of(Array)
|
219
|
-
@search.results(:artist).length.should == 12
|
220
|
-
end
|
221
|
-
|
222
|
-
it "should be able to filter all non-releases from extended results" do
|
223
|
-
@search.results(:release).should be_instance_of(Array)
|
224
|
-
@search.results(:release).length.should == 6
|
225
|
-
end
|
226
|
-
|
227
|
-
it "should be able to filter all non-labels from extended results" do
|
228
|
-
@search.results(:label).should be_instance_of(Array)
|
229
|
-
@search.results(:label).length.should == 2
|
230
|
-
end
|
231
|
-
|
232
|
-
it "should return an empty array on a junk filter" do
|
233
|
-
@search.results(:cheesecake).should be_instance_of(Array)
|
234
|
-
@search.results(:cheesecake).should be_empty
|
235
|
-
end
|
236
|
-
|
237
|
-
it "should simply return all extended results without a filter" do
|
26
|
+
it "should have the results stored as an array" do
|
238
27
|
@search.results.should be_instance_of(Array)
|
239
|
-
@search.results.length.should == 20
|
240
|
-
end
|
241
|
-
|
242
|
-
end
|
243
|
-
|
244
|
-
end
|
245
|
-
|
246
|
-
describe "when getting the next page" do
|
247
|
-
|
248
|
-
before do
|
249
|
-
mock_search(2)
|
250
|
-
|
251
|
-
@search = @wrapper.search(@search_term, :page => 2)
|
252
|
-
end
|
253
|
-
|
254
|
-
describe "when dealing with page information" do
|
255
|
-
|
256
|
-
it "should have a current_page method" do
|
257
|
-
@search.current_page.should == 2
|
258
|
-
end
|
259
|
-
|
260
|
-
it "should be able to report if this is the last page" do
|
261
|
-
@search.last_page?.should be_false
|
262
|
-
end
|
263
|
-
|
264
|
-
end
|
265
|
-
|
266
|
-
describe "when handling exact results" do
|
267
|
-
|
268
|
-
it "should not have any exact results" do
|
269
|
-
@search.exactresults.should be_nil
|
270
|
-
end
|
271
|
-
|
272
|
-
it "should return empty array for exact filtering" do
|
273
|
-
@search.exact.should == []
|
274
28
|
end
|
275
29
|
|
276
|
-
it "should
|
277
|
-
@search.
|
30
|
+
it "should have a type for the first result" do
|
31
|
+
@search.results[0].type.should == "release"
|
278
32
|
end
|
279
33
|
|
280
|
-
it "should
|
281
|
-
@search.
|
282
|
-
@search.
|
283
|
-
@search.closest(:label).should be_nil
|
34
|
+
it "should have a style array for the first result" do
|
35
|
+
@search.results[0].style.should be_instance_of(Array)
|
36
|
+
@search.results[0].style[0].should == "Black Metal"
|
284
37
|
end
|
285
38
|
|
286
|
-
it "should
|
287
|
-
@search.
|
39
|
+
it "should have a type for the fourth result" do
|
40
|
+
@search.results[3].type.should == "release"
|
288
41
|
end
|
289
42
|
|
290
43
|
end
|
291
44
|
|
292
45
|
describe "when handling search results" do
|
293
46
|
|
294
|
-
it "should have
|
295
|
-
@search.
|
296
|
-
end
|
297
|
-
|
298
|
-
it "should have an end attribute" do
|
299
|
-
@search.end.should == "40"
|
47
|
+
it "should have number of results per page attribute" do
|
48
|
+
@search.pagination.per_page.should == 50
|
300
49
|
end
|
301
50
|
|
302
|
-
it "should have number of
|
303
|
-
@search.
|
304
|
-
end
|
305
|
-
|
306
|
-
it "should have number of pages attribute (still)" do
|
307
|
-
@search.total_pages.should == 93
|
308
|
-
end
|
309
|
-
|
310
|
-
it "should have the search results stored as an array" do
|
311
|
-
@search.searchresults.should be_instance_of(Array)
|
312
|
-
end
|
313
|
-
|
314
|
-
it "should be stored as result objects" do
|
315
|
-
@search.searchresults.each do |result|
|
316
|
-
result.should be_instance_of(Discogs::Search::Result)
|
317
|
-
end
|
318
|
-
end
|
319
|
-
|
320
|
-
it "should have a incrementing num for each search result" do
|
321
|
-
@search.searchresults.each_with_index do |result, index|
|
322
|
-
result.num.should == (index + 21).to_s
|
323
|
-
end
|
51
|
+
it "should have number of pages attribute" do
|
52
|
+
@search.pagination.pages.should == 1
|
324
53
|
end
|
325
54
|
|
326
55
|
end
|