fanart_api 0.2.1 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,18 +1,108 @@
1
- # documentation: http://fanart.tv/api-docs/tv-api
2
1
  class FanartApi::Tv < FanartApi::Base
3
- def find(options = {})
2
+ include Ov
3
+
4
+ # Find specific tv data.
5
+ #
6
+ # access: FREE
7
+ # param:
8
+ # find(1234)
9
+ # output: Faraday::Response instance with Hash body
10
+ # example: http://docs.fanarttv.apiary.io/#tv
11
+ let :find, Any do |id|
12
+ find(id: id)
13
+ end
14
+
15
+ # Find specific tv data.
16
+ #
17
+ # access: FREE
18
+ # param:
19
+ # find(id: 1234)
20
+ # output: Faraday::Response instance with Hash body
21
+ # example: http://docs.fanarttv.apiary.io/#tv
22
+ let :find, Hash do |options|
4
23
  find_path_with_params(options).get
5
24
  end
6
25
 
7
- def find_url(options = {})
26
+ # Find specific tv data - return only url.
27
+ #
28
+ # access: FREE
29
+ # param:
30
+ # find_url(1234)
31
+ # output: url string
32
+ let :find_url, Any do |id|
33
+ find_url(id: id)
34
+ end
35
+
36
+ # Find specific tv data - return only url.
37
+ #
38
+ # access: FREE
39
+ # param:
40
+ # find_url(id: 1234)
41
+ # output: url string
42
+ let :find_url, Hash do |options|
8
43
  find_path_with_params(options).url
9
44
  end
10
45
 
11
- def latest(options = {})
46
+ # Get latest tv data.
47
+ #
48
+ # access: FREE
49
+ # param:
50
+ # latest
51
+ # output: Faraday::Response instance with Array body
52
+ # example: http://docs.fanarttv.apiary.io/#tv
53
+ let :latest do |date|
54
+ latest({})
55
+ end
56
+
57
+ # Get latest tv data.
58
+ #
59
+ # access: FREE
60
+ # param:
61
+ # latest(1234)
62
+ # output: Faraday::Response instance with Array body
63
+ # example: http://docs.fanarttv.apiary.io/#tv
64
+ let :latest, Any do |date|
65
+ latest(date: date)
66
+ end
67
+
68
+ # Get latest tv data.
69
+ #
70
+ # access: FREE
71
+ # param:
72
+ # latest(date: 1234)
73
+ # output: Faraday::Response instance with Array body
74
+ # example: http://docs.fanarttv.apiary.io/#tv
75
+ let :latest, Hash do |options|
12
76
  latest_path_with_params(options).get
13
77
  end
14
78
 
15
- def latest_url(options = {})
79
+ # Get latest tv data - return only url.
80
+ #
81
+ # access: FREE
82
+ # param:
83
+ # latest_url
84
+ # output: url string
85
+ let :latest_url do |date|
86
+ latest_url({})
87
+ end
88
+
89
+ # Get latest tv data - return only url.
90
+ #
91
+ # access: FREE
92
+ # param:
93
+ # latest_url(1234)
94
+ # output: url string
95
+ let :latest_url, Any do |date|
96
+ latest_url(date: date)
97
+ end
98
+
99
+ # Get latest tv data - return only url.
100
+ #
101
+ # access: FREE
102
+ # param:
103
+ # latest_url(date: 1234)
104
+ # output: url string
105
+ let :latest_url, Hash do |options|
16
106
  latest_path_with_params(options).url
17
107
  end
18
108
 
@@ -1,3 +1,3 @@
1
1
  module FanartApi
2
- VERSION = '0.2.1'
2
+ VERSION = '0.3.0'
3
3
  end
@@ -5,44 +5,101 @@ describe FanartApi::Movie do
5
5
  let(:model) { client.movie }
6
6
 
7
7
  let(:movies_data) { File.read('spec/fixtures/find_movies.json') }
8
- let(:movies_data) { File.read('spec/fixtures/find_movies.json') }
8
+ let(:latest_movies_data) { File.read('spec/fixtures/latest_movies.json') }
9
9
 
10
10
  let(:faraday_stubs) do
11
11
  Faraday::Adapter::Test::Stubs.new do |stub|
12
12
  stub.get('/v3/movies/1234?api_key=123456789') { [200, { content_type: 'json' }, movies_data] }
