trakt_api 0.0.3 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -1
- data/.travis.yml +3 -1
- data/README.md +21 -209
- data/lib/trakt_api.rb +3 -17
- data/lib/trakt_api/base.rb +35 -68
- data/lib/trakt_api/client.rb +6 -67
- data/lib/trakt_api/search.rb +7 -18
- data/lib/trakt_api/version.rb +1 -1
- data/spec/fixtures/search.json +125 -0
- data/spec/functionals/search_spec.rb +23 -0
- data/spec/integrations/search_spec.rb +9 -30
- data/spec/spec_helper.rb +2 -38
- data/spec/support/.keep +0 -0
- data/spec/support/trakt_api.rb.example +1 -0
- data/trakt_api.gemspec +4 -3
- metadata +42 -94
- data/lib/generators/templates/trakt_api.rb +0 -5
- data/lib/generators/trakt_api/install_generator.rb +0 -12
- data/lib/trakt_api/account.rb +0 -16
- data/lib/trakt_api/activity.rb +0 -94
- data/lib/trakt_api/calendar.rb +0 -17
- data/lib/trakt_api/comment.rb +0 -16
- data/lib/trakt_api/configuration.rb +0 -7
- data/lib/trakt_api/genres.rb +0 -11
- data/lib/trakt_api/lists.rb +0 -26
- data/lib/trakt_api/movie.rb +0 -86
- data/lib/trakt_api/movies.rb +0 -11
- data/lib/trakt_api/network.rb +0 -26
- data/lib/trakt_api/rate.rb +0 -31
- data/lib/trakt_api/recommendations.rb +0 -21
- data/lib/trakt_api/server.rb +0 -6
- data/lib/trakt_api/show.rb +0 -151
- data/lib/trakt_api/shows.rb +0 -11
- data/lib/trakt_api/user.rb +0 -116
- data/spec/integration_spec_helper.rb +0 -3
- data/spec/integrations/account_spec.rb +0 -19
- data/spec/integrations/calendar_spec.rb +0 -31
- data/spec/integrations/client_spec.rb +0 -173
- data/spec/integrations/genres_spec.rb +0 -19
- data/spec/integrations/movies_spec.rb +0 -25
- data/spec/integrations/network_spec.rb +0 -37
- data/spec/integrations/server_spec.rb +0 -13
- data/spec/integrations/shows_spec.rb +0 -25
- data/spec/integrations/support/trakt_api.rb.example +0 -5
- data/spec/trakt_api/account_spec.rb +0 -56
- data/spec/trakt_api/activity_spec.rb +0 -243
- data/spec/trakt_api/base_spec.rb +0 -140
- data/spec/trakt_api/calendar_spec.rb +0 -48
- data/spec/trakt_api/client_spec.rb +0 -101
- data/spec/trakt_api/comment_spec.rb +0 -69
- data/spec/trakt_api/genres_spec.rb +0 -24
- data/spec/trakt_api/lists_spec.rb +0 -111
- data/spec/trakt_api/movie_spec.rb +0 -345
- data/spec/trakt_api/movies_spec.rb +0 -44
- data/spec/trakt_api/network_spec.rb +0 -105
- data/spec/trakt_api/rate_spec.rb +0 -132
- data/spec/trakt_api/recommendations_spec.rb +0 -90
- data/spec/trakt_api/search_spec.rb +0 -81
- data/spec/trakt_api/server_spec.rb +0 -15
- data/spec/trakt_api/show_spec.rb +0 -618
- data/spec/trakt_api/shows_spec.rb +0 -44
- data/spec/trakt_api/user_spec.rb +0 -489
@@ -1,25 +0,0 @@
|
|
1
|
-
require 'integration_spec_helper'
|
2
|
-
|
3
|
-
describe TraktApi::Shows do
|
4
|
-
let(:model) { TraktApi::Shows.new(TraktApi::Client.new) }
|
5
|
-
|
6
|
-
describe 'real request' do
|
7
|
-
describe '.trending' do
|
8
|
-
it 'should return response class' do
|
9
|
-
model.trending.class.should == HTTParty::Response
|
10
|
-
end
|
11
|
-
|
12
|
-
describe 'with authentication' do
|
13
|
-
it 'should return response class' do
|
14
|
-
model.trending(auth: true).class.should == HTTParty::Response
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
describe '.updated' do
|
20
|
-
it 'should return response class' do
|
21
|
-
model.updated(time: Time.now.strftime("%Y%d%m")).class.should == HTTParty::Response
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
@@ -1,56 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe TraktApi::Account do
|
4
|
-
let(:model) { TraktApi::Account.new(TraktApi::Client.new) }
|
5
|
-
let(:mock_model) { SampleModel.new }
|
6
|
-
|
7
|
-
before do
|
8
|
-
model.instance_variable_set("@uri", '/')
|
9
|
-
end
|
10
|
-
|
11
|
-
describe '.create' do
|
12
|
-
it 'should call post with specific params' do
|
13
|
-
model.instance_variable_set("@method", :post)
|
14
|
-
model.should_receive(:post).with('account/create').and_return(mock_model)
|
15
|
-
|
16
|
-
model.create(username: 'tester', password: 'qwerty', email: 'tester@gmail.com')
|
17
|
-
end
|
18
|
-
|
19
|
-
it 'should call params wih specific hash' do
|
20
|
-
model.should_receive(:params).with(username: 'tester', password: 'qwerty', email: 'tester@gmail.com').
|
21
|
-
and_return(mock_model)
|
22
|
-
|
23
|
-
model.create(username: 'tester', password: 'qwerty', email: 'tester@gmail.com')
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
describe '.settings' do
|
28
|
-
it 'should call auth' do
|
29
|
-
model.should_receive(:auth).and_return(mock_model)
|
30
|
-
|
31
|
-
model.settings
|
32
|
-
end
|
33
|
-
|
34
|
-
it 'should call post with specific params' do
|
35
|
-
model.instance_variable_set("@method", :post)
|
36
|
-
model.should_receive(:post).with('account/settings').and_return(mock_model)
|
37
|
-
|
38
|
-
model.settings
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
describe '.test' do
|
43
|
-
it 'should call auth' do
|
44
|
-
model.should_receive(:auth).and_return(mock_model)
|
45
|
-
|
46
|
-
model.test
|
47
|
-
end
|
48
|
-
|
49
|
-
it 'should call post with specific params' do
|
50
|
-
model.instance_variable_set("@method", :post)
|
51
|
-
model.should_receive(:post).with('account/test').and_return(mock_model)
|
52
|
-
|
53
|
-
model.test
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
@@ -1,243 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe TraktApi::Activity do
|
4
|
-
let(:model) { TraktApi::Activity.new(TraktApi::Client.new) }
|
5
|
-
let(:mock_model) { SampleModel.new }
|
6
|
-
|
7
|
-
describe '.community' do
|
8
|
-
it 'should call get with specific params' do
|
9
|
-
model.instance_variable_set("@method", :get)
|
10
|
-
model.should_receive(:get).with('activity/community').and_return(mock_model)
|
11
|
-
|
12
|
-
model.community
|
13
|
-
end
|
14
|
-
|
15
|
-
it 'should call params' do
|
16
|
-
model.should_receive(:params).and_return(mock_model)
|
17
|
-
|
18
|
-
model.community
|
19
|
-
end
|
20
|
-
|
21
|
-
it 'should call restful_params' do
|
22
|
-
model.should_receive(:restful_params).and_return(mock_model)
|
23
|
-
|
24
|
-
model.community
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
describe '.episodes' do
|
29
|
-
it 'should call get with specific params' do
|
30
|
-
model.instance_variable_set("@method", :get)
|
31
|
-
model.should_receive(:get).with('activity/episodes').and_return(mock_model)
|
32
|
-
|
33
|
-
model.episodes(title: 'test', season: 1, episode: 2)
|
34
|
-
end
|
35
|
-
|
36
|
-
it 'should call params' do
|
37
|
-
model.should_receive(:params).and_return(mock_model)
|
38
|
-
|
39
|
-
model.episodes(title: 'test', season: 1, episode: 2)
|
40
|
-
end
|
41
|
-
|
42
|
-
it 'should call restful_params' do
|
43
|
-
model.should_receive(:restful_params).and_return(mock_model)
|
44
|
-
|
45
|
-
model.episodes(title: 'test', season: 1, episode: 2)
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
describe '.friends' do
|
50
|
-
it 'should call auth' do
|
51
|
-
model.should_receive(:auth).and_return(mock_model)
|
52
|
-
|
53
|
-
model.friends
|
54
|
-
end
|
55
|
-
|
56
|
-
it 'should call post with specific params' do
|
57
|
-
model.instance_variable_set("@method", :post)
|
58
|
-
model.should_receive(:post).with('activity/friends').and_return(mock_model)
|
59
|
-
|
60
|
-
model.friends
|
61
|
-
end
|
62
|
-
|
63
|
-
it 'should call params' do
|
64
|
-
model.should_receive(:params).and_return(mock_model)
|
65
|
-
|
66
|
-
model.friends
|
67
|
-
end
|
68
|
-
|
69
|
-
it 'should call restful_params' do
|
70
|
-
model.should_receive(:restful_params).and_return(mock_model)
|
71
|
-
|
72
|
-
model.friends
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
describe '.movies' do
|
77
|
-
it 'should call get with specific params' do
|
78
|
-
model.instance_variable_set("@method", :get)
|
79
|
-
model.should_receive(:get).with('activity/movies').and_return(mock_model)
|
80
|
-
|
81
|
-
model.movies(title: 'test')
|
82
|
-
end
|
83
|
-
|
84
|
-
it 'should call params' do
|
85
|
-
model.should_receive(:params).and_return(mock_model)
|
86
|
-
|
87
|
-
model.movies(title: 'test')
|
88
|
-
end
|
89
|
-
|
90
|
-
it 'should call restful_params' do
|
91
|
-
model.should_receive(:restful_params).and_return(mock_model)
|
92
|
-
|
93
|
-
model.movies(title: 'test')
|
94
|
-
end
|
95
|
-
end
|
96
|
-
|
97
|
-
describe '.seasons' do
|
98
|
-
it 'should call get with specific params' do
|
99
|
-
model.instance_variable_set("@method", :get)
|
100
|
-
model.should_receive(:get).with('activity/seasons').and_return(mock_model)
|
101
|
-
|
102
|
-
model.seasons(title: 'test', season: 1)
|
103
|
-
end
|
104
|
-
|
105
|
-
it 'should call params' do
|
106
|
-
model.should_receive(:params).and_return(mock_model)
|
107
|
-
|
108
|
-
model.seasons(title: 'test', season: 1)
|
109
|
-
end
|
110
|
-
|
111
|
-
it 'should call restful_params' do
|
112
|
-
model.should_receive(:restful_params).and_return(mock_model)
|
113
|
-
|
114
|
-
model.seasons(title: 'test', season: 1)
|
115
|
-
end
|
116
|
-
end
|
117
|
-
|
118
|
-
describe '.shows' do
|
119
|
-
it 'should call get with specific params' do
|
120
|
-
model.instance_variable_set("@method", :get)
|
121
|
-
model.should_receive(:get).with('activity/shows').and_return(mock_model)
|
122
|
-
|
123
|
-
model.shows(title: 'test')
|
124
|
-
end
|
125
|
-
|
126
|
-
it 'should call params' do
|
127
|
-
model.should_receive(:params).and_return(mock_model)
|
128
|
-
|
129
|
-
model.shows(title: 'test')
|
130
|
-
end
|
131
|
-
|
132
|
-
it 'should call restful_params' do
|
133
|
-
model.should_receive(:restful_params).and_return(mock_model)
|
134
|
-
|
135
|
-
model.shows(title: 'test')
|
136
|
-
end
|
137
|
-
end
|
138
|
-
|
139
|
-
describe '.user' do
|
140
|
-
it 'should call get with specific params' do
|
141
|
-
model.instance_variable_set("@method", :get)
|
142
|
-
model.should_receive(:get).with('activity/user').and_return(mock_model)
|
143
|
-
|
144
|
-
model.user(username: 'test')
|
145
|
-
end
|
146
|
-
|
147
|
-
it 'should call params' do
|
148
|
-
model.should_receive(:params).and_return(mock_model)
|
149
|
-
|
150
|
-
model.user(username: 'test')
|
151
|
-
end
|
152
|
-
|
153
|
-
it 'should call restful_params' do
|
154
|
-
model.should_receive(:restful_params).and_return(mock_model)
|
155
|
-
|
156
|
-
model.user(username: 'test')
|
157
|
-
end
|
158
|
-
end
|
159
|
-
|
160
|
-
describe '.user_episodes' do
|
161
|
-
it 'should call get with specific params' do
|
162
|
-
model.instance_variable_set("@method", :get)
|
163
|
-
model.should_receive(:get).with('activity/user/episodes').and_return(mock_model)
|
164
|
-
|
165
|
-
model.user_episodes(username: 'justin', title: 'test', season: 1, episode: 2)
|
166
|
-
end
|
167
|
-
|
168
|
-
it 'should call params' do
|
169
|
-
model.should_receive(:params).and_return(mock_model)
|
170
|
-
|
171
|
-
model.user_episodes(username: 'justin', title: 'test', season: 1, episode: 2)
|
172
|
-
end
|
173
|
-
|
174
|
-
it 'should call restful_params' do
|
175
|
-
model.should_receive(:restful_params).and_return(mock_model)
|
176
|
-
|
177
|
-
model.user_episodes(username: 'justin', title: 'test', season: 1, episode: 2)
|
178
|
-
end
|
179
|
-
end
|
180
|
-
|
181
|
-
describe '.user_movies' do
|
182
|
-
it 'should call get with specific params' do
|
183
|
-
model.instance_variable_set("@method", :get)
|
184
|
-
model.should_receive(:get).with('activity/user/movies').and_return(mock_model)
|
185
|
-
|
186
|
-
model.user_movies(username: 'justin', title: 'test')
|
187
|
-
end
|
188
|
-
|
189
|
-
it 'should call params' do
|
190
|
-
model.should_receive(:params).and_return(mock_model)
|
191
|
-
|
192
|
-
model.user_movies(username: 'justin', title: 'test')
|
193
|
-
end
|
194
|
-
|
195
|
-
it 'should call restful_params' do
|
196
|
-
model.should_receive(:restful_params).and_return(mock_model)
|
197
|
-
|
198
|
-
model.user_movies(username: 'justin', title: 'test')
|
199
|
-
end
|
200
|
-
end
|
201
|
-
|
202
|
-
describe '.user_seasons' do
|
203
|
-
it 'should call get with specific params' do
|
204
|
-
model.instance_variable_set("@method", :get)
|
205
|
-
model.should_receive(:get).with('activity/user/seasons').and_return(mock_model)
|
206
|
-
|
207
|
-
model.user_seasons(username: 'justin', title: 'test', season: 1)
|
208
|
-
end
|
209
|
-
|
210
|
-
it 'should call params' do
|
211
|
-
model.should_receive(:params).and_return(mock_model)
|
212
|
-
|
213
|
-
model.user_seasons(username: 'justin', title: 'test', season: 1)
|
214
|
-
end
|
215
|
-
|
216
|
-
it 'should call restful_params' do
|
217
|
-
model.should_receive(:restful_params).and_return(mock_model)
|
218
|
-
|
219
|
-
model.user_seasons(username: 'justin', title: 'test', season: 1)
|
220
|
-
end
|
221
|
-
end
|
222
|
-
|
223
|
-
describe '.user_shows' do
|
224
|
-
it 'should call get with specific params' do
|
225
|
-
model.instance_variable_set("@method", :get)
|
226
|
-
model.should_receive(:get).with('activity/user/shows').and_return(mock_model)
|
227
|
-
|
228
|
-
model.user_shows(username: 'justin', title: 'test')
|
229
|
-
end
|
230
|
-
|
231
|
-
it 'should call params' do
|
232
|
-
model.should_receive(:params).and_return(mock_model)
|
233
|
-
|
234
|
-
model.user_shows(username: 'justin', title: 'test')
|
235
|
-
end
|
236
|
-
|
237
|
-
it 'should call restful_params' do
|
238
|
-
model.should_receive(:restful_params).and_return(mock_model)
|
239
|
-
|
240
|
-
model.user_shows(username: 'justin', title: 'test')
|
241
|
-
end
|
242
|
-
end
|
243
|
-
end
|
data/spec/trakt_api/base_spec.rb
DELETED
@@ -1,140 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
class ExampleClass < TraktApi::Base
|
4
|
-
end
|
5
|
-
|
6
|
-
describe TraktApi::Base do
|
7
|
-
let(:klass) { ExampleClass }
|
8
|
-
let(:model) { klass.new(TraktApi::Client.new) }
|
9
|
-
|
10
|
-
describe '.auth' do
|
11
|
-
it 'should set auth' do
|
12
|
-
model.auth
|
13
|
-
|
14
|
-
model.instance_variable_get('@auth').should == true
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
describe '.store_uri' do
|
19
|
-
it 'should set uri' do
|
20
|
-
model.stub(:api_key).and_return('API_KEY')
|
21
|
-
model.store_uri('http://example.com')
|
22
|
-
|
23
|
-
model.instance_variable_get('@uri').should == 'http://example.com.json/API_KEY'
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
describe '.get' do
|
28
|
-
it 'should call store_uri' do
|
29
|
-
model.should_receive(:store_uri)
|
30
|
-
|
31
|
-
model.get('http://example.com')
|
32
|
-
end
|
33
|
-
|
34
|
-
it 'should set @method to get' do
|
35
|
-
model.get('http://example.com')
|
36
|
-
|
37
|
-
model.instance_variable_get('@method').should == :get
|
38
|
-
end
|
39
|
-
|
40
|
-
it 'should return self' do
|
41
|
-
model.get('http://example.com').should == model
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
describe '.post' do
|
46
|
-
it 'should call store_uri' do
|
47
|
-
model.should_receive(:store_uri)
|
48
|
-
|
49
|
-
model.post('http://example.com')
|
50
|
-
end
|
51
|
-
|
52
|
-
it 'should set @method to post' do
|
53
|
-
model.post('http://example.com')
|
54
|
-
|
55
|
-
model.instance_variable_get('@method').should == :post
|
56
|
-
end
|
57
|
-
|
58
|
-
it 'should return self' do
|
59
|
-
model.post('http://example.com').should == model
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
describe '.params' do
|
64
|
-
it 'should set @params' do
|
65
|
-
model.params(sample: true, auth: true)
|
66
|
-
|
67
|
-
model.instance_variable_get('@params').should == { sample: true }
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
describe '.restful_params' do
|
72
|
-
it 'should return correct uri' do
|
73
|
-
model.instance_variable_set('@uri', 'URI')
|
74
|
-
model.instance_variable_set('@params', { sample: 'test' })
|
75
|
-
|
76
|
-
model.restful_params([:sample])
|
77
|
-
|
78
|
-
model.instance_variable_get('@uri').should == 'URI/test'
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
describe '.response' do
|
83
|
-
it 'should call get klass method' do
|
84
|
-
model.instance_variable_set('@method', :get)
|
85
|
-
klass.should_receive(:get)
|
86
|
-
|
87
|
-
model.response
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
|
-
describe '.request_options' do
|
92
|
-
it 'should return correct keys' do
|
93
|
-
model.request_options.keys.sort.should == [:body].sort
|
94
|
-
end
|
95
|
-
end
|
96
|
-
|
97
|
-
describe '.auth_hash' do
|
98
|
-
it 'should return correct hash' do
|
99
|
-
model = klass.new(TraktApi::Client.new(username: 'tester', password: 'qwerty'))
|
100
|
-
|
101
|
-
model.auth_hash.should == { basic_auth: { username: model.username, password: model.password.to_sha1 } }
|
102
|
-
end
|
103
|
-
end
|
104
|
-
|
105
|
-
describe '.series_uri' do
|
106
|
-
it 'should use default api_key' do
|
107
|
-
klass.new(TraktApi::Client.new(api_key: 'API_KEY')).series_uri('1234').should == 'API_KEY/series/1234/'
|
108
|
-
end
|
109
|
-
end
|
110
|
-
|
111
|
-
describe '.api_key' do
|
112
|
-
it 'should use default api_key' do
|
113
|
-
klass.new(TraktApi::Client.new).api_key.should == TraktApi::Configuration.api_key
|
114
|
-
end
|
115
|
-
|
116
|
-
it 'should set api_key' do
|
117
|
-
klass.new(TraktApi::Client.new(api_key: 'API_KEY')).api_key.should == 'API_KEY'
|
118
|
-
end
|
119
|
-
end
|
120
|
-
|
121
|
-
describe '.username' do
|
122
|
-
it 'should use default username' do
|
123
|
-
klass.new(TraktApi::Client.new).username.should == TraktApi::Configuration.username
|
124
|
-
end
|
125
|
-
|
126
|
-
it 'should set username' do
|
127
|
-
klass.new(TraktApi::Client.new(username: 'USERNAME')).username.should == 'USERNAME'
|
128
|
-
end
|
129
|
-
end
|
130
|
-
|
131
|
-
describe '.password' do
|
132
|
-
it 'should use default password' do
|
133
|
-
klass.new(TraktApi::Client.new).password.should == TraktApi::Configuration.password
|
134
|
-
end
|
135
|
-
|
136
|
-
it 'should set username' do
|
137
|
-
klass.new(TraktApi::Client.new(password: 'PASSWORD')).password.should == 'PASSWORD'
|
138
|
-
end
|
139
|
-
end
|
140
|
-
end
|