hallon 0.14.0 → 0.15.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -130,6 +130,13 @@ describe Hallon::Session do
130
130
  end
131
131
  end
132
132
 
133
+ describe "#login" do
134
+ it "should raise an error when given empty credentials" do
135
+ expect { session.login '', 'pass' }.to raise_error(ArgumentError)
136
+ expect { session.login 'Kim', '' }.to raise_error(ArgumentError)
137
+ end
138
+ end
139
+
133
140
  describe "#logout" do
134
141
  it "should check logged in status" do
135
142
  session.should_receive(:logged_in?).once.and_return(false)
@@ -67,7 +67,7 @@ describe Hallon::User do
67
67
  it "should return the playlist container of the user" do
68
68
  Spotify.registry_add("spotify:container:%s" % user.name, mock_container)
69
69
 
70
- session.login('burgestrand', '')
70
+ session.login('burgestrand', 'pass')
71
71
  mock_session { user.published.should eq published }
72
72
  end
73
73
 
data/spec/mockspotify.rb CHANGED
@@ -42,7 +42,9 @@ module Spotify
42
42
  layout :playlist, :playlist,
43
43
  :type, :playlist_type,
44
44
  :folder_name, :pointer,
45
- :folder_id, :uint64
45
+ :folder_id, :uint64,
46
+ :num_seen_tracks, :int,
47
+ :seen_tracks, :pointer
46
48
  end
47
49
  end
48
50
 
@@ -61,18 +63,18 @@ module Spotify
61
63
 
62
64
  attach_function :mock_session, :mocksp_session_create, [:pointer, :connectionstate, :int, Spotify::OfflineSyncStatus, :int, :int, :playlist], :session
63
65
  attach_mock_function :mock_user, :mocksp_user_create, [:string, :string, :bool], :user
64
- attach_mock_function :mock_track, :mocksp_track_create, [:string, :int, :array, :album, :int, :int, :int, :int, :error, :bool, :availability, :track_offline_status, :bool, :bool, :bool, :bool], :track
66
+ attach_mock_function :mock_track, :mocksp_track_create, [:string, :int, :array, :album, :int, :int, :int, :int, :error, :bool, :availability, :track_offline_status, :bool, :bool, :track, :bool, :bool], :track
65
67
  attach_mock_function :mock_image, :mocksp_image_create, [:image_id, :imageformat, :size_t, :buffer_in, :error], :image
66
68
  attach_mock_function :mock_artist, :mocksp_artist_create, [:string, :image_id, :bool], :artist
67
69
  attach_mock_function :mock_album, :mocksp_album_create, [:string, :artist, :int, :image_id, :albumtype, :bool, :bool], :album
68
70
 
69
71
  attach_function :mock_albumbrowse, :mocksp_albumbrowse_create, [:error, :int, :album, :artist, :int, :array, :int, :array, :string, :albumbrowse_complete_cb, :pointer], :albumbrowse
70
- attach_function :mock_artistbrowse, :mocksp_artistbrowse_create, [:error, :int, :artist, :int, :array, :int, :array, :int, :array, :int, :array, :string, :artistbrowse_type, :artistbrowse_complete_cb, :pointer], :artistbrowse
72
+ attach_function :mock_artistbrowse, :mocksp_artistbrowse_create, [:error, :int, :artist, :int, :array, :int, :array, :int, :array, :int, :array, :int, :array, :string, :artistbrowse_type, :artistbrowse_complete_cb, :pointer], :artistbrowse
71
73
  attach_function :mock_toplistbrowse, :mocksp_toplistbrowse_create, [:error, :int, :int, :array, :int, :array, :int, :array], :toplistbrowse
72
74
 
73
75
  attach_mock_function :mock_playlist, :mocksp_playlist_create, [:string, :bool, :user, :bool, :string, :image_id, :bool, :uint, Spotify::Subscribers, :bool, :playlist_offline_status, :int, :int, :array], :playlist