13
- stub.get('/v3/movies/latest?api_key=123456789&date=123') { [200, { content_type: 'json' }, {}] }
13
+ stub.get('/v3/movies/latest?api_key=123456789&date=123') { [200, { content_type: 'json' }, latest_movies_data] }
14
+ stub.get('/v3/movies/latest?api_key=123456789') { [200, { content_type: 'json' }, latest_movies_data] }
14
15
  end
15
16
  end
16
17
 
17
18
  describe '.find' do
18
- it 'should return Faraday::Response class' do
19
- model.find(id: 1234).class.should == Faraday::Response
19
+ context 'hash attributes' do
20
+ it 'should return Faraday::Response class' do
21
+ expect(model.find(id: 1234)).to be_a(Faraday::Response)
22
+ end
23
+
24
+ it 'should return Hash class for body reponse' do
25
+ expect(model.find(id: 1234).body).to be_a(Hash)
26
+ end
20
27
  end
21
28
 
22
- it 'should return Hash class for body reponse' do
23
- model.find(id: 1234).body == Hash
29
+ context 'normal attributes' do
30
+ it 'should return Faraday::Response class' do
31
+ expect(model.find(1234)).to be_a(Faraday::Response)
32
+ end
33
+
34
+ it 'should return Hash class for body reponse' do
35
+ expect(model.find(1234).body).to be_a(Hash)
36
+ end
24
37
  end
25
38
  end
26
39
 
27
40
  describe '.find_url' do
28
- it 'should return correct url' do
29
- model.find_url(id: 1234).should == 'http://fanarttv.apiary-proxy.com/v3/movies/1234?api_key=123456789'
41
+ context 'hash attributes' do
42
+ it 'should return correct url' do
43
+ expect(model.find_url(id: 1234)).to eq('http://webservice.fanart.tv/v3/movies/1234?api_key=123456789')
44
+ end
45
+ end
46
+
47
+ context 'normal attributes' do
48
+ it 'should return correct url' do
49
+ expect(model.find_url(1234)).to eq('http://webservice.fanart.tv/v3/movies/1234?api_key=123456789')
50
+ end
30
51
  end
31
52
  end
32
53
 
33
54
  describe '.latest' do
34
- it 'should return Faraday::Response class' do
35
- model.latest(date: 123).class.should == Faraday::Response
55
+ context 'hash attributes' do
56
+ it 'should return Faraday::Response class' do
57
+ expect(model.latest(date: 123)).to be_a(Faraday::Response)
58
+ end
59
+
60
+ it 'should return Hash class for body reponse' do
61
+ expect(model.latest(date: 123).body).to be_a(Array)
62
+ end
63
+ end
64
+
65
+ context 'normal attributes' do
66
+ it 'should return Faraday::Response class' do
67
+ expect(model.latest(123)).to be_a(Faraday::Response)
68
+ end
69
+
70
+ it 'should return Hash class for body reponse' do
71
+ expect(model.latest(123).body).to be_a(Array)
72
+ end
36
73
  end
37
74
 
38
- it 'should return Hash class for body reponse' do
39
- model.latest(date: 123).body == Hash
75
+ context 'without attributes' do
76
+ it 'should return Faraday::Response class' do
77
+ expect(model.latest).to be_a(Faraday::Response)
78
+ end
79
+
80
+ it 'should return Hash class for body reponse' do
81
+ expect(model.latest.body).to be_a(Array)
82
+ end
40
83
  end
41
84
  end
42
85
 
43
86
  describe '.latest_url' do
44
- it 'should return correct url' do
45
- model.latest_url(date: 123).should == 'http://fanarttv.apiary-proxy.com/v3/movies/latest?api_key=123456789&date=123'
87
+ context 'hash attributes' do
88
+ it 'should return correct url' do
89
+ expect(model.latest_url(date: 123)).to eq('http://webservice.fanart.tv/v3/movies/latest?api_key=123456789&date=123')
90
+ end
91
+ end
92
+
93
+ context 'normal attributes' do
94
+ it 'should return correct url' do
95
+ expect(model.latest_url(123)).to eq('http://webservice.fanart.tv/v3/movies/latest?api_key=123456789&date=123')
96
+ end
97
+ end
98
+
99
+ context 'without attributes' do
100
+ it 'should return correct url' do
101
+ expect(model.latest_url).to eq('http://webservice.fanart.tv/v3/movies/latest?api_key=123456789')
102
+ end
46
103
  end
