rspotify 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 36f4e80d9142dc5193f056b22e94e8ff632e4a81
4
- data.tar.gz: 87dc03fabf423e54e67a781c4bfa2850a302f649
3
+ metadata.gz: 925839b54c713a9ec76dcabd826b96a2b05e8a5a
4
+ data.tar.gz: 69d15be0e45516a0512a9f69a55bde3455c547e9
5
5
  SHA512:
6
- metadata.gz: 7edc724a34dbfa0fba08048b6b968b0db3ec37f98bd5f2cb6f61967d0d63e1e284e49a451d1051aa94bd9f5c8611c689cb55a00e78299649fa24de47ff018d50
7
- data.tar.gz: 5c1ec4d1fcd29fcfcd49edc17908a290f211392d4ad11db8c6484f91489b7b3ad750e1d6c27ee1c2f513383f6ba2abb0cc1daafbf4274826d6cf76d873f9b231
6
+ metadata.gz: d69cee2e26d3c4e58682399d9ef585462c01d588554094effbdc88d44a12abea321b61026de7243b47958e06188eefb41ddb0d548961164838640d9d3ebf3c46
7
+ data.tar.gz: ced2a7e6a1cabf0c94718cc438a4ea8b30b0c552d6270b8a031abf69cb0095af6635568a9252bef757cb12114f66e613902cbf575ea86d67c53ad564e9d877d6
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --color
2
+ --warnings
3
+ --require spec_helper
@@ -26,7 +26,7 @@ module RSpotify
26
26
  @owner = User.new options['owner']
27
27
  end
28
28
 
29
- if options['tracks']
29
+ if options['tracks'] && options['tracks']['items']
30
30
  tracks = options['tracks']['items']
31
31
  @tracks = tracks.map { |t| Track.new t['track'] }
32
32
  end
@@ -1,3 +1,3 @@
1
1
  module RSpotify
2
- VERSION = '0.3.0'
2
+ VERSION = '0.3.1'
3
3
  end