74
76
  attach_mock_function :mock_playlistcontainer, :mocksp_playlistcontainer_create, [:user, :bool, :int, :array, PlaylistContainerCallbacks, :userdata], :playlistcontainer
75
- attach_function :mock_search, :mocksp_search_create, [:error, :string, :string, :int, :int, :array, :int, :int, :array, :int, :int, :array, :search_complete_cb, :pointer], :search
77
+ attach_function :mock_search, :mocksp_search_create, [:error, :string, :string, :int, :int, :array, :int, :int, :array, :int, :int, :array, :int, :int, :array, :search_complete_cb, :pointer], :search
76
78
  attach_function :mock_subscribers, :mocksp_subscribers, [:int, :array], Spotify::Subscribers
77
79
 
78
80
  # mocked accessors
data/spec/spec_helper.rb CHANGED
@@ -1,5 +1,8 @@
1
1
  # coding: utf-8
2
2
 
3
+ require 'bundler'
4
+ Bundler.setup
5
+
3
6
  begin
4
7
  require 'cover_me'
5
8
  rescue LoadError
@@ -13,12 +13,17 @@ RSpec::Core::ExampleGroup.instance_eval do
13
13
 
14
14
  let(:mock_track) do
15
15
  artists = pointer_array_with(mock_artist, mock_artist_two)
16
- Spotify.mock_track!("They", artists.length, artists, mock_album, 123_456, 42, 2, 7, 0, true, :available, :done, false, true, true, false)
16
+ Spotify.mock_track!("They", artists.length, artists, mock_album, 123_456, 42, 2, 7, :ok, true, :available, :done, false, true, nil, true, false)
17
17
  end
18
18
 
19
19
  let(:mock_track_two) do
20
20
  artists = pointer_array_with(mock_artist)
21
- Spotify.mock_track!("Amazing", artists.length, artists, mock_album, 123_456, 42, 2, 7, 0, true, :available, :no, false, true, true, true)
21
+ Spotify.mock_track!("Amazing", artists.length, artists, mock_album, 123_456, 42, 2, 7, :ok, true, :available, :no, false, true, nil, true, true)
22
+ end
23
+
24
+ let(:mock_linked_track) do
25
+ artists = pointer_array_with(mock_artist_two)
26
+ Spotify.mock_track!("They", artists.length, artists, mock_album, 60, 100, 1, 1, :ok, true, :available, :no, false, true, mock_track, false, false)
22
27
  end
23
28
 
24
29
  let(:mock_albumbrowse) do
@@ -34,8 +39,9 @@ RSpec::Core::ExampleGroup.instance_eval do
34
39
  portraits = pointer_array_with(mock_image_id_pointer, mock_image_id_pointer)
35
40
  tracks = pointer_array_with(mock_track, mock_track_two)
36
41
  albums = pointer_array_with(mock_album)
42
+ tophits = pointer_array_with(mock_track)
37
43
 
38
- Spotify.mock_artistbrowse(:ok, 2751, mock_artist, portraits.length, portraits, tracks.length, tracks, albums.length, albums, similar_artists.length, similar_artists, "grew up in DA BLOCK", :full, nil, nil)
44
+ Spotify.mock_artistbrowse(:ok, 2751, mock_artist, portraits.length, portraits, tracks.length, tracks, albums.length, albums, similar_artists.length, similar_artists, tophits.length, tophits, "grew up in DA BLOCK", :full, nil, nil)
39
45
  end
40
46
 
41
47
  let(:mock_toplistbrowse) do
@@ -46,11 +52,12 @@ RSpec::Core::ExampleGroup.instance_eval do
46
52
  end
47
53
 
48
54
  let(:mock_search) do
49
- artists = pointer_array_with(mock_artist, mock_artist_two)
50
- albums = pointer_array_with(mock_album)
51
- tracks = pointer_array_with(mock_track, mock_track_two)
55
+ artists = pointer_array_with(mock_artist, mock_artist_two)
56
+ albums = pointer_array_with(mock_album)
57
+ tracks = pointer_array_with(mock_track, mock_track_two)
58
+ playlists = pointer_array_with(mock_playlist, mock_playlist_two)
52
59
 
