lastfm 1.27.3 → 1.27.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.
- checksums.yaml +4 -4
- data/.rspec +2 -2
- data/lastfm.gemspec +3 -3
- data/spec/lastfm_spec.rb +34 -34
- data/spec/method_category_spec.rb +1 -1
- data/spec/method_specs/album_spec.rb +92 -92
- data/spec/method_specs/artist_spec.rb +73 -73
- data/spec/method_specs/chart_spec.rb +13 -13
- data/spec/method_specs/event_spec.rb +3 -3
- data/spec/method_specs/geo_spec.rb +13 -13
- data/spec/method_specs/group_spec.rb +4 -4
- data/spec/method_specs/library_spec.rb +7 -7
- data/spec/method_specs/radio_spec.rb +10 -10
- data/spec/method_specs/tag_spec.rb +28 -28
- data/spec/method_specs/tasteometer_spec.rb +4 -4
- data/spec/method_specs/track_spec.rb +76 -76
- data/spec/method_specs/user_spec.rb +101 -101
- data/spec/response_spec.rb +6 -6
- data/spec/util_spec.rb +16 -16
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 97fb464cf27713555c45f696a2c7489906c6d8dc
|
4
|
+
data.tar.gz: 93856d36bde02f40e1b9180f151e29363fc51ef8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0f0c940d644e5fd4f4c55d0c77ef4e1fa8be5e5252e9e00a2552296745ab4f892478da72d09021b752a7770035c76e065cd8941d900b3d16c2bf6afaa04e3259
|
7
|
+
data.tar.gz: 874c706e479275dbff678f62bee3dd87767e8c074722dd4bc08161a1981becbb80608a118f35abdd536353781cbed9c654be7de32a98cb06786289ad29db9d8e
|
data/.rspec
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
--color
|
2
|
+
--format documentation
|
data/lastfm.gemspec
CHANGED
@@ -12,12 +12,12 @@ Gem::Specification.new do |gem|
|
|
12
12
|
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
13
13
|
gem.name = %q{lastfm}
|
14
14
|
gem.require_paths = ["lib"]
|
15
|
-
gem.version = "1.27.
|
15
|
+
gem.version = "1.27.4"
|
16
16
|
gem.license = 'MIT'
|
17
17
|
|
18
18
|
gem.add_dependency "xml-simple"
|
19
19
|
gem.add_dependency "httparty"
|
20
20
|
|
21
|
-
gem.add_development_dependency('rspec', ['~>
|
22
|
-
gem.add_development_dependency('rake', '<
|
21
|
+
gem.add_development_dependency('rspec', ['~> 3.4.0'])
|
22
|
+
gem.add_development_dependency('rake', '< 12.3.3')
|
23
23
|
end
|
data/spec/lastfm_spec.rb
CHANGED
@@ -5,105 +5,105 @@ describe "Lastfm" do
|
|
5
5
|
|
6
6
|
describe '.new' do
|
7
7
|
it 'should instantiate' do
|
8
|
-
@lastfm.
|
8
|
+
expect(@lastfm).to be_an_instance_of(Lastfm)
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
12
12
|
describe '#request' do
|
13
13
|
it 'should post' do
|
14
|
-
mock_response =
|
15
|
-
HTTPRequest.
|
14
|
+
mock_response = double(HTTParty::Response)
|
15
|
+
expect(HTTPRequest).to receive(:post).with('/', :body => {
|
16
16
|
:foo => 'bar',
|
17
17
|
:method => 'xxx.yyy',
|
18
18
|
:api_key => 'xxx',
|
19
19
|
}).and_return(mock_response)
|
20
|
-
mock_response.
|
20
|
+
expect(mock_response).to receive(:body).and_return(@response_xml)
|
21
21
|
@lastfm.request('xxx.yyy', { :foo => 'bar' }, :post, false, false)
|
22
22
|
end
|
23
23
|
|
24
24
|
it 'should post with signature' do
|
25
|
-
mock_response =
|
26
|
-
HTTPRequest.
|
25
|
+
mock_response = double(HTTParty::Response)
|
26
|
+
expect(HTTPRequest).to receive(:post).with('/', :body => {
|
27
27
|
:foo => 'bar',
|
28
28
|
:method => 'xxx.yyy',
|
29
29
|
:api_key => 'xxx',
|
30
30
|
:api_sig => Digest::MD5.hexdigest('api_keyxxxfoobarmethodxxx.yyyyyy'),
|
31
31
|
}).and_return(mock_response)
|
32
|
-
mock_response.
|
32
|
+
expect(mock_response).to receive(:body).and_return(@response_xml)
|
33
33
|
@lastfm.request('xxx.yyy', { :foo => 'bar' }, :post, true, false)
|
34
34
|
end
|
35
35
|
|
36
36
|
it 'should post with signature and session (request with authentication)' do
|
37
|
-
mock_response =
|
37
|
+
mock_response = double(HTTParty::Response)
|
38
38
|
@lastfm.session = 'abcdef'
|
39
|
-
HTTPRequest.
|
39
|
+
expect(HTTPRequest).to receive(:post).with('/', :body => {
|
40
40
|
:foo => 'bar',
|
41
41
|
:method => 'xxx.yyy',
|
42
42
|
:api_key => 'xxx',
|
43
43
|
:api_sig => Digest::MD5.hexdigest('api_keyxxxfoobarmethodxxx.yyyskabcdefyyy'),
|
44
44
|
:sk => 'abcdef',
|
45
45
|
}).and_return(mock_response)
|
46
|
-
mock_response.
|
46
|
+
expect(mock_response).to receive(:body).and_return(@response_xml)
|
47
47
|
@lastfm.request('xxx.yyy', { :foo => 'bar' }, :post, true, true)
|
48
48
|
end
|
49
49
|
|
50
50
|
it 'should get' do
|
51
|
-
mock_response =
|
52
|
-
HTTPRequest.
|
51
|
+
mock_response = double(HTTParty::Response)
|
52
|
+
expect(HTTPRequest).to receive(:get).with('/', :query => {
|
53
53
|
:foo => 'bar',
|
54
54
|
:method => 'xxx.yyy',
|
55
55
|
:api_key => 'xxx',
|
56
56
|
}).and_return(mock_response)
|
57
|
-
mock_response.
|
57
|
+
expect(mock_response).to receive(:body).and_return(@response_xml)
|
58
58
|
@lastfm.request('xxx.yyy', { :foo => 'bar' }, :get, false, false)
|
59
59
|
end
|
60
60
|
|
61
61
|
it 'should get with signature (request for authentication)' do
|
62
|
-
mock_response =
|
63
|
-
HTTPRequest.
|
62
|
+
mock_response = double(HTTParty::Response)
|
63
|
+
expect(HTTPRequest).to receive(:get).with('/', :query => {
|
64
64
|
:foo => 'bar',
|
65
65
|
:method => 'xxx.yyy',
|
66
66
|
:api_key => 'xxx',
|
67
67
|
:api_sig => Digest::MD5.hexdigest('api_keyxxxfoobarmethodxxx.yyyyyy'),
|
68
68
|
}).and_return(mock_response)
|
69
|
-
mock_response.
|
69
|
+
expect(mock_response).to receive(:body).and_return(@response_xml)
|
70
70
|
@lastfm.request('xxx.yyy', { :foo => 'bar' }, :get, true, false)
|
71
71
|
end
|
72
72
|
|
73
73
|
it 'should get with signature and session' do
|
74
|
-
mock_response =
|
74
|
+
mock_response = double(HTTParty::Response)
|
75
75
|
@lastfm.session = 'abcdef'
|
76
|
-
HTTPRequest.
|
76
|
+
expect(HTTPRequest).to receive(:get).with('/', :query => {
|
77
77
|
:foo => 'bar',
|
78
78
|
:method => 'xxx.yyy',
|
79
79
|
:api_key => 'xxx',
|
80
80
|
:api_sig => Digest::MD5.hexdigest('api_keyxxxfoobarmethodxxx.yyyskabcdefyyy'),
|
81
81
|
:sk => 'abcdef',
|
82
82
|
}).and_return(mock_response)
|
83
|
-
mock_response.
|
83
|
+
expect(mock_response).to receive(:body).and_return(@response_xml)
|
84
84
|
@lastfm.request('xxx.yyy', { :foo => 'bar' }, :get, true, true)
|
85
85
|
end
|
86
86
|
|
87
87
|
it 'should raise an error if an api error is ocuured' do
|
88
|
-
mock_response =
|
89
|
-
mock_response.
|
90
|
-
HTTPRequest.
|
88
|
+
mock_response = double(HTTParty::Response)
|
89
|
+
expect(mock_response).to receive(:body).and_return(open(fixture('ng.xml')).read)
|
90
|
+
expect(HTTPRequest).to receive(:post).and_return(mock_response)
|
91
91
|
|
92
|
-
|
92
|
+
expect {
|
93
93
|
@lastfm.request('xxx.yyy', { :foo => 'bar' }, :post)
|
94
|
-
}.
|
95
|
-
error.code.
|
94
|
+
}.to raise_error(Lastfm::ApiError, 'Invalid API key - You must be granted a valid key by last.fm') {|error|
|
95
|
+
expect(error.code).to eq(10)
|
96
96
|
}
|
97
97
|
end
|
98
98
|
end
|
99
99
|
|
100
100
|
describe '#auth' do
|
101
101
|
it 'should return an instance of Lastfm::Auth' do
|
102
|
-
@lastfm.auth.
|
102
|
+
expect(@lastfm.auth).to be_an_instance_of(Lastfm::MethodCategory::Auth)
|
103
103
|
end
|
104
104
|
|
105
105
|
it 'should get token' do
|
106
|
-
@lastfm.
|
106
|
+
expect(@lastfm).to receive(:request).
|
107
107
|
with('auth.getToken', {}, :get, true).
|
108
108
|
and_return(make_response(<<XML))
|
109
109
|
<?xml version="1.0" encoding="utf-8"?>
|
@@ -111,11 +111,11 @@ describe "Lastfm" do
|
|
111
111
|
<token>xxxyyyzzz</token></lfm>
|
112
112
|
XML
|
113
113
|
|
114
|
-
@lastfm.auth.get_token.
|
114
|
+
expect(@lastfm.auth.get_token).to eq('xxxyyyzzz')
|
115
115
|
end
|
116
116
|
|
117
117
|
it 'should get session' do
|
118
|
-
@lastfm.
|
118
|
+
expect(@lastfm).to receive(:request).
|
119
119
|
with('auth.getSession', { :token => 'xxxyyyzzz' }, :get, true).
|
120
120
|
and_return(make_response(<<XML))
|
121
121
|
<?xml version="1.0" encoding="utf-8"?>
|
@@ -128,12 +128,12 @@ XML
|
|
128
128
|
</lfm>
|
129
129
|
XML
|
130
130
|
session = @lastfm.auth.get_session('xxxyyyzzz')
|
131
|
-
session['name'].
|
132
|
-
session['key'].
|
131
|
+
expect(session['name']).to eq('MyLastFMUsername')
|
132
|
+
expect(session['key']).to eq('zzzyyyxxx')
|
133
133
|
end
|
134
134
|
|
135
135
|
it 'should get mobile session' do
|
136
|
-
@lastfm.
|
136
|
+
expect(@lastfm).to receive(:request).
|
137
137
|
with('auth.getMobileSession', { :username => 'xxxyyyzzz', :password => 'sekretz' }, :post, true, false, true).
|
138
138
|
and_return(make_response(<<XML))
|
139
139
|
<?xml version="1.0" encoding="utf-8"?>
|
@@ -146,8 +146,8 @@ XML
|
|
146
146
|
</lfm>
|
147
147
|
XML
|
148
148
|
session = @lastfm.auth.get_mobile_session('xxxyyyzzz', 'sekretz')
|
149
|
-
session['name'].
|
150
|
-
session['key'].
|
149
|
+
expect(session['name']).to eq('MyLastFMUsername')
|
150
|
+
expect(session['key']).to eq('zzzyyyxxx')
|
151
151
|
end
|
152
152
|
end
|
153
153
|
end
|
@@ -6,6 +6,6 @@ describe 'Lastfm::MethodCategory' do
|
|
6
6
|
end
|
7
7
|
|
8
8
|
it 'should have instance of Lastfm' do
|
9
|
-
Lastfm::MethodCategory::Base.new(@lastfm).instance_eval { @lastfm }.
|
9
|
+
expect(Lastfm::MethodCategory::Base.new(@lastfm).instance_eval { @lastfm }).to equal(@lastfm)
|
10
10
|
end
|
11
11
|
end
|
@@ -5,28 +5,28 @@ describe '#album' do
|
|
5
5
|
before { init_lastfm }
|
6
6
|
|
7
7
|
it 'should return an instance of Lastfm::Album' do
|
8
|
-
@lastfm.album.
|
8
|
+
expect(@lastfm.album).to be_an_instance_of(Lastfm::MethodCategory::Album)
|
9
9
|
end
|
10
10
|
|
11
11
|
describe '#add_tags' do
|
12
12
|
it 'should add tags' do
|
13
|
-
@lastfm.
|
13
|
+
expect(@lastfm).to receive(:request).with('album.addTags', {
|
14
14
|
:artist => 'foo artist',
|
15
15
|
:album => 'foo track',
|
16
16
|
:tags => 'aaa,bbb,ccc'
|
17
17
|
}, :post, true, true).and_return(@ok_response)
|
18
18
|
|
19
|
-
@lastfm.album.add_tags(
|
19
|
+
expect(@lastfm.album.add_tags(
|
20
20
|
:artist => 'foo artist',
|
21
21
|
:album => 'foo track',
|
22
22
|
:tags => 'aaa,bbb,ccc'
|
23
|
-
).
|
23
|
+
)).to be_truthy
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
27
|
describe '#get_buylinks' do
|
28
28
|
it 'should get buylinks' do
|
29
|
-
@lastfm.
|
29
|
+
expect(@lastfm).to receive(:request).with('album.getBuylinks', {
|
30
30
|
:artist => 'radiohead',
|
31
31
|
:album => 'in rainbows',
|
32
32
|
:country => 'united kingdom',
|
@@ -39,23 +39,23 @@ describe '#album' do
|
|
39
39
|
:country => 'united kingdom'
|
40
40
|
)
|
41
41
|
|
42
|
-
buylinks['physicals'].size.
|
43
|
-
buylinks['physicals']['affiliation']['supplierName'].
|
44
|
-
buylinks['physicals']['affiliation']['price']['currency'].
|
45
|
-
buylinks['physicals']['affiliation']['price']['amount'].
|
46
|
-
buylinks['physicals']['affiliation']['price']['formatted'].
|
47
|
-
buylinks['physicals']['affiliation']['buyLink'].
|
48
|
-
|
49
|
-
buylinks['downloads'].size.
|
50
|
-
buylinks['downloads']['affiliation']['supplierName'].
|
51
|
-
buylinks['downloads']['affiliation']['price']['currency'].
|
52
|
-
buylinks['downloads']['affiliation']['price']['amount'].
|
53
|
-
buylinks['downloads']['affiliation']['price']['formatted'].
|
54
|
-
buylinks['downloads']['affiliation']['buyLink'].
|
42
|
+
expect(buylinks['physicals'].size).to eq(1)
|
43
|
+
expect(buylinks['physicals']['affiliation']['supplierName']).to eq('Amazon')
|
44
|
+
expect(buylinks['physicals']['affiliation']['price']['currency']).to eq('GBP')
|
45
|
+
expect(buylinks['physicals']['affiliation']['price']['amount']).to eq('6.34')
|
46
|
+
expect(buylinks['physicals']['affiliation']['price']['formatted']).to eq('£6.34')
|
47
|
+
expect(buylinks['physicals']['affiliation']['buyLink']).to eq('http://www.last.fm/affiliate/byid/8/3418994/1/ws.album.buylinks.f4e2585261d8d10d3297e181d68940fc')
|
48
|
+
|
49
|
+
expect(buylinks['downloads'].size).to eq(1)
|
50
|
+
expect(buylinks['downloads']['affiliation']['supplierName']).to eq('Amazon MP3')
|
51
|
+
expect(buylinks['downloads']['affiliation']['price']['currency']).to eq('GBP')
|
52
|
+
expect(buylinks['downloads']['affiliation']['price']['amount']).to eq('7.99')
|
53
|
+
expect(buylinks['downloads']['affiliation']['price']['formatted']).to eq('£7.99')
|
54
|
+
expect(buylinks['downloads']['affiliation']['buyLink']).to eq('http://www.last.fm/affiliate/byid/8/3418994/44/ws.album.buylinks.f4e2585261d8d10d3297e181d68940fc')
|
55
55
|
end
|
56
56
|
|
57
57
|
it 'should get buylinks by mbid' do
|
58
|
-
@lastfm.
|
58
|
+
expect(@lastfm).to receive(:request).with('album.getBuylinks', {
|
59
59
|
:mbid => 'radiohead',
|
60
60
|
:country => 'united kingdom',
|
61
61
|
:autocorrect => nil
|
@@ -66,19 +66,19 @@ describe '#album' do
|
|
66
66
|
:country => 'united kingdom'
|
67
67
|
)
|
68
68
|
|
69
|
-
buylinks['physicals'].size.
|
70
|
-
buylinks['physicals']['affiliation']['supplierName'].
|
71
|
-
buylinks['physicals']['affiliation']['price']['currency'].
|
72
|
-
buylinks['physicals']['affiliation']['price']['amount'].
|
73
|
-
buylinks['physicals']['affiliation']['price']['formatted'].
|
74
|
-
buylinks['physicals']['affiliation']['buyLink'].
|
75
|
-
|
76
|
-
buylinks['downloads'].size.
|
77
|
-
buylinks['downloads']['affiliation']['supplierName'].
|
78
|
-
buylinks['downloads']['affiliation']['price']['currency'].
|
79
|
-
buylinks['downloads']['affiliation']['price']['amount'].
|
80
|
-
buylinks['downloads']['affiliation']['price']['formatted'].
|
81
|
-
buylinks['downloads']['affiliation']['buyLink'].
|
69
|
+
expect(buylinks['physicals'].size).to eq(1)
|
70
|
+
expect(buylinks['physicals']['affiliation']['supplierName']).to eq('Amazon')
|
71
|
+
expect(buylinks['physicals']['affiliation']['price']['currency']).to eq('GBP')
|
72
|
+
expect(buylinks['physicals']['affiliation']['price']['amount']).to eq('6.34')
|
73
|
+
expect(buylinks['physicals']['affiliation']['price']['formatted']).to eq('£6.34')
|
74
|
+
expect(buylinks['physicals']['affiliation']['buyLink']).to eq('http://www.last.fm/affiliate/byid/8/3418994/1/ws.album.buylinks.f4e2585261d8d10d3297e181d68940fc')
|
75
|
+
|
76
|
+
expect(buylinks['downloads'].size).to eq(1)
|
77
|
+
expect(buylinks['downloads']['affiliation']['supplierName']).to eq('Amazon MP3')
|
78
|
+
expect(buylinks['downloads']['affiliation']['price']['currency']).to eq('GBP')
|
79
|
+
expect(buylinks['downloads']['affiliation']['price']['amount']).to eq('7.99')
|
80
|
+
expect(buylinks['downloads']['affiliation']['price']['formatted']).to eq('£7.99')
|
81
|
+
expect(buylinks['downloads']['affiliation']['buyLink']).to eq('http://www.last.fm/affiliate/byid/8/3418994/44/ws.album.buylinks.f4e2585261d8d10d3297e181d68940fc')
|
82
82
|
end
|
83
83
|
|
84
84
|
it 'should raise ArgumentError without country' do
|
@@ -95,56 +95,56 @@ describe '#album' do
|
|
95
95
|
|
96
96
|
describe '#get_info' do
|
97
97
|
it 'should get info by artist and album' do
|
98
|
-
@lastfm.
|
98
|
+
expect(@lastfm).to receive(:request).with('album.getInfo', {
|
99
99
|
:artist => 'Cher', :album => 'Believe'
|
100
100
|
}).and_return(make_response('album_get_info'))
|
101
101
|
|
102
102
|
album = @lastfm.album.get_info(:artist => 'Cher', :album => 'Believe')
|
103
|
-
album['name'].
|
104
|
-
album['artist'].
|
105
|
-
album['id'].
|
106
|
-
album['mbid'].
|
107
|
-
album['url'].
|
108
|
-
album['image'].size.
|
109
|
-
album['releasedate'].
|
110
|
-
album['tracks']['track'].size.
|
111
|
-
album['tracks']['track'][0]['name'].
|
112
|
-
album['tracks']['track'][0]['duration'].
|
113
|
-
album['tracks']['track'][0]['url'].
|
103
|
+
expect(album['name']).to eq('Believe')
|
104
|
+
expect(album['artist']).to eq('Cher')
|
105
|
+
expect(album['id']).to eq('2026126')
|
106
|
+
expect(album['mbid']).to eq('61bf0388-b8a9-48f4-81d1-7eb02706dfb0')
|
107
|
+
expect(album['url']).to eq('http://www.last.fm/music/Cher/Believe')
|
108
|
+
expect(album['image'].size).to eq(5)
|
109
|
+
expect(album['releasedate']).to eq('6 Apr 1999, 00:00')
|
110
|
+
expect(album['tracks']['track'].size).to eq(10)
|
111
|
+
expect(album['tracks']['track'][0]['name']).to eq('Believe')
|
112
|
+
expect(album['tracks']['track'][0]['duration']).to eq('239')
|
113
|
+
expect(album['tracks']['track'][0]['url']).to eq('http://www.last.fm/music/Cher/_/Believe')
|
114
114
|
end
|
115
115
|
|
116
116
|
it 'should get info by mbid' do
|
117
|
-
@lastfm.
|
117
|
+
expect(@lastfm).to receive(:request).with('album.getInfo', {
|
118
118
|
:mbid => 'xxxxx'
|
119
119
|
}).and_return(make_response('album_get_info'))
|
120
120
|
|
121
121
|
album = @lastfm.album.get_info(:mbid => 'xxxxx')
|
122
|
-
album['name'].
|
123
|
-
album['artist'].
|
124
|
-
album['id'].
|
125
|
-
album['mbid'].
|
126
|
-
album['url'].
|
127
|
-
album['image'].size.
|
128
|
-
album['releasedate'].
|
129
|
-
album['tracks']['track'].size.
|
130
|
-
album['tracks']['track'][0]['name'].
|
131
|
-
album['tracks']['track'][0]['duration'].
|
132
|
-
album['tracks']['track'][0]['url'].
|
122
|
+
expect(album['name']).to eq('Believe')
|
123
|
+
expect(album['artist']).to eq('Cher')
|
124
|
+
expect(album['id']).to eq('2026126')
|
125
|
+
expect(album['mbid']).to eq('61bf0388-b8a9-48f4-81d1-7eb02706dfb0')
|
126
|
+
expect(album['url']).to eq('http://www.last.fm/music/Cher/Believe')
|
127
|
+
expect(album['image'].size).to eq(5)
|
128
|
+
expect(album['releasedate']).to eq('6 Apr 1999, 00:00')
|
129
|
+
expect(album['tracks']['track'].size).to eq(10)
|
130
|
+
expect(album['tracks']['track'][0]['name']).to eq('Believe')
|
131
|
+
expect(album['tracks']['track'][0]['duration']).to eq('239')
|
132
|
+
expect(album['tracks']['track'][0]['url']).to eq('http://www.last.fm/music/Cher/_/Believe')
|
133
133
|
end
|
134
134
|
|
135
135
|
it 'works without release date' do
|
136
|
-
@lastfm.
|
136
|
+
expect(@lastfm).to receive(:request).with('album.getInfo', {
|
137
137
|
:mbid => 'xxxxx'
|
138
138
|
}).and_return(make_response('album_get_info_without_release_date'))
|
139
139
|
|
140
140
|
album = @lastfm.album.get_info(:mbid => 'xxxxx')
|
141
|
-
album['name'].
|
141
|
+
expect(album['name']).to eq('Believe')
|
142
142
|
end
|
143
143
|
end
|
144
144
|
|
145
145
|
describe '#get_shouts' do
|
146
146
|
it 'should get shouts' do
|
147
|
-
@lastfm.
|
147
|
+
expect(@lastfm).to receive(:request).with('album.getShouts', {
|
148
148
|
:artist => 'Cher',
|
149
149
|
:album => 'Believe',
|
150
150
|
:autocorrect => nil,
|
@@ -155,16 +155,16 @@ describe '#album' do
|
|
155
155
|
shouts = @lastfm.album.get_shouts(
|
156
156
|
:artist => 'Cher',
|
157
157
|
:album => 'Believe')
|
158
|
-
shouts.size.
|
159
|
-
shouts[0]['body'].
|
160
|
-
shouts[0]['author'].
|
161
|
-
shouts[0]['date'].
|
158
|
+
expect(shouts.size).to eq(2)
|
159
|
+
expect(shouts[0]['body']).to eq('A perfect Pop/Dance Masterpiece')
|
160
|
+
expect(shouts[0]['author']).to eq('top20fanatico')
|
161
|
+
expect(shouts[0]['date']).to eq('Wed, 7 Jan 2015 12:45:35')
|
162
162
|
end
|
163
163
|
end
|
164
164
|
|
165
165
|
describe '#get_tags' do
|
166
166
|
it 'should get tags' do
|
167
|
-
@lastfm.
|
167
|
+
expect(@lastfm).to receive(:request).with('album.getTags', {
|
168
168
|
:artist => 'Cher',
|
169
169
|
:album => 'Believe',
|
170
170
|
:autocorrect => nil
|
@@ -173,15 +173,15 @@ describe '#album' do
|
|
173
173
|
tags = @lastfm.album.get_tags(
|
174
174
|
:artist => 'Cher',
|
175
175
|
:album => 'Believe')
|
176
|
-
tags.size.
|
177
|
-
tags[0]['name'].
|
178
|
-
tags[0]['url'].
|
176
|
+
expect(tags.size).to eq(2)
|
177
|
+
expect(tags[0]['name']).to eq('sourabh')
|
178
|
+
expect(tags[0]['url']).to eq('http://www.last.fm/tag/sourabh')
|
179
179
|
end
|
180
180
|
end
|
181
181
|
|
182
182
|
describe '#get_top_tags' do
|
183
183
|
it 'should get top tags' do
|
184
|
-
@lastfm.
|
184
|
+
expect(@lastfm).to receive(:request).with('album.getTopTags', {
|
185
185
|
:artist => 'Radiohead',
|
186
186
|
:album => 'The Bends',
|
187
187
|
:autocorrect => nil
|
@@ -190,31 +190,31 @@ describe '#album' do
|
|
190
190
|
tags = @lastfm.album.get_top_tags(
|
191
191
|
:artist => 'Radiohead',
|
192
192
|
:album => 'The Bends')
|
193
|
-
tags.size.
|
194
|
-
tags[0]['name'].
|
195
|
-
tags[0]['count'].
|
196
|
-
tags[0]['url'].
|
193
|
+
expect(tags.size).to eq(2)
|
194
|
+
expect(tags[0]['name']).to eq('albums I own')
|
195
|
+
expect(tags[0]['count']).to eq('100')
|
196
|
+
expect(tags[0]['url']).to eq('http://www.last.fm/tag/albums%20i%20own')
|
197
197
|
end
|
198
198
|
end
|
199
199
|
|
200
200
|
describe '#remove_tag' do
|
201
201
|
it 'should remove tag' do
|
202
|
-
@lastfm.
|
202
|
+
expect(@lastfm).to receive(:request).with('album.removeTag', {
|
203
203
|
:artist => 'foo artist',
|
204
204
|
:album => 'foo track',
|
205
205
|
:tag => 'aaa'
|
206
206
|
}, :post, true, true).and_return(@ok_response)
|
207
207
|
|
208
|
-
@lastfm.album.remove_tag(
|
208
|
+
expect(@lastfm.album.remove_tag(
|
209
209
|
:artist => 'foo artist',
|
210
210
|
:album => 'foo track',
|
211
|
-
:tag => 'aaa').
|
211
|
+
:tag => 'aaa')).to be_truthy
|
212
212
|
end
|
213
213
|
end
|
214
214
|
|
215
215
|
describe '#search' do
|
216
216
|
it 'should search' do
|
217
|
-
@lastfm.
|
217
|
+
expect(@lastfm).to receive(:request).with('album.search', {
|
218
218
|
:album => 'Believe',
|
219
219
|
:limit => nil,
|
220
220
|
:page => nil,
|
@@ -222,14 +222,14 @@ describe '#album' do
|
|
222
222
|
|
223
223
|
albums = @lastfm.album.search(:album => 'Believe')
|
224
224
|
|
225
|
-
albums['results']['for'].
|
226
|
-
albums['results']['totalResults'].
|
227
|
-
albums['results']['albummatches']['album'].size.
|
228
|
-
albums['results']['albummatches']['album'][0]['name'].
|
225
|
+
expect(albums['results']['for']).to eq('Believe')
|
226
|
+
expect(albums['results']['totalResults']).to eq('3926')
|
227
|
+
expect(albums['results']['albummatches']['album'].size).to eq(2)
|
228
|
+
expect(albums['results']['albummatches']['album'][0]['name']).to eq('Believe')
|
229
229
|
end
|
230
230
|
|
231
231
|
it 'should always return an array of albums' do
|
232
|
-
@lastfm.
|
232
|
+
expect(@lastfm).to receive(:request).with('album.search', {
|
233
233
|
:album => 'Believe',
|
234
234
|
:limit => nil,
|
235
235
|
:page => nil,
|
@@ -237,14 +237,14 @@ describe '#album' do
|
|
237
237
|
|
238
238
|
albums = @lastfm.album.search(:album => 'Believe')
|
239
239
|
|
240
|
-
albums['results']['for'].
|
241
|
-
albums['results']['totalResults'].
|
242
|
-
albums['results']['albummatches']['album'].size.
|
243
|
-
albums['results']['albummatches']['album'][0]['name'].
|
240
|
+
expect(albums['results']['for']).to eq('Believe')
|
241
|
+
expect(albums['results']['totalResults']).to eq('3926')
|
242
|
+
expect(albums['results']['albummatches']['album'].size).to eq(1)
|
243
|
+
expect(albums['results']['albummatches']['album'][0]['name']).to eq('Believe')
|
244
244
|
end
|
245
245
|
|
246
246
|
it 'should return an empty array if no match found' do
|
247
|
-
@lastfm.
|
247
|
+
expect(@lastfm).to receive(:request).with('album.search', {
|
248
248
|
:album => 'Believe',
|
249
249
|
:limit => nil,
|
250
250
|
:page => nil,
|
@@ -252,15 +252,15 @@ describe '#album' do
|
|
252
252
|
|
253
253
|
albums = @lastfm.album.search(:album => 'Believe')
|
254
254
|
|
255
|
-
albums['results']['for'].
|
256
|
-
albums['results']['totalResults'].
|
257
|
-
albums['results']['albummatches']['album'].size.
|
255
|
+
expect(albums['results']['for']).to eq('Believe')
|
256
|
+
expect(albums['results']['totalResults']).to eq('0')
|
257
|
+
expect(albums['results']['albummatches']['album'].size).to eq(0)
|
258
258
|
end
|
259
259
|
end
|
260
260
|
|
261
261
|
describe '#share' do
|
262
262
|
it 'should share' do
|
263
|
-
@lastfm.
|
263
|
+
expect(@lastfm).to receive(:request).with('album.share', {
|
264
264
|
:artist => 'bar artist',
|
265
265
|
:album => 'bar album',
|
266
266
|
:recipient => 'bar@example.com',
|
@@ -268,12 +268,12 @@ describe '#album' do
|
|
268
268
|
:public => nil,
|
269
269
|
}, :post, true, true).and_return(@ok_response)
|
270
270
|
|
271
|
-
@lastfm.album.share(
|
271
|
+
expect(@lastfm.album.share(
|
272
272
|
:artist => 'bar artist',
|
273
273
|
:album => 'bar album',
|
274
274
|
:recipient => 'bar@example.com',
|
275
275
|
:message => 'this is a message',
|
276
|
-
).
|
276
|
+
)).to be_truthy
|
277
277
|
end
|
278
278
|
end
|
279
279
|
end
|