47
104
  end
48
105
  end
@@ -13,70 +13,167 @@ describe FanartApi::Music do
13
13
  stub.get('/v3/music/albums/1234?api_key=123456789') { [200, { content_type: 'json' }, music_data] }
14
14
  stub.get('/v3/music/labels/1234?api_key=123456789') { [200, { content_type: 'json' }, music_data] }
15
15
  stub.get('/v3/music/latest?api_key=123456789&date=123') { [200, { content_type: 'json' }, latest_music_data] }
16
+ stub.get('/v3/music/latest?api_key=123456789') { [200, { content_type: 'json' }, latest_music_data] }
16
17
  end
17
18
  end
18
19
 
19
20
  describe '.artist' do
20
- it 'should return Faraday::Response class' do
21
- model.artist(id: 1234).class.should == Faraday::Response
21
+ context 'hash attributes' do
22
+ it 'should return Faraday::Response class' do
23
+ expect(model.artist(id: 1234)).to be_a(Faraday::Response)
24
+ end
25
+
26
+ it 'should return Hash class for body reponse' do
27
+ expect(model.artist(id: 1234).body).to be_a(Hash)
28
+ end
22
29
  end
23
30
 
24
- it 'should return Hash class for body reponse' do
25
- model.artist(id: 1234).body == Hash
31
+ context 'normal attributes' do
32
+ it 'should return Faraday::Response class' do
33
+ expect(model.artist(1234)).to be_a(Faraday::Response)
34
+ end
35
+
36
+ it 'should return Hash class for body reponse' do
37
+ expect(model.artist(1234).body).to be_a(Hash)
38
+ end
26
39
  end
27
40
  end
28
41
 
29
42
  describe '.artist_url' do
30
- it 'should return correct url' do
31
- model.artist_url(id: 1234).should == 'http://fanarttv.apiary-proxy.com/v3/music/1234?api_key=123456789'
43
+ context 'hash attributes' do
44
+ it 'should return correct url' do
45
+ expect(model.artist_url(id: 1234)).to eq('http://webservice.fanart.tv/v3/music/1234?api_key=123456789')
46
+ end
47
+ end
48
+
49
+ context 'normal attributes' do
50
+ it 'should return correct url' do
51
+ expect(model.artist_url(1234)).to eq('http://webservice.fanart.tv/v3/music/1234?api_key=123456789')
52
+ end
32
53
  end
33
54
  end
34
55
 
35
56
  describe '.album' do
36
- it 'should return Faraday::Response class' do
37
- model.album(id: 1234).class.should == Faraday::Response
57
+ context 'hash attributes' do
58
+ it 'should return Faraday::Response class' do
59
+ expect(model.album(id: 1234)).to be_a(Faraday::Response)
60
+ end
61
+
62
+ it 'should return Hash class for body reponse' do
63
+ expect(model.album(id: 1234).body).to be_a(Hash)
64
+ end
38
65
  end
39
66
 
40
- it 'should return Hash class for body reponse' do
41
- model.album(id: 1234).body == Hash
67
+ context 'normal attributes' do
68
+ it 'should return Faraday::Response class' do
69
+ expect(model.album(1234)).to be_a(Faraday::Response)
70
+ end
71
+
72
+ it 'should return Hash class for body reponse' do
73
+ expect(model.album(1234).body).to be_a(Hash)
74
+ end
42
75
  end
43
76
  end
44
77
 
45
78
  describe '.album_url' do
46
- it 'should return correct url' do
47
- model.album_url(id: 1234).should == 'http://fanarttv.apiary-proxy.com/v3/music/albums/1234?api_key=123456789'
79
+ context 'hash attributes' do
80
+ it 'should return correct url' do
81
+ expect(model.album_url(id: 1234)).to eq('http://webservice.fanart.tv/v3/music/albums/1234?api_key=123456789')
82
+ end
83
+ end
84
+
85
+ context 'normal attributes' do
86
+ it 'should return correct url' do
87
+ expect(model.album_url(1234)).to eq('http://webservice.fanart.tv/v3/music/albums/1234?api_key=123456789')
88
+ end
48
89
  end
49
90
  end
50
91
 
51
92
  describe '.label' do