53
- Spotify.mock_search(:ok, "my query", "another thing", 1337, tracks.length, tracks, 42, albums.length, albums, 81104, artists.length, artists, nil, nil)
60
+ Spotify.mock_search(:ok, "my å utf8  query", "another thing", 1337, tracks.length, tracks, 42, albums.length, albums, 81104, artists.length, artists, 0716, playlists.length, playlists, nil, nil)
54
61
  end
55
62
 
56
63
  let(:mock_subscribers) do
@@ -110,8 +117,8 @@ RSpec::Core::ExampleGroup.instance_eval do
110
117
  end
111
118
 
112
119
  let(:mock_image_uri) { "spotify:image:#{mock_image_hex}" }
113
- let(:mock_image_hex) { "3ad93423add99766e02d563605c6e76ed2b0e450" }
114
- let(:mock_image_id) { ":\xD94#\xAD\xD9\x97f\xE0-V6\x05\xC6\xE7n\xD2\xB0\xE4P".force_encoding("BINARY") }
120
+ let(:mock_image_hex) { "3ad93423add99766e02d563605c6e76ed2b0e400" }
121
+ let(:mock_image_id) { ":\xD94#\xAD\xD9\x97f\xE0-V6\x05\xC6\xE7n\xD2\xB0\xE4\0".force_encoding("BINARY") }
115
122
  let(:null_pointer) { FFI::Pointer.new(0) }
116
123
  let(:a_pointer) { FFI::Pointer.new(1) }
117
124
 
@@ -157,7 +164,7 @@ RSpec::Core::ExampleGroup.instance_eval do
157
164
 
158
165
  let(:mock_container) do
159
166
  num_items = 4
160
- items_ptr = FFI::MemoryPointer.new(Spotify::Mock::PlaylistTrack, num_items)
167
+ items_ptr = FFI::MemoryPointer.new(Spotify::Mock::PlaylistContainerItem, num_items)
161
168
  items = num_items.times.map do |i|
162
169
  Spotify::Mock::PlaylistContainerItem.new(items_ptr + Spotify::Mock::PlaylistContainerItem.size * i)
163
170
  end
@@ -192,6 +199,7 @@ RSpec.configure do |config|
192
199
  Spotify.registry_add 'spotify:user:burgestrand', mock_user
193
200
  Spotify.registry_add 'spotify:user:burgestrand:playlist:07AX9IY9Hqmj1RqltcG0fi', mock_playlist
194
201
  Spotify.registry_add 'spotify:user:burgestrand:starred', mock_playlist
202
+ Spotify.registry_add 'spotify:search:my+%C3%A5+utf8+%EF%A3%BF+query', mock_search
195
203
  end
196
204
 
197
205
  config.after do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hallon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.14.0
4
+ version: 0.15.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-02-27 00:00:00.000000000 Z
12
+ date: 2012-04-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: ref
16
- requirement: &70180063490240 !ruby/object:Gem::Requirement
16
+ requirement: &70257549939320 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,21 +21,21 @@ dependencies:
21
21
  version: '1.0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70180063490240
24
+ version_requirements: *70257549939320
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: spotify
27
- requirement: &70180063489400 !ruby/object:Gem::Requirement
27
+ requirement: &70257549938820 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
31
31
  - !ruby/object:Gem::Version
32
- version: 10.3.0
32
+ version: 11.0.2
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70180063489400
35
+ version_requirements: *70257549938820
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rake
38
- requirement: &70180063487500 !ruby/object:Gem::Requirement
38
+ requirement: &70257549938160 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0.8'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70180063487500
46
+ version_requirements: *70257549938160
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rspec
49
- requirement: &70180063485340 !ruby/object:Gem::Requirement
49
+ requirement: &70257549937260 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ~>
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '2'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *70180063485340
57
+ version_requirements: *70257549937260
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: yard
60
- requirement: &70180063484620 !ruby/object:Gem::Requirement
60
+ requirement: &70257549936520 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,21 @@ dependencies:
65
65
  version: '0'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *70180063484620
