nestling 0.1.1 → 0.1.2

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.
data/test/test_client.rb CHANGED
@@ -74,7 +74,7 @@ class TestClient < MiniTest::Unit::TestCase
74
74
  def test_sends_user_agent
75
75
  Net::HTTP.any_instance.expects(:get) \
76
76
  .with(anything, { 'User-Agent' => Client::USER_AGENT} ) \
77
- .returns([{}, <<-EOS
77
+ .returns( OpenStruct.new({:body => <<-EOS
78
78
  {
79
79
  "response": {
80
80
  "status": {
@@ -85,7 +85,7 @@ class TestClient < MiniTest::Unit::TestCase
85
85
  }
86
86
  }
87
87
  EOS
88
- ])
88
+ }))
89
89
  Client.new('foo').get('bar')
90
90
  end
91
91
 
@@ -3,8 +3,6 @@ require File.join(File.dirname(__FILE__), 'helper')
3
3
  class TestPlaylist < MiniTest::Unit::TestCase
4
4
  include Nestling
5
5
 
6
- METHODS = Playlist::METHODS
7
-
8
6
  def setup
9
7
  @playlist = Nestling.new('foo').playlist
10
8
  end
@@ -17,26 +15,124 @@ class TestPlaylist < MiniTest::Unit::TestCase
17
15
  assert_equal "playlist/", Playlist::METHOD_PREFIX
18
16
  end
19
17
 
20
- def test_number_of_methods
21
- assert_equal 3, METHODS.length
18
+ def test_static_method
19
+ assert_respond_to @playlist, :static
20
+ end
21
+
22
+ def test_static_returns_collection
23
+ json = <<-EOS
24
+ {"response": {
25
+ "status": {
26
+ "code": "0",
27
+ "message": "Success",
28
+ "version": "4.2"
29
+ },
30
+ "songs": [{
31
+ "foo": "bar"
32
+ }]
33
+ }}
34
+ EOS
35
+ expect_request json, "#{Nestling::Playlist::METHOD_PREFIX}static"
36
+ response = @playlist.static
37
+ assert_kind_of Nestling::Collection, response
38
+ assert_equal 'bar', response[0][:foo]
39
+ end
40
+
41
+ def test_static_passes_options
42
+ json = <<-EOS
43
+ {"response": {
44
+ "status": {
45
+ "code": "0",
46
+ "message": "Success",
47
+ "version": "4.2"
48
+ },
49
+ "songs": [{
50
+ "foo": "bar"
51
+ }]
52
+ }}
53
+ EOS
54
+ expect_request json, "#{Nestling::Playlist::METHOD_PREFIX}static", { :foo => :bar }
55
+ @playlist.static :foo => :bar
56
+ end
57
+
58
+ def test_dynamic_method
59
+ assert_respond_to @playlist, :dynamic
60
+ end
61
+
62
+ def test_dynamic_returns_collection
63
+ json = <<-EOS
64
+ {"response": {
65
+ "status": {
66
+ "code": "0",
67
+ "message": "Success",
68
+ "version": "4.2"
69
+ },
70
+ "songs": [{
71
+ "foo": "bar"
72
+ }]
73
+ }}
74
+ EOS
75
+ expect_request json, "#{Nestling::Playlist::METHOD_PREFIX}dynamic"
76
+ response = @playlist.dynamic
77
+ assert_kind_of Nestling::Collection, response
78
+ assert_equal 'bar', response[0][:foo]
79
+ end
80
+
81
+ def test_dynamic_passes_options
82
+ json = <<-EOS
83
+ {"response": {
84
+ "status": {
85
+ "code": "0",
86
+ "message": "Success",
87
+ "version": "4.2"
88
+ },
89
+ "songs": [{
90
+ "foo": "bar"
91
+ }]
92
+ }}
93
+ EOS
94
+ expect_request json, "#{Nestling::Playlist::METHOD_PREFIX}dynamic", { :foo => :bar }
95
+ @playlist.dynamic :foo => :bar
22
96
  end
23
97
 
24
- def test_static
25
- assert METHODS[:static][:collection]
26
- assert_equal "songs", METHODS[:static][:key]
27
- assert @playlist.respond_to?(:static)
98
+ def test_session_info_method
99
+ assert_respond_to @playlist, :session_info
28
100
  end
29
101
 
30
- def test_dynamic
31
- assert METHODS[:dynamic][:collection]
32
- assert_equal "songs", METHODS[:dynamic][:key]
33
- assert @playlist.respond_to?(:dynamic)
102
+ def test_session_info_returns_hash
103
+ json = <<-EOS
104
+ {"response": {
105
+ "status": {
106
+ "code": "0",
107
+ "message": "Success",
108
+ "version": "4.2"
109
+ },
110
+ "terms": {
111
+ "foo": "bar"
112
+ }
113
+ }}
114
+ EOS
115
+ expect_request json, "#{Nestling::Playlist::METHOD_PREFIX}session_info"
116
+ response = @playlist.session_info
117
+ assert_kind_of Nestling::Hash, response
118
+ assert_equal 'bar', response[:foo]
34
119
  end
35
120
 
36
- def test_session_info
37
- refute METHODS[:session_info][:collection]
38
- assert_equal "terms", METHODS[:session_info][:key]
39
- assert @playlist.respond_to?(:session_info)
121
+ def test_session_info_passes_options
122
+ json = <<-EOS
123
+ {"response": {
124
+ "status": {
125
+ "code": "0",
126
+ "message": "Success",
127
+ "version": "4.2"
128
+ },
129
+ "terms": {
130
+ "foo": "bar"
131
+ }
132
+ }}
133
+ EOS
134
+ expect_request json, "#{Nestling::Playlist::METHOD_PREFIX}session_info", { :foo => :bar }
135
+ @playlist.session_info :foo => :bar
40
136
  end
41
137
  end
42
138
 
data/test/test_song.rb CHANGED
@@ -3,8 +3,6 @@ require File.join(File.dirname(__FILE__), 'helper')
3
3
  class TestSong < MiniTest::Unit::TestCase
4
4
  include Nestling
5
5
 
6
- METHODS = Song::METHODS
7
-
8
6
  def setup
9
7
  @song = Nestling.new('foo').song
10
8
  end
@@ -17,26 +15,124 @@ class TestSong < MiniTest::Unit::TestCase
17
15
  assert_equal "song/", Song::METHOD_PREFIX
18
16
  end
19
17
 
20
- def test_number_of_methods
21
- assert_equal 3, METHODS.length
18
+ def test_search_method
19
+ assert_respond_to @song, :search
20
+ end
21
+
22
+ def test_search_returns_collection
23
+ json = <<-EOS
24
+ {"response": {
25
+ "status": {
26
+ "code": "0",
27
+ "message": "Success",
28
+ "version": "4.2"
29
+ },
30
+ "songs": [{
31
+ "foo": "bar"
32
+ }]
33
+ }}
34
+ EOS
35
+ expect_request json, "#{Nestling::Song::METHOD_PREFIX}search"
36
+ response = @song.search
37
+ assert_kind_of Nestling::Collection, response
38
+ assert_equal 'bar', response[0][:foo]
39
+ end
40
+
41
+ def test_search_passes_options
42
+ json = <<-EOS
43
+ {"response": {
44
+ "status": {
45
+ "code": "0",
46
+ "message": "Success",
47
+ "version": "4.2"
48
+ },
49
+ "songs": [{
50
+ "foo": "bar"
51
+ }]
52
+ }}
53
+ EOS
54
+ expect_request json, "#{Nestling::Song::METHOD_PREFIX}search", { :foo => :bar }
55
+ @song.search :foo => :bar
56
+ end
57
+
58
+ def test_profile_method
59
+ assert_respond_to @song, :profile
60
+ end
61
+
62
+ def test_profile_returns_collection
63
+ json = <<-EOS
64
+ {"response": {
65
+ "status": {
66
+ "code": "0",
67
+ "message": "Success",
68
+ "version": "4.2"
69
+ },
70
+ "songs": [{
71
+ "foo": "bar"
72
+ }]
73
+ }}
74
+ EOS
75
+ expect_request json, "#{Nestling::Song::METHOD_PREFIX}profile"
76
+ response = @song.profile
77
+ assert_kind_of Nestling::Collection, response
78
+ assert_equal 'bar', response[0][:foo]
79
+ end
80
+
81
+ def test_profile_passes_options
82
+ json = <<-EOS
83
+ {"response": {
84
+ "status": {
85
+ "code": "0",
86
+ "message": "Success",
87
+ "version": "4.2"
88
+ },
89
+ "songs": [{
90
+ "foo": "bar"
91
+ }]
92
+ }}
93
+ EOS
94
+ expect_request json, "#{Nestling::Song::METHOD_PREFIX}profile", { :foo => :bar }
95
+ @song.profile :foo => :bar
22
96
  end
23
97
 
24
- def test_search
25
- assert METHODS[:search][:collection]
26
- assert_equal "songs", METHODS[:search][:key]
27
- assert @song.respond_to?(:search)
98
+ def test_identify_method
99
+ assert_respond_to @song, :identify
28
100
  end
29
101
 
30
- def test_profile
31
- assert METHODS[:profile][:collection]
32
- assert_equal "songs", METHODS[:profile][:key]
33
- assert @song.respond_to?(:profile)
102
+ def test_identify_returns_collection
103
+ json = <<-EOS
104
+ {"response": {
105
+ "status": {
106
+ "code": "0",
107
+ "message": "Success",
108
+ "version": "4.2"
109
+ },
110
+ "songs": [{
111
+ "foo": "bar"
112
+ }]
113
+ }}
114
+ EOS
115
+ expect_request json, "#{Nestling::Song::METHOD_PREFIX}identify"
116
+ response = @song.identify
117
+ assert_kind_of Nestling::Collection, response
118
+ assert_equal 'bar', response[0][:foo]
34
119
  end
35
120
 
36
- def test_identify
37
- assert METHODS[:identify][:collection]
38
- assert_equal "songs", METHODS[:identify][:key]
39
- assert @song.respond_to?(:identify)
121
+ def test_identify_passes_options
122
+ json = <<-EOS
123
+ {"response": {
124
+ "status": {
125
+ "code": "0",
126
+ "message": "Success",
127
+ "version": "4.2"
128
+ },
129
+ "songs": [{
130
+ "foo": "bar"
131
+ }]
132
+ }}
133
+ EOS
134
+ expect_request json, "#{Nestling::Song::METHOD_PREFIX}identify", { :foo => :bar }
135
+ @song.identify :foo => :bar
40
136
  end
41
137
  end
42
138
 
data/test/test_track.rb CHANGED
@@ -3,8 +3,6 @@ require File.join(File.dirname(__FILE__), 'helper')
3
3
  class TestTrack < MiniTest::Unit::TestCase
4
4
  include Nestling
5
5
 
6
- METHODS = Track::METHODS
7
-
8
6
  def setup
9
7
  @track = Nestling.new('foo').track
10
8
  end
@@ -17,14 +15,44 @@ class TestTrack < MiniTest::Unit::TestCase
17
15
  assert_equal "track/", Track::METHOD_PREFIX
18
16
  end
19
17
 
20
- def test_number_of_methods
21
- assert_equal 1, METHODS.length
18
+ def test_profile_method
19
+ assert_respond_to @track, :profile
20
+ end
21
+
22
+ def test_profile_returns_hash
23
+ json = <<-EOS
24
+ {"response": {
25
+ "status": {
26
+ "code": "0",
27
+ "message": "Success",
28
+ "version": "4.2"
29
+ },
30
+ "track": {
31
+ "foo": "bar"
32
+ }
33
+ }}
34
+ EOS
35
+ expect_request json, "#{Nestling::Track::METHOD_PREFIX}profile"
36
+ response = @track.profile
37
+ assert_kind_of Nestling::Hash, response
38
+ assert_equal 'bar', response[:foo]
22
39
  end
23
40
 
24
- def test_profile
25
- refute METHODS[:profile][:collection]
26
- assert_equal "track", METHODS[:profile][:key]
27
- assert @track.respond_to?(:profile)
41
+ def test_profile_passes_options
42
+ json = <<-EOS
43
+ {"response": {
44
+ "status": {
45
+ "code": "0",
46
+ "message": "Success",
47
+ "version": "4.2"
48
+ },
49
+ "track": {
50
+ "foo": "bar"
51
+ }
52
+ }}
53
+ EOS
54
+ expect_request json, "#{Nestling::Track::METHOD_PREFIX}profile", { :foo => :bar }
55
+ @track.profile :foo => :bar
28
56
  end
29
57
  end
30
58
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nestling
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
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: 2011-09-23 00:00:00.000000000Z
12
+ date: 2012-03-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: multi_json
16
- requirement: &70331940832920 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,15 @@ dependencies:
21
21
  version: 1.0.3
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70331940832920
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: 1.0.3
25
30
  - !ruby/object:Gem::Dependency
26
31
  name: rake
27
- requirement: &70331940832240 !ruby/object:Gem::Requirement
32
+ requirement: !ruby/object:Gem::Requirement
28
33
  none: false
29
34
  requirements:
30
35
  - - ~>
@@ -32,10 +37,15 @@ dependencies:
32
37
  version: '0.9'
33
38
  type: :development
34
39
  prerelease: false
35
- version_requirements: *70331940832240
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: '0.9'
36
46
  - !ruby/object:Gem::Dependency
37
47
  name: minitest
38
- requirement: &70331940831560 !ruby/object:Gem::Requirement
48
+ requirement: !ruby/object:Gem::Requirement
39
49
  none: false
40
50
  requirements:
41
51
  - - ~>
@@ -43,10 +53,15 @@ dependencies:
43
53
  version: 2.6.0
44
54
  type: :development
45
55
  prerelease: false
46
- version_requirements: *70331940831560
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 2.6.0
47
62
  - !ruby/object:Gem::Dependency
48
63
  name: mocha
49
- requirement: &70331940830800 !ruby/object:Gem::Requirement
64
+ requirement: !ruby/object:Gem::Requirement
50
65
  none: false
51
66
  requirements:
52
67
  - - ~>
@@ -54,7 +69,12 @@ dependencies:
54
69
  version: 0.9.12
55
70
  type: :development
56
71
  prerelease: false
57
- version_requirements: *70331940830800
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ~>
76
+ - !ruby/object:Gem::Version
77
+ version: 0.9.12
58
78
  description: Ruby wrapper for the EchoNest API
59
79
  email:
60
80
  - tob@tobiassvensson.co.uk
@@ -103,15 +123,21 @@ required_ruby_version: !ruby/object:Gem::Requirement
103
123
  - - ! '>='
104
124
  - !ruby/object:Gem::Version
105
125
  version: '0'
126
+ segments:
127
+ - 0
128
+ hash: -362739744680810628
106
129
  required_rubygems_version: !ruby/object:Gem::Requirement
107
130
  none: false
108
131
  requirements:
109
132
  - - ! '>='
110
133
  - !ruby/object:Gem::Version
111
134
  version: '0'
135
+ segments:
136
+ - 0
137
+ hash: -362739744680810628
112
138
  requirements: []
113
139
  rubyforge_project:
114
- rubygems_version: 1.8.10
140
+ rubygems_version: 1.8.19
115
141
  signing_key:
116
142
  specification_version: 3
117
143
  summary: Ruby wrapper for the EchoNest API