52
- it 'should return Faraday::Response class' do
53
- model.label(id: 1234).class.should == Faraday::Response
93
+ context 'hash attributes' do
94
+ it 'should return Faraday::Response class' do
95
+ expect(model.label(id: 1234)).to be_a(Faraday::Response)
96
+ end
97
+
98
+ it 'should return Hash class for body reponse' do
99
+ expect(model.label(id: 1234).body).to be_a(Hash)
100
+ end
54
101
  end
55
102
 
56
- it 'should return Hash class for body reponse' do
57
- model.label(id: 1234).body == Hash
103
+ context 'normal attributes' do
104
+ it 'should return Faraday::Response class' do
105
+ expect(model.label(1234)).to be_a(Faraday::Response)
106
+ end
107
+
108
+ it 'should return Hash class for body reponse' do
109
+ expect(model.label(1234).body).to be_a(Hash)
110
+ end
58
111
  end
59
112
  end
60
113
 
61
114
  describe '.label_url' do
62
- it 'should return correct url' do
63
- model.label_url(id: 1234).should == 'http://fanarttv.apiary-proxy.com/v3/music/labels/1234?api_key=123456789'
115
+ context 'hash attributes' do
116
+ it 'should return correct url' do
117
+ expect(model.label_url(id: 1234)).to eq('http://webservice.fanart.tv/v3/music/labels/1234?api_key=123456789')
118
+ end
119
+ end
120
+
121
+ context 'normal attributes' do
122
+ it 'should return correct url' do
123
+ expect(model.label_url(1234)).to eq('http://webservice.fanart.tv/v3/music/labels/1234?api_key=123456789')
124
+ end
64
125
  end
65
126
  end
66
127
 
67
128
  describe '.latest' do
68
- it 'should return Faraday::Response class' do
69
- model.latest(date: 123).class.should == Faraday::Response
129
+ context 'hash attributes' do
130
+ it 'should return Faraday::Response class' do
131
+ expect(model.latest(date: 123)).to be_a(Faraday::Response)
132
+ end
133
+
134
+ it 'should return Hash class for body reponse' do
135
+ expect(model.latest(date: 123).body).to be_a(Array)
136
+ end
137
+ end
138
+
139
+ context 'normal attributes' do
140
+ it 'should return Faraday::Response class' do
141
+ expect(model.latest(123)).to be_a(Faraday::Response)
142
+ end
143
+
144
+ it 'should return Hash class for body reponse' do
145
+ expect(model.latest(123).body).to be_a(Array)
146
+ end
70
147
  end
71
148
 
72
- it 'should return Hash class for body reponse' do
73
- model.latest(date: 123).body == Hash
149
+ context 'without attributes' do
150
+ it 'should return Faraday::Response class' do
151
+ expect(model.latest).to be_a(Faraday::Response)
152
+ end
153
+
154
+ it 'should return Hash class for body reponse' do
155
+ expect(model.latest.body).to be_a(Array)
156
+ end
74
157
  end
75
158
  end
76
159
 
77
160
  describe '.latest_url' do
78
- it 'should return correct url' do
79
- model.latest_url(date: 123).should == 'http://fanarttv.apiary-proxy.com/v3/music/latest?api_key=123456789&date=123'
161
+ context 'hash attributes' do
162
+ it 'should return correct url' do
163
+ expect(model.latest_url(date: 123)).to eq('http://webservice.fanart.tv/v3/music/latest?api_key=123456789&date=123')
164
+ end
165
+ end
166
+
167
+ context 'normal attributes' do
168
+ it 'should return correct url' do
169
+ expect(model.latest_url(123)).to eq('http://webservice.fanart.tv/v3/music/latest?api_key=123456789&date=123')
170
+ end
171
+ end
172
+
173
+ context 'without attributes' do
174
+ it 'should return correct url' do
175
+ expect(model.latest_url).to eq('http://webservice.fanart.tv/v3/music/latest?api_key=123456789')
176
+ end
80
177
  end
81
178
  end
82
179
  end
@@ -11,38 +11,95 @@ describe FanartApi::Tv do
11
11
  Faraday::Adapter::Test::Stubs.new do |stub|
12
12
  stub.get('/v3/tv/1234?api_key=123456789') { [200, { content_type: 'json' }, tv_data] }