@@ -0,0 +1,53 @@
1
+ describe RSpotify::Album do
2
+
3
+ describe 'Album#find' do
4
+
5
+ before(:each) do
6
+ # Get Arctic Monkeys's AM album as a testing sample
7
+ @album = RSpotify::Album.find('5bU1XKYxHhEwukllT20xtk')
8
+ end
9
+
10
+ it 'should find album with correct attributes' do
11
+ expect(@album.album_type) .to eq 'album'
12
+ expect(@album.available_markets) .to include *%w(AD AT BE BG CA EE ES FR GR MC TW US)
13
+ expect(@album.external_ids['upc']) .to eq '887828031795'
14
+ expect(@album.external_urls['spotify']) .to eq 'https://open.spotify.com/album/5bU1XKYxHhEwukllT20xtk'
15
+ expect(@album.genres) .to include 'Indie'
16
+ expect(@album.href) .to eq 'https://api.spotify.com/v1/albums/5bU1XKYxHhEwukllT20xtk'
17
+ expect(@album.id) .to eq '5bU1XKYxHhEwukllT20xtk'
18
+ expect(@album.images) .to include ({'height' => 640, 'width' => 640, 'url' => 'https://i.scdn.co/image/4d9ec146e3a257b10634d9a413ef6cc3de325008'})
19
+ expect(@album.name) .to eq 'AM'
20
+ expect(@album.popularity) .to be > 0
21
+ expect(@album.release_date) .to eq '2013-09-09'
22
+ expect(@album.release_date_precision) .to eq 'day'
23
+ expect(@album.type) .to eq 'album'
24
+ expect(@album.uri) .to eq 'spotify:album:5bU1XKYxHhEwukllT20xtk'
25
+ end
26
+
27
+ it 'should find album with correct artists' do
28
+ artists = @album.artists
29
+ expect(artists) .to be_an Array
30
+ expect(artists.size) .to eq 1
31
+ expect(artists.first) .to be_an RSpotify::Artist
32
+ expect(artists.map(&:name)) .to include('Arctic Monkeys')
33
+ end
34
+
35
+ it 'should find album with correct tracks' do
36
+ tracks = @album.tracks
37
+ expect(tracks) .to be_an Array
38
+ expect(tracks.size) .to eq 12
39
+ expect(tracks.first) .to be_an RSpotify::Track
40
+ expect(tracks.map(&:name)) .to include('Do I Wanna Know?', 'R U Mine?', 'Arabella', 'Fireside')
41
+ end
42
+ end
43
+
44
+ describe 'Album#search' do
45
+ it 'should search for the right albums' do
46
+ albums = RSpotify::Album.search('AM')
47
+ expect(albums) .to be_an Array
48
+ expect(albums.size) .to eq 20
49
+ expect(albums.first) .to be_an RSpotify::Album
50
+ expect(albums.map(&:name)) .to include('AM', 'Am I Wrong', 'A.M.', 'Melody AM')
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,31 @@
1
+ describe RSpotify::Artist do
2
+
3
+ describe 'Artist#find' do
4
+ before(:each) do
5
+ # Get Arctic Monkeys as a testing sample
6
+ @artist = RSpotify::Artist.find('7Ln80lUS6He07XvHI8qqHH')
7
+ end
8
+
9
+ it 'should find artist with correct attributes' do
10
+ expect(@artist.external_urls['spotify']) .to eq 'https://open.spotify.com/artist/7Ln80lUS6He07XvHI8qqHH'
11
+ expect(@artist.genres) .to include 'Alternative Pop/Rock', 'Alternative/Indie Rock', 'Indie', 'Indie Rock', 'Pop/Rock'
12
+ expect(@artist.href) .to eq 'https://api.spotify.com/v1/artists/7Ln80lUS6He07XvHI8qqHH'
13
+ expect(@artist.id) .to eq '7Ln80lUS6He07XvHI8qqHH'
14
+ expect(@artist.images) .to include ({'height' => 1333, 'width' => 1000, 'url' => 'https://i.scdn.co/image/fa2e9ca1a27695ae7f8013350d9a53e11d523ece'})
15
+ expect(@artist.name) .to eq 'Arctic Monkeys'
16
+ expect(@artist.popularity) .to be > 0
17
+ expect(@artist.type) .to eq 'artist'
18
+ expect(@artist.uri) .to eq 'spotify:artist:7Ln80lUS6He07XvHI8qqHH'
19
+ end
20
+ end
21
+
22
+ describe 'Artist#search' do
23
+ it 'should search for the right artists' do
24
+ artists = RSpotify::Artist.search('Arctic')
25
+ expect(artists) .to be_an Array
26
+ expect(artists.size) .to eq 20
27
+ expect(artists.first) .to be_an RSpotify::Artist
28
+ expect(artists.map(&:name)) .to include('Arctic Monkeys', 'Arctic Moon', 'Arctic', 'Arctic Quest')
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,43 @@
1
+ describe RSpotify::Playlist do
2
+
3
+ describe 'Playlist#find' do
4
+
5
+ before(:each) do
6
+ # Keys generated specifically for the tests. Should be removed in the future
7
+ client_id = '5ac1cda2ad354aeaa1ad2693d33bb98c'
8
+ client_secret = '155fc038a85840679b55a1822ef36b9b'
9
+ RSpotify.authenticate(client_id, client_secret)
10
+
11
+ # Get wizzler's "Movie Soundtrack Masterpieces" playlist as a testing sample
12
+ @playlist = RSpotify::Playlist.find('wizzler', '00wHcTN0zQiun4xri9pmvX')
13
+ end
14
+
15
+ it 'should find playlist with correct attributes' do
16
+ expect(@playlist.collaborative) .to eq false
17
+ expect(@playlist.external_urls['spotify']) .to eq 'http://open.spotify.com/user/wizzler/playlist/00wHcTN0zQiun4xri9pmvX'
18
+ expect(@playlist.description) .to match /Iconic soundtracks featured in some of the greatest movies/
19
+ expect(@playlist.followers['total']) .to eq 12
20
+ expect(@playlist.href) .to eq 'https://api.spotify.com/v1/users/wizzler/playlists/00wHcTN0zQiun4xri9pmvX'
21
+ expect(@playlist.id) .to eq '00wHcTN0zQiun4xri9pmvX'
22
+ expect(@playlist.images.first['url']) .to match %r{https://dv72vokf4bztv\.cloudfront}
23
+ expect(@playlist.name) .to eq 'Movie Soundtrack Masterpieces'
24
+ expect(@playlist.public) .to eq true
25
+ expect(@playlist.type) .to eq 'playlist'
26
+ expect(@playlist.uri) .to eq 'spotify:user:wizzler:playlist:00wHcTN0zQiun4xri9pmvX'
27
+ end
28
+
29
+ it 'should find playlist with correct owner' do
30
+ owner = @playlist.owner
31
+ expect(owner) .to be_an RSpotify::User
32
+ expect(owner.id) .to eq 'wizzler'
33
+ end
34
+
35
+ it 'should find playlist with correct tracks' do
36
+ tracks = @playlist.tracks
37
+ expect(tracks) .to be_an Array
38
+ expect(tracks.size) .to eq 50
39
+ expect(tracks.first) .to be_an RSpotify::Track
40
+ expect(tracks.map(&:name)) .to include('Waking Up', 'Honor Him', 'Circle of Life', 'Time')
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,52 @@
1
+ describe RSpotify::Track do
2
+
3
+ describe 'Track#find' do
4
+
5
+ before(:each) do
6
+ # Get Arctic Monkeys's "Do I Wanna Know?" track as a testing sample
7
+ @track = RSpotify::Track.find('3jfr0TF6DQcOLat8gGn7E2')
8
+ end
9
+
10
+ it 'should find track with correct attributes' do
11
+ expect(@track.available_markets) .to include *%w(AD AT BE BG CA EE ES FR GR MC TW US)
12
+ expect(@track.disc_number) .to eq 1
13
+ expect(@track.duration_ms) .to eq 272394
14
+ expect(@track.explicit) .to eq false
15
+ expect(@track.external_ids['isrc']) .to eq 'GBCEL1300362'
16
+ expect(@track.external_urls['spotify']) .to eq 'https://open.spotify.com/track/3jfr0TF6DQcOLat8gGn7E2'
17
+ expect(@track.href) .to eq 'https://api.spotify.com/v1/tracks/3jfr0TF6DQcOLat8gGn7E2'
18
+ expect(@track.id) .to eq '3jfr0TF6DQcOLat8gGn7E2'
19
+ expect(@track.name) .to eq 'Do I Wanna Know?'
20
+ expect(@track.popularity) .to be > 0
21
+ expect(@track.preview_url) .to eq 'https://p.scdn.co/mp3-preview/c181f36e2fe0fb41885cb83a8fe9f76480952701'
22
+ expect(@track.track_number) .to eq 1
23
+ expect(@track.type) .to eq 'track'
24
+ expect(@track.uri) .to eq 'spotify:track:3jfr0TF6DQcOLat8gGn7E2'
25
+ end
26
+
27
+ it 'should find track with correct album' do
28
+ album = @track.album
29
+ expect(album) .to be_an RSpotify::Album
30
+ expect(album.id) .to eq '5bU1XKYxHhEwukllT20xtk'
31
+ expect(album.name) .to eq 'AM'
32
+ end
33
+
34
+ it 'should find track with correct artists' do
35
+ artists = @track.artists
36
+ expect(artists) .to be_an Array
37
+ expect(artists.size) .to eq 1
38
+ expect(artists.first) .to be_an RSpotify::Artist
39
+ expect(artists.map(&:name)) .to include('Arctic Monkeys')
40
+ end
41
+ end
42
+
43
+ describe 'Track#search' do
44
+ it 'should search for the right tracks' do
45
+ tracks = RSpotify::Track.search('Wanna Know')
46
+ expect(tracks) .to be_an Array
47
+ expect(tracks.size) .to eq 20
48
+ expect(tracks.first) .to be_an RSpotify::Track
49
+ expect(tracks.map(&:name)) .to include('Do I Wanna Know?', 'Wanna Know', 'Never Wanna Know')
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,31 @@
1
+ describe RSpotify::User do
2
+
3
+ describe 'User#find' do
4
+
5
+ before(:each) do
6
+ # Get wizzler user as a testing sample
7
+ @user = RSpotify::User.find('wizzler')
8
+ end
9
+
10
+ it 'should find user with correct attributes' do
11
+ expect(@user.external_urls['spotify']) .to eq 'https://open.spotify.com/user/wizzler'
12
+ expect(@user.href) .to eq 'https://api.spotify.com/v1/users/wizzler'
13
+ expect(@user.id) .to eq 'wizzler'
14
+ expect(@user.type) .to eq 'user'
15
+ expect(@user.uri) .to eq 'spotify:user:wizzler'
16
+ end
17
+
18
+ it 'should find user with correct playlists' do
19
+ # Keys generated specifically for the tests. Should be removed in the future
20
+ client_id = '5ac1cda2ad354aeaa1ad2693d33bb98c'
21
+ client_secret = '155fc038a85840679b55a1822ef36b9b'
22
+ RSpotify.authenticate(client_id, client_secret)
23
+
24
+ playlists = @user.playlists
25
+ expect(playlists) .to be_an Array
26
+ expect(playlists.size) .to eq 7
27
+ expect(playlists.first) .to be_an RSpotify::Playlist
28
+ expect(playlists.map(&:name)) .to include('Movie Soundtrack Masterpieces', 'Blue Mountain State', 'Starred')
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,2 @@
1
+ describe RSpotify do
2
+ end
@@ -0,0 +1,27 @@
1
+ require 'rspotify'
2
+
3
+ RSpec.configure do |config|
4
+
5
+ config.filter_run :focus
6
+ config.run_all_when_everything_filtered = true
7
+
8
+ if config.files_to_run.one?
9
+ config.default_formatter = 'doc'
10
+ end
11
+
12
+ config.profile_examples = 10
13
+
14
+ config.order = :random
15
+
16
+ Kernel.srand config.seed
17
+
18
+ config.expect_with :rspec do |expectations|
19
+ expectations.syntax = :expect
20
+ end
21
+
22
+ config.mock_with :rspec do |mocks|
23
+ mocks.syntax = :expect
24
+
25
+ mocks.verify_partial_doubles = true
26
+ end
27
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspotify
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Guilherme Sad
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-20 00:00:00.000000000 Z
11
+ date: 2014-06-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest_client
@@ -88,6 +88,7 @@ extensions: []
88
88
  extra_rdoc_files: []
89
89
  files:
90
90
  - ".gitignore"
91
+ - ".rspec"
91
92
  - Gemfile
92
93
  - LICENSE.txt
93
94
  - README.md
@@ -102,7 +103,13 @@ files:
102
103
  - lib/rspotify/user.rb
103
104
  - lib/rspotify/version.rb
104
105
  - rspotify.gemspec
105
- - spec/TODO
106
+ - spec/lib/rspotify/album_spec.rb
107
+ - spec/lib/rspotify/artist_spec.rb
108
+ - spec/lib/rspotify/playlist_spec.rb
109
+ - spec/lib/rspotify/track_spec.rb
110
+ - spec/lib/rspotify/user_spec.rb
111
+ - spec/lib/rspotify_spec.rb
112
+ - spec/spec_helper.rb
106
113
  homepage: http://rubygems.org/gems/rspotify
107
114
  licenses:
108
115
  - MIT
@@ -128,4 +135,10 @@ signing_key:
128
135
  specification_version: 4
129
136
  summary: A ruby wrapper for the Spotify Web API
130
137
  test_files:
131
- - spec/TODO
138
+ - spec/lib/rspotify/album_spec.rb
139
+ - spec/lib/rspotify/artist_spec.rb
140
+ - spec/lib/rspotify/playlist_spec.rb
141
+ - spec/lib/rspotify/track_spec.rb
142
+ - spec/lib/rspotify/user_spec.rb
143
+ - spec/lib/rspotify_spec.rb
144
+ - spec/spec_helper.rb
data/spec/TODO DELETED
File without changes