spotify-api 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,106 @@
1
+ #!/usr/bin/env jruby -S spec
2
+ require File.join(File.dirname(__FILE__), '..', 'spec_helper')
3
+ require 'jotify'
4
+
5
+ describe Jotify::Media do
6
+
7
+ describe "an artist" do
8
+ before do
9
+ @artist = Jotify::Media::Artist.new(spotify_hex_id)
10
+ end
11
+
12
+ it "should implement to_h" do
13
+ @artist.to_h.should == {:id=>"4d921ebcdd8c80f32ce1ed5acafbb9c8", :popularity=>0.0, :url=>"http://open.spotify.com/artist/2mnbxTkghYtlHMdX3jdP9C", :name=>nil}
14
+ end
15
+ end
16
+
17
+ describe "a track" do
18
+ before do
19
+ @track = Jotify::Media::Track.new(spotify_hex_id)
20
+ end
21
+
22
+ it "should implement to_h" do
23
+ @track.to_h.should == {:id=>"4d921ebcdd8c80f32ce1ed5acafbb9c8", :popularity=>0.0, :url=>"http://open.spotify.com/track/2mnbxTkghYtlHMdX3jdP9C", :title=>nil, :artist=>nil, :album=>nil}
24
+ end
25
+ end
26
+
27
+ describe "an album" do
28
+ before do
29
+ @album = Jotify::Media::Album.new(spotify_hex_id)
30
+ end
31
+
32
+ it "should implement to_h" do
33
+ @album.to_h.should == {:id=>"4d921ebcdd8c80f32ce1ed5acafbb9c8", :popularity=>0.0, :url=>"http://open.spotify.com/album/2mnbxTkghYtlHMdX3jdP9C", :name=>nil, :artist=>nil, :year=>-1, :type=>nil}
34
+ end
35
+
36
+ it "should implement enumerable" do
37
+ @album.class.included_modules.should include(Enumerable)
38
+ @album.to_a.should == []
39
+ end
40
+ end
41
+
42
+ describe "a result" do
43
+ before do
44
+ @result = Jotify::Media::Result.new
45
+ end
46
+
47
+ it "should implement to_h" do
48
+ @result.to_h.should == {:artists=>[], :albums=>[], :tracks=>[]}
49
+ end
50
+
51
+ it "should implement enumerable" do
52
+ @result.class.included_modules.should include(Enumerable)
53
+ @result.respond_to?(:each).should be_true
54
+ @result.to_a.should == []
55
+ @result.inspect.should == "{:artists=>[], :albums=>[], :tracks=>[]}"
56
+ end
57
+ end
58
+
59
+ describe "playlists" do
60
+ before(:each) do
61
+ @p = Jotify::Media::Playlist.new
62
+ end
63
+
64
+ it "should implement enumerable, size, inspect" do
65
+ @p.class.included_modules.should include(Enumerable)
66
+ @p.respond_to?(:each).should be_true
67
+ 10.times { @p.tracks.add(Jotify::Media::Track.new) }
68
+ @p.size.should == 10
69
+ end
70
+
71
+ it "should implement inspect" do
72
+ @p.inspect.should == "[Playlist: ]"
73
+ end
74
+
75
+ it "should implement <<(track)" do
76
+ @t = Jotify::Media::Track.new(spotify_hex_id)
77
+ lambda {
78
+ @p << @t
79
+ }.should change(@p, :size).by(1)
80
+ @p.to_a.first.should == @t
81
+ end
82
+ end
83
+
84
+ describe "playlist container" do
85
+ before do
86
+ @container = Jotify::Media::PlaylistContainer.new
87
+ end
88
+
89
+ it "should implement enumerable" do
90
+ @container.respond_to?(:each).should be_true
91
+ @container.class.included_modules.should include(Enumerable)
92
+ @container.to_a.should == []
93
+ end
94
+
95
+ it "should implement size" do
96
+ @container.size.should == 0
97
+ end
98
+
99
+ it "should implement <<(playlist)" do
100
+ lambda {
101
+ 2.times { @container << empty_playlist }
102
+ }.should change(@container, :size).by(2)
103
+ end
104
+ end
105
+
106
+ end
@@ -0,0 +1,59 @@
1
+ #!/usr/bin/env jruby -S spec
2
+ require File.join(File.dirname(__FILE__), 'spec_helper')
3
+ require 'jotify'
4
+
5
+ describe Jotify do
6
+
7
+ before(:each) do
8
+ @jotify_impl = mock('JotifyImpl')
9
+ @jotify_impl.stub!(:login)
10
+ @jotify = Jotify.new(@jotify_impl)
11
+ end
12
+
13
+ it "should resolve ids" do
14
+ { "spotify:user:flumix:playlist:2mnbxTkghYtlHMdX3jdP9C" => "4d921ebcdd8c80f32ce1ed5acafbb9c8",
15
+ "http://open.spotify.com/user/flumix/playlist/2mnbxTkghYtlHMdX3jdP9C" => "4d921ebcdd8c80f32ce1ed5acafbb9c8",
16
+ "2mnbxTkghYtlHMdX3jdP9C" => "4d921ebcdd8c80f32ce1ed5acafbb9c8",
17
+ "4d921ebcdd8c80f32ce1ed5acafbb9c8" => "4d921ebcdd8c80f32ce1ed5acafbb9c8"
18
+ }.each { |id, expected| Jotify.resolve_id(id).should == expected }
19
+ end
20
+
21
+ it "should set tracks on playlist" do
22
+ @playlist = Jotify::Media::Playlist.new
23
+ @jotify_impl.should_receive(:playlistAddTracks) do |playlist, tracks, pos|
24
+ playlist.should be_a(Jotify::Media::Playlist)
25
+ #playlist.should == @playlist
26
+ pos.should == 0
27
+ tracks.should be_an(Java::JavaUtil::List)
28
+ tracks.size.should == 1
29
+ end
30
+ @jotify.set_tracks_on_playlist(@playlist, ['4d921ebcdd8c80f32ce1ed5acafbb9c8'])
31
+ end
32
+
33
+ it "should remove tracks before setting tracks on playlist" do
34
+ @playlist = Jotify::Media::Playlist.new
35
+ @playlist << empty_track
36
+ @jotify_impl.should_receive(:playlistRemoveTracks).and_return(true)
37
+ @jotify_impl.should_receive(:playlistAddTracks) do |playlist, tracks, pos|
38
+ playlist.should be_a(Jotify::Media::Playlist)
39
+ #playlist.should == @playlist
40
+ pos.should == 1
41
+ tracks.should be_an(Java::JavaUtil::List)
42
+ tracks.size.should == 1
43
+ end
44
+ @jotify.set_tracks_on_playlist(@playlist, ['4d921ebcdd8c80f32ce1ed5acafbb9c8'])
45
+ end
46
+
47
+ it "should rename the playlist" do
48
+ @playlist = Jotify::Media::Playlist.new
49
+ @jotify_impl.should_receive(:playlistRename).with(anything(), 'new').and_return(true)
50
+ @jotify.rename_playlist(@playlist, 'new').should == true
51
+ end
52
+
53
+
54
+ it "should rename the playlist" do
55
+ @playlist = Jotify::Media::Playlist.new
56
+ @jotify_impl.should_receive(:playlistSetCollaborative).with(anything(), true).and_return(true)
57
+ @jotify.set_collaborative_flag(@playlist, true).should == true
58
+ end
59
+ end
@@ -0,0 +1,36 @@
1
+ require 'rubygems'
2
+ require 'spec'
3
+ require 'rack/test'
4
+
5
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
6
+
7
+ Spec::Runner.configure do |config|
8
+ config.include Rack::Test::Methods
9
+ end
10
+
11
+
12
+ module Helpers
13
+ def spotify_hex_id
14
+ '4d921ebcdd8c80f32ce1ed5acafbb9c8'
15
+ end
16
+
17
+ def spotify_uri
18
+ '2mnbxTkghYtlHMdX3jdP9C'
19
+ end
20
+
21
+ def empty_playlist
22
+ Jotify::Media::Playlist.new
23
+ end
24
+
25
+ def empty_track
26
+ Jotify::Media::Track.new
27
+ end
28
+
29
+ def empty_album
30
+ Jotify::Media::Album.new
31
+ end
32
+ end
33
+
34
+ Spec::Example::ExampleMethods.send(:include, Helpers)
35
+
36
+
@@ -0,0 +1,77 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{spotify-api}
5
+ s.version = "0.0.5"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["Jan Berkel"]
9
+ s.date = %q{2009-10-13}
10
+ s.default_executable = %q{spotify-api-server}
11
+ s.description = %q{an api for spotify, based on jotify}
12
+ s.email = %q{jan.berkel@gmail.com}
13
+ s.executables = ["spotify-api-server"]
14
+ s.extra_rdoc_files = [
15
+ "LICENSE",
16
+ "README.md"
17
+ ]
18
+ s.files = [
19
+ ".gitignore",
20
+ "CHANGELOG",
21
+ "LICENSE",
22
+ "README.md",
23
+ "Rakefile",
24
+ "VERSION.yml",
25
+ "bin/spotify-api-server",
26
+ "examples/lastfm.rb",
27
+ "examples/lastfm2spotify.rb",
28
+ "examples/spotify.rb",
29
+ "lib/jars/jotify.jar",
30
+ "lib/jotify.rb",
31
+ "lib/jotify/api.rb",
32
+ "lib/jotify/media.rb",
33
+ "spec/integration_spec.rb",
34
+ "spec/jotify/api_spec.rb",
35
+ "spec/jotify/media_spec.rb",
36
+ "spec/jotify_spec.rb",
37
+ "spec/spec_helper.rb",
38
+ "spotify-api.gemspec"
39
+ ]
40
+ s.homepage = %q{http://github.com/jberkel/spotify-api}
41
+ s.rdoc_options = ["--charset=UTF-8"]
42
+ s.require_paths = ["lib"]
43
+ s.rubygems_version = %q{1.3.5}
44
+ s.summary = %q{an api for spotify, based on jotify}
45
+ s.test_files = [
46
+ "spec/integration_spec.rb",
47
+ "spec/jotify/api_spec.rb",
48
+ "spec/jotify/media_spec.rb",
49
+ "spec/jotify_spec.rb",
50
+ "spec/spec_helper.rb",
51
+ "examples/lastfm.rb",
52
+ "examples/lastfm2spotify.rb",
53
+ "examples/spotify.rb"
54
+ ]
55
+
56
+ if s.respond_to? :specification_version then
57
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
58
+ s.specification_version = 3
59
+
60
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
61
+ s.add_runtime_dependency(%q<rack>, [">= 0"])
62
+ s.add_runtime_dependency(%q<rack-test>, [">= 0"])
63
+ s.add_runtime_dependency(%q<sinatra>, [">= 0"])
64
+ s.add_runtime_dependency(%q<json-jruby>, [">= 0"])
65
+ else
66
+ s.add_dependency(%q<rack>, [">= 0"])
67
+ s.add_dependency(%q<rack-test>, [">= 0"])
68
+ s.add_dependency(%q<sinatra>, [">= 0"])
69
+ s.add_dependency(%q<json-jruby>, [">= 0"])
70
+ end
71
+ else
72
+ s.add_dependency(%q<rack>, [">= 0"])
73
+ s.add_dependency(%q<rack-test>, [">= 0"])
74
+ s.add_dependency(%q<sinatra>, [">= 0"])
75
+ s.add_dependency(%q<json-jruby>, [">= 0"])
76
+ end
77
+ end
metadata ADDED
@@ -0,0 +1,121 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: spotify-api
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.5
5
+ platform: ruby
6
+ authors:
7
+ - Jan Berkel
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-10-13 00:00:00 +02:00
13
+ default_executable: spotify-api-server
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: rack
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: "0"
24
+ version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: rack-test
27
+ type: :runtime
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: "0"
34
+ version:
35
+ - !ruby/object:Gem::Dependency
36
+ name: sinatra
37
+ type: :runtime
38
+ version_requirement:
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: "0"
44
+ version:
45
+ - !ruby/object:Gem::Dependency
46
+ name: json-jruby
47
+ type: :runtime
48
+ version_requirement:
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: "0"
54
+ version:
55
+ description: an api for spotify, based on jotify
56
+ email: jan.berkel@gmail.com
57
+ executables:
58
+ - spotify-api-server
59
+ extensions: []
60
+
61
+ extra_rdoc_files:
62
+ - LICENSE
63
+ - README.md
64
+ files:
65
+ - .gitignore
66
+ - CHANGELOG
67
+ - LICENSE
68
+ - README.md
69
+ - Rakefile
70
+ - VERSION.yml
71
+ - bin/spotify-api-server
72
+ - examples/lastfm.rb
73
+ - examples/lastfm2spotify.rb
74
+ - examples/spotify.rb
75
+ - lib/jars/jotify.jar
76
+ - lib/jotify.rb
77
+ - lib/jotify/api.rb
78
+ - lib/jotify/media.rb
79
+ - spec/integration_spec.rb
80
+ - spec/jotify/api_spec.rb
81
+ - spec/jotify/media_spec.rb
82
+ - spec/jotify_spec.rb
83
+ - spec/spec_helper.rb
84
+ - spotify-api.gemspec
85
+ has_rdoc: true
86
+ homepage: http://github.com/jberkel/spotify-api
87
+ licenses: []
88
+
89
+ post_install_message:
90
+ rdoc_options:
91
+ - --charset=UTF-8
92
+ require_paths:
93
+ - lib
94
+ required_ruby_version: !ruby/object:Gem::Requirement
95
+ requirements:
96
+ - - ">="
97
+ - !ruby/object:Gem::Version
98
+ version: "0"
99
+ version:
100
+ required_rubygems_version: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - ">="
103
+ - !ruby/object:Gem::Version
104
+ version: "0"
105
+ version:
106
+ requirements: []
107
+
108
+ rubyforge_project:
109
+ rubygems_version: 1.3.5
110
+ signing_key:
111
+ specification_version: 3
112
+ summary: an api for spotify, based on jotify
113
+ test_files:
114
+ - spec/integration_spec.rb
115
+ - spec/jotify/api_spec.rb
116
+ - spec/jotify/media_spec.rb
117
+ - spec/jotify_spec.rb
118
+ - spec/spec_helper.rb
119
+ - examples/lastfm.rb
120
+ - examples/lastfm2spotify.rb
121
+ - examples/spotify.rb