spotifiery 0.0.1

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.
@@ -0,0 +1,55 @@
1
+ describe 'Spotifiery::SearchResult::Base' do
2
+
3
+ describe "on initialize from a mock" do
4
+
5
+ before (:each) do
6
+ @spotify_json = {
7
+ :info => {:num_results => 110, :limit => 100, :offset => 200, :query => "foo", :type => "album", :page => 3},
8
+ :albums => []
9
+ }
10
+ @spotifiery_search_result = Spotifiery::SearchResult::Base.new(@spotify_json)
11
+ end
12
+
13
+ it "should accept a valid spotify json string" do
14
+ @spotifiery_search_result.should_not be_nil
15
+ end
16
+
17
+ it "should respond to spotify search results" do
18
+ @spotifiery_search_result.should respond_to(:num_results, :limit, :offset, :query, :type, :page)
19
+ end
20
+
21
+ it "should have album as type" do
22
+ @spotifiery_search_result.type.should eql 'album'
23
+ end
24
+
25
+ end
26
+
27
+ describe "on initialize from a real spotify response" do
28
+
29
+ before (:each) do
30
+ VCR.insert_cassette 'with_or_without_you', :record => :new_episodes
31
+ spotify_response = HTTParty.get("http://ws.spotify.com/search/1/track.json", :query => {:q => "With or Without You", :page => '1'})
32
+ parsed_response = JSON.parse(spotify_response.body, :symbolize_names => true)
33
+ @spotifiery_search_result = Spotifiery::SearchResult::Base.new parsed_response
34
+ end
35
+
36
+ after do
37
+ VCR.eject_cassette
38
+ end
39
+
40
+ it "should have track as type" do
41
+ @spotifiery_search_result.type.should eql 'track'
42
+ end
43
+
44
+ it "should respond to tracks and results" do
45
+ @spotifiery_search_result.should respond_to(:tracks, :results)
46
+ end
47
+
48
+ it "each item in results should be a track" do
49
+ @spotifiery_search_result.tracks.first.should be_a_kind_of(Spotifiery::Searchable::Track)
50
+ @spotifiery_search_result.tracks.last.should be_a_kind_of(Spotifiery::Searchable::Track)
51
+ end
52
+
53
+ end
54
+
55
+ end
@@ -0,0 +1,2 @@
1
+ describe 'Spotifiery::SearchResult' do
2
+ end
@@ -0,0 +1,86 @@
1
+ require_relative '../../../spec_helper'
2
+
3
+ describe Spotifiery::Searchable::Album do
4
+
5
+ describe "default attributes and methods" do
6
+
7
+ it "should have a base uri to search albums" do
8
+ Spotifiery::Searchable::Album.base_uri.should eql("http://ws.spotify.com/search/1")
9
+ end
10
+
11
+ it "should define base query extra option" do
12
+ Spotifiery::Searchable::Album::QUERY_EXTRA_DEFAULT.should eql "trackdetail"
13
+ end
14
+
15
+ end
16
+
17
+ describe "looking for albums" do
18
+
19
+ before (:each) do
20
+ VCR.insert_cassette 'album_find', :record => :new_episodes
21
+ @result = Spotifiery::Searchable::Album.find(:q => "Greatest Hits" )
22
+ end
23
+
24
+ after do
25
+ VCR.eject_cassette
26
+ end
27
+
28
+ it "it should return a SearchResult::Base object" do
29
+ @result.should be_a_kind_of(Spotifiery::SearchResult::Base)
30
+ end
31
+
32
+ it "should return Albums as results" do
33
+ @result.results.first.should be_a_kind_of(Spotifiery::Searchable::Album)
34
+ end
35
+
36
+ end
37
+
38
+ describe "a concrete artist by uri" do
39
+ before (:each) do
40
+ VCR.insert_cassette 'album_lookup_by_uri', :record => :new_episodes
41
+ @spotifiery_album = Spotifiery::Searchable::Album.new("spotify:album:6G9fHYDCoyEErUkHrFYfs4")
42
+ end
43
+
44
+ after do
45
+ VCR.eject_cassette
46
+ end
47
+
48
+ it "should respond to base attributes" do
49
+ @spotifiery_album.should respond_to(:name, :released, :href)
50
+ end
51
+
52
+ it "should have 'Remedy' as name" do
53
+ @spotifiery_album.name.should eql 'Remedy'
54
+ end
55
+
56
+ it "should have 1999 as track-number" do
57
+ @spotifiery_album.released.should eql 1999
58
+ end
59
+
60
+
61
+ it "should respond to artist" do
62
+ @spotifiery_album.should respond_to :artists
63
+ end
64
+
65
+ it "should respond to tracks" do
66
+ @spotifiery_album.should respond_to :tracks
67
+ end
68
+
69
+ it "should have an Artist as astist" do
70
+ @spotifiery_album.artists.first.should be_a_kind_of Spotifiery::Searchable::Artist
71
+ @spotifiery_album.artists.last.should be_a_kind_of Spotifiery::Searchable::Artist
72
+ end
73
+
74
+ it "should have an array of Tracks as tracks" do
75
+ @spotifiery_album.tracks.first.should be_a_kind_of Spotifiery::Searchable::Track
76
+ @spotifiery_album.tracks.last.should be_a_kind_of Spotifiery::Searchable::Track
77
+ end
78
+
79
+ it "should have Basement Jaxx as artist name" do
80
+ @spotifiery_album.artists.first.name.should eql "Basement Jaxx"
81
+ end
82
+
83
+ end
84
+
85
+
86
+ end
@@ -0,0 +1,68 @@
1
+ require_relative '../../../spec_helper'
2
+
3
+ describe Spotifiery::Searchable::Artist do
4
+
5
+ describe "default attributes and methods" do
6
+
7
+ it "should have a base uri to search artists" do
8
+ Spotifiery::Searchable::Track.base_uri.should eql("http://ws.spotify.com/search/1")
9
+ end
10
+
11
+ it "should define base query extra option" do
12
+ Spotifiery::Searchable::Artist::QUERY_EXTRA_DEFAULT.should eql "albumdetail"
13
+ end
14
+
15
+ end
16
+
17
+ describe "looking for artists" do
18
+
19
+ before (:each) do
20
+ VCR.insert_cassette 'artist_find', :record => :new_episodes
21
+ @result = Spotifiery::Searchable::Artist.find(:q => "Foo Fighters" )
22
+ end
23
+
24
+ after do
25
+ VCR.eject_cassette
26
+ end
27
+
28
+ it "it should return a SearchResult::Base object" do
29
+ @result.should be_a_kind_of(Spotifiery::SearchResult::Base)
30
+ end
31
+
32
+ it "should return Artists as results" do
33
+ @result.results.first.should be_a_kind_of(Spotifiery::Searchable::Artist)
34
+ end
35
+
36
+ end
37
+
38
+ describe "a concrete track by uri" do
39
+ before (:each) do
40
+ VCR.insert_cassette 'track_lookup_by_uri', :record => :new_episodes
41
+ @spotifiery_artist = Spotifiery::Searchable::Artist.new("spotify:artist:4YrKBkKSVeqDamzBPWVnSJ")
42
+ end
43
+
44
+ after do
45
+ VCR.eject_cassette
46
+ end
47
+
48
+ it "should respond to base attributes" do
49
+ @spotifiery_artist.should respond_to(:name, :href)
50
+ end
51
+
52
+ it "should have 'Basement Jaxx' as name" do
53
+ @spotifiery_artist.name.should eql 'Basement Jaxx'
54
+ end
55
+
56
+ it "should respond to albums" do
57
+ @spotifiery_artist.should respond_to :albums
58
+ end
59
+
60
+ it "should have an array of Albums as albums" do
61
+ @spotifiery_artist.albums.first.should be_a_kind_of Spotifiery::Searchable::Album
62
+ @spotifiery_artist.albums.last.should be_a_kind_of Spotifiery::Searchable::Album
63
+ end
64
+
65
+ end
66
+
67
+
68
+ end
@@ -0,0 +1,41 @@
1
+ require_relative '../../../spec_helper'
2
+
3
+ describe Spotifiery::Searchable::Base do
4
+
5
+ describe "default attributes and methods" do
6
+
7
+ it "should define base api search url" do
8
+ Spotifiery::Searchable::Base::BASE_SEARCH_URL.should eql("http://ws.spotify.com/search/1/")
9
+ end
10
+
11
+ it "should define base api lookup url" do
12
+ Spotifiery::Searchable::Base::BASE_LOOKUP_URL.should eql("http://ws.spotify.com/lookup/1/.json")
13
+ end
14
+
15
+ end
16
+
17
+ describe "modules including it" do
18
+
19
+ before do
20
+ # Not sure if this is an aberration...
21
+ class SearchableTestClass
22
+ include Spotifiery::Searchable::Base
23
+ end
24
+ end
25
+
26
+ it "should define the find static method" do
27
+ SearchableTestClass.should respond_to(:find)
28
+ end
29
+
30
+ it "should raise exception if find called" do
31
+ lambda { SearchableTestClass.find(:q => "something") }.should raise_error
32
+ end
33
+
34
+ it "should include httparty methods" do
35
+ SearchableTestClass.should include(HTTParty)
36
+ end
37
+
38
+ end
39
+
40
+
41
+ end
@@ -0,0 +1,92 @@
1
+ require_relative '../../../spec_helper'
2
+
3
+ describe Spotifiery::Searchable::Track do
4
+
5
+ describe "default attributes and methods" do
6
+
7
+ it "should have a base uri to search tracks" do
8
+ Spotifiery::Searchable::Track.base_uri.should eql("http://ws.spotify.com/search/1")
9
+ end
10
+
11
+ it "should not define base query extra option" do
12
+ Spotifiery::Searchable::Track::QUERY_EXTRA_DEFAULT.should be_nil
13
+ end
14
+
15
+ end
16
+
17
+ describe "looking for tracks" do
18
+
19
+ before (:each) do
20
+ VCR.insert_cassette 'track_find', :record => :new_episodes
21
+ @result = Spotifiery::Searchable::Track.find(:q => "Foo Fighters" )
22
+ end
23
+
24
+ after do
25
+ VCR.eject_cassette
26
+ end
27
+
28
+ it "it should return a SearchResult::Base object" do
29
+ @result.should be_a_kind_of(Spotifiery::SearchResult::Base)
30
+ end
31
+
32
+ it "should return a Tracks as results" do
33
+ @result.results.first.should be_a_kind_of(Spotifiery::Searchable::Track)
34
+ end
35
+
36
+ end
37
+
38
+ describe "a concrete track by uri" do
39
+ before (:each) do
40
+ VCR.insert_cassette 'track_lookup_by_uri', :record => :new_episodes
41
+ @spotifiery_track = Spotifiery::Searchable::Track.new("spotify:track:07q6QTQXyPRCf7GbLakRPr")
42
+ end
43
+
44
+ after do
45
+ VCR.eject_cassette
46
+ end
47
+
48
+ it "should respond to base attributes" do
49
+ @spotifiery_track.should respond_to(:name, :popularity, :length, :href, :track_number)
50
+ end
51
+
52
+ it "should have 'Everlong' as name" do
53
+ @spotifiery_track.name.should eql 'Everlong'
54
+ end
55
+
56
+ it "should have 3 as track-number" do
57
+ @spotifiery_track.track_number.should eql 3
58
+ end
59
+
60
+ it "should have a length of 250.259" do
61
+ @spotifiery_track.length.should eql 250.259
62
+ end
63
+
64
+ it "should respond to artist" do
65
+ @spotifiery_track.should respond_to :artists
66
+ end
67
+
68
+ it "should respond to album" do
69
+ @spotifiery_track.should respond_to :album
70
+ end
71
+
72
+ it "should have an array of Artist as astist" do
73
+ @spotifiery_track.artists.first.should be_a_kind_of Spotifiery::Searchable::Artist
74
+ @spotifiery_track.artists.last.should be_a_kind_of Spotifiery::Searchable::Artist
75
+ end
76
+
77
+ it "should have an Album as album" do
78
+ @spotifiery_track.album.should be_a_kind_of Spotifiery::Searchable::Album
79
+ end
80
+
81
+ it "should have Foo Fighters as artist name" do
82
+ @spotifiery_track.artists.first.name.should eql "Foo Fighters"
83
+ end
84
+
85
+ it "should have Greatest Hits as album name" do
86
+ @spotifiery_track.album.name.should eql "Greatest Hits"
87
+ end
88
+
89
+ end
90
+
91
+
92
+ end
@@ -0,0 +1,2 @@
1
+ describe 'Spotifiery::Searchable' do
2
+ end
@@ -0,0 +1,2 @@
1
+ describe 'Spotifiery' do
2
+ end
@@ -0,0 +1,11 @@
1
+ # encoding: utf-8
2
+
3
+ require 'webmock/rspec'
4
+ require 'vcr'
5
+
6
+ require_relative '../lib/spotifiery'
7
+
8
+ VCR.configure do |config|
9
+ config.cassette_library_dir = 'spec/fixtures/vcr_cassettes'
10
+ config.hook_into :webmock
11
+ end
@@ -0,0 +1,26 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/spotifiery/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["cicloon"]
6
+ gem.email = ["aleon.prof@gmail.com"]
7
+ gem.description = %q{Spotify Web API wrapper}
8
+ gem.summary = %q{This gem provides an API wrapper for the spotify Web search API}
9
+ gem.homepage = "https://github.com/cicloon/spotifiery"
10
+
11
+ gem.files = `git ls-files`.split($\)
12
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
13
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
14
+ gem.name = "spotifiery"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = Spotifiery::VERSION
17
+
18
+ gem.add_dependency "httparty", ">= 0.9.0"
19
+ gem.add_dependency %q<active_support>, ">= 3.0"
20
+
21
+ gem.add_development_dependency "rspec", "~> 2.11.0"
22
+ gem.add_development_dependency "webmock", "< 1.9.0"
23
+ gem.add_development_dependency "vcr", "~> 2.3.0"
24
+
25
+
26
+ end
metadata ADDED
@@ -0,0 +1,170 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: spotifiery
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - cicloon
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-12-13 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: httparty
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: 0.9.0
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: 0.9.0
30
+ - !ruby/object:Gem::Dependency
31
+ name: active_support
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '3.0'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '3.0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: rspec
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: 2.11.0
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 2.11.0
62
+ - !ruby/object:Gem::Dependency
63
+ name: webmock
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - <
68
+ - !ruby/object:Gem::Version
69
+ version: 1.9.0
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - <
76
+ - !ruby/object:Gem::Version
77
+ version: 1.9.0
78
+ - !ruby/object:Gem::Dependency
79
+ name: vcr
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ~>
84
+ - !ruby/object:Gem::Version
85
+ version: 2.3.0
86
+ type: :development
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ~>
92
+ - !ruby/object:Gem::Version
93
+ version: 2.3.0
94
+ description: Spotify Web API wrapper
95
+ email:
96
+ - aleon.prof@gmail.com
97
+ executables: []
98
+ extensions: []
99
+ extra_rdoc_files: []
100
+ files:
101
+ - .gitignore
102
+ - Gemfile
103
+ - LICENSE
104
+ - README.md
105
+ - Rakefile
106
+ - lib/spotifiery.rb
107
+ - lib/spotifiery/search_result.rb
108
+ - lib/spotifiery/search_result/base.rb
109
+ - lib/spotifiery/searchable.rb
110
+ - lib/spotifiery/searchable/album.rb
111
+ - lib/spotifiery/searchable/artist.rb
112
+ - lib/spotifiery/searchable/base.rb
113
+ - lib/spotifiery/searchable/track.rb
114
+ - lib/spotifiery/version.rb
115
+ - spec/fixtures/vcr_cassettes/album_find.yml
116
+ - spec/fixtures/vcr_cassettes/album_lookup_by_uri.yml
117
+ - spec/fixtures/vcr_cassettes/artist_find.yml
118
+ - spec/fixtures/vcr_cassettes/track_find.yml
119
+ - spec/fixtures/vcr_cassettes/track_lookup_by_uri.yml
120
+ - spec/fixtures/vcr_cassettes/with_or_without_you.yml
121
+ - spec/lib/spotifiery/search_result/base_spec.rb
122
+ - spec/lib/spotifiery/search_result_spec.rb
123
+ - spec/lib/spotifiery/searchable/album_spec.rb
124
+ - spec/lib/spotifiery/searchable/artist_spec.rb
125
+ - spec/lib/spotifiery/searchable/base_spec.rb
126
+ - spec/lib/spotifiery/searchable/track_spec.rb
127
+ - spec/lib/spotifiery/searchable_spec.rb
128
+ - spec/lib/spotifiery_spec.rb
129
+ - spec/spec_helper.rb
130
+ - spotifiery.gemspec
131
+ homepage: https://github.com/cicloon/spotifiery
132
+ licenses: []
133
+ post_install_message:
134
+ rdoc_options: []
135
+ require_paths:
136
+ - lib
137
+ required_ruby_version: !ruby/object:Gem::Requirement
138
+ none: false
139
+ requirements:
140
+ - - ! '>='
141
+ - !ruby/object:Gem::Version
142
+ version: '0'
143
+ required_rubygems_version: !ruby/object:Gem::Requirement
144
+ none: false
145
+ requirements:
146
+ - - ! '>='
147
+ - !ruby/object:Gem::Version
148
+ version: '0'
149
+ requirements: []
150
+ rubyforge_project:
151
+ rubygems_version: 1.8.24
152
+ signing_key:
153
+ specification_version: 3
154
+ summary: This gem provides an API wrapper for the spotify Web search API
155
+ test_files:
156
+ - spec/fixtures/vcr_cassettes/album_find.yml
157
+ - spec/fixtures/vcr_cassettes/album_lookup_by_uri.yml
158
+ - spec/fixtures/vcr_cassettes/artist_find.yml
159
+ - spec/fixtures/vcr_cassettes/track_find.yml
160
+ - spec/fixtures/vcr_cassettes/track_lookup_by_uri.yml
161
+ - spec/fixtures/vcr_cassettes/with_or_without_you.yml
162
+ - spec/lib/spotifiery/search_result/base_spec.rb
163
+ - spec/lib/spotifiery/search_result_spec.rb
164
+ - spec/lib/spotifiery/searchable/album_spec.rb
165
+ - spec/lib/spotifiery/searchable/artist_spec.rb
166
+ - spec/lib/spotifiery/searchable/base_spec.rb
167
+ - spec/lib/spotifiery/searchable/track_spec.rb
168
+ - spec/lib/spotifiery/searchable_spec.rb
169
+ - spec/lib/spotifiery_spec.rb
170
+ - spec/spec_helper.rb