68
+ version_requirements: *70257549936520
69
+ - !ruby/object:Gem::Dependency
70
+ name: bundler
71
+ requirement: &70257549935960 !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ! '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: *70257549935960
69
80
  - !ruby/object:Gem::Dependency
70
81
  name: rdiscount
71
- requirement: &70180063483960 !ruby/object:Gem::Requirement
82
+ requirement: &70257549935520 !ruby/object:Gem::Requirement
72
83
  none: false
73
84
  requirements:
74
85
  - - ! '>='
@@ -76,7 +87,7 @@ dependencies:
76
87
  version: '0'
77
88
  type: :development
78
89
  prerelease: false
79
- version_requirements: *70180063483960
90
+ version_requirements: *70257549935520
80
91
  description:
81
92
  email: kim@burgestrand.se
82
93
  executables: []
@@ -97,9 +108,8 @@ files:
97
108
  - Rakefile
98
109
  - dev/login.rb
99
110
  - examples/adding_tracks_to_playlist.rb
100
- - examples/logging_in.rb
111
+ - examples/example_support.rb
101
112
  - examples/playing_audio.rb
102
- - examples/printing_link_information.rb
103
113
  - examples/show_published_playlists_of_user.rb
104
114
  - hallon.gemspec
105
115
  - lib/hallon.rb
@@ -208,6 +218,8 @@ files:
208
218
  - spec/mockspotify/libmockspotify/src/session.c
209
219
  - spec/mockspotify/libmockspotify/src/toplistbrowse.c
210
220
  - spec/mockspotify/libmockspotify/src/track.c
221
+ - spec/mockspotify/libmockspotify/src/urlcode.c
222
+ - spec/mockspotify/libmockspotify/src/urlcode.h
211
223
  - spec/mockspotify/libmockspotify/src/user.c
212
224
  - spec/mockspotify/libmockspotify/src/util.c
213
225
  - spec/mockspotify/libmockspotify/src/util.h
@@ -1,16 +0,0 @@
1
- # coding: utf-8
2
-
3
- $LOAD_PATH.unshift(File.expand_path('../lib', File.dirname(__FILE__)))
4
-
5
- require 'hallon'
6
- require './spec/support/config'
7
-
8
- session = Hallon::Session.initialize IO.read(ENV['HALLON_APPKEY']) do
9
- on(:log_message) do |message|
10
- puts "[LOG] #{message}"
11
- end
12
- end
13
-
14
- session.login!(ENV['HALLON_USERNAME'], ENV['HALLON_PASSWORD'])
15
-
16
- puts "Successfully logged in!"
@@ -1,30 +0,0 @@
1
- # coding: utf-8
2
-
3
- $LOAD_PATH.unshift(File.expand_path('../lib', File.dirname(__FILE__)))
4
-
5
- require 'hallon'
6
- require './spec/support/config'
7
-
8
- # Utility
9
- def prompt(str)
10
- print str
11
- gets.chomp
12
- end
13
-
14
- # Hallon
15
- session = Hallon::Session.initialize IO.read(ENV['HALLON_APPKEY']) do
16
- on(:log_message) do |message|
17
- $stderr.puts "[LOG] #{message}"
18
- end
19
- end
20
-
21
- while url = prompt("Enter a Spotify URI: ")
22
- begin
23
- p (link = Hallon::Link.new(url))
24
- puts "\tHTTP URL: #{link.to_url}"
25
- puts "\tSpotify URI: #{link.to_str}"
26
- puts "\tLink type: #{link.type}"
27
- rescue ArgumentError => e
28
- puts e
29
- end
30
- end