13
13
  stub.get('/v3/tv/latest?api_key=123456789&date=123') { [200, { content_type: 'json' }, latest_tv_data] }
14
+ stub.get('/v3/tv/latest?api_key=123456789') { [200, { content_type: 'json' }, latest_tv_data] }
14
15
  end
15
16
  end
16
17
 
17
18
  describe '.find' do
18
- it 'should return Faraday::Response class' do
19
- model.find(id: 1234).class.should == Faraday::Response
19
+ context 'hash attributes' do
20
+ it 'should return Faraday::Response class' do
21
+ expect(model.find(id: 1234)).to be_a(Faraday::Response)
22
+ end
23
+
24
+ it 'should return Hash class for body reponse' do
25
+ expect(model.find(id: 1234).body).to be_a(Hash)
26
+ end
20
27
  end
21
28
 
22
- it 'should return Hash class for body reponse' do
23
- model.find(id: 1234).body == Hash
29
+ context 'normal attributes' do
30
+ it 'should return Faraday::Response class' do
31
+ expect(model.find(1234)).to be_a(Faraday::Response)
32
+ end
33
+
34
+ it 'should return Hash class for body reponse' do
35
+ expect(model.find(1234).body).to be_a(Hash)
36
+ end
24
37
  end
25
38
  end
26
39
 
27
40
  describe '.find_url' do
28
- it 'should return correct url' do
29
- model.find_url(id: 1234).should == 'http://fanarttv.apiary-proxy.com/v3/tv/1234?api_key=123456789'
41
+ context 'hash attributes' do
42
+ it 'should return correct url' do
43
+ expect(model.find_url(id: 1234)).to eq('http://webservice.fanart.tv/v3/tv/1234?api_key=123456789')
44
+ end
45
+ end
46
+
47
+ context 'normal attributes' do
48
+ it 'should return correct url' do
49
+ expect(model.find_url(1234)).to eq('http://webservice.fanart.tv/v3/tv/1234?api_key=123456789')
50
+ end
30
51
  end
31
52
  end
32
53
 
33
54
  describe '.latest' do
34
- it 'should return Faraday::Response class' do
35
- model.latest(date: 123).class.should == Faraday::Response
55
+ context 'hash attributes' do
56
+ it 'should return Faraday::Response class' do
57
+ expect(model.latest(date: 123)).to be_a(Faraday::Response)
58
+ end
59
+
60
+ it 'should return Hash class for body reponse' do
61
+ expect(model.latest(date: 123).body).to be_a(Array)
62
+ end
36
63
  end
37
64
 
38
- it 'should return Hash class for body reponse' do
39
- model.latest(date: 123).body == Array
65
+ context 'normal attributes' do
66
+ it 'should return Faraday::Response class' do
67
+ expect(model.latest(123)).to be_a(Faraday::Response)
68
+ end
69
+
70
+ it 'should return Hash class for body reponse' do
71
+ expect(model.latest(123).body).to be_a(Array)
72
+ end
73
+ end
74
+
75
+ context 'without attributes' do
76
+ it 'should return Faraday::Response class' do
77
+ expect(model.latest).to be_a(Faraday::Response)
78
+ end
79
+
80
+ it 'should return Hash class for body reponse' do
81
+ expect(model.latest.body).to be_a(Array)
82
+ end
40
83
  end
41
84
  end
42
85
 
43
86
  describe '.latest_url' do
44
- it 'should return correct url' do
45
- model.latest_url(date: 123).should == 'http://fanarttv.apiary-proxy.com/v3/tv/latest?api_key=123456789&date=123'
87
+ context 'hash attributes' do
88
+ it 'should return correct url' do
89
+ expect(model.latest_url(date: 123)).to eq('http://webservice.fanart.tv/v3/tv/latest?api_key=123456789&date=123')
90
+ end
91
+ end
92
+
93
+ context 'normal attributes' do
94
+ it 'should return correct url' do
95
+ expect(model.latest_url(123)).to eq('http://webservice.fanart.tv/v3/tv/latest?api_key=123456789&date=123')
96
+ end
97
+ end
98
+
99
+ context 'without attributes' do
100
+ it 'should return correct url' do
101
+ expect(model.latest_url).to eq('http://webservice.fanart.tv/v3/tv/latest?api_key=123456789')
102
+ end
46
103
  end
47
104
  end
48
105
  end