trakt_api 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +19 -0
  3. data/.travis.yml +4 -0
  4. data/Gemfile +4 -0
  5. data/LICENSE.txt +22 -0
  6. data/README.md +252 -0
  7. data/Rakefile +1 -0
  8. data/lib/generators/templates/trakt_api.rb +5 -0
  9. data/lib/generators/trakt_api/install_generator.rb +12 -0
  10. data/lib/trakt_api.rb +22 -0
  11. data/lib/trakt_api/account.rb +16 -0
  12. data/lib/trakt_api/activity.rb +109 -0
  13. data/lib/trakt_api/base.rb +93 -0
  14. data/lib/trakt_api/calendar.rb +17 -0
  15. data/lib/trakt_api/client.rb +74 -0
  16. data/lib/trakt_api/comment.rb +16 -0
  17. data/lib/trakt_api/configuration.rb +7 -0
  18. data/lib/trakt_api/genres.rb +11 -0
  19. data/lib/trakt_api/lists.rb +26 -0
  20. data/lib/trakt_api/movie.rb +86 -0
  21. data/lib/trakt_api/movies.rb +11 -0
  22. data/lib/trakt_api/network.rb +26 -0
  23. data/lib/trakt_api/rate.rb +31 -0
  24. data/lib/trakt_api/recommendations.rb +21 -0
  25. data/lib/trakt_api/search.rb +26 -0
  26. data/lib/trakt_api/server.rb +6 -0
  27. data/lib/trakt_api/show.rb +152 -0
  28. data/lib/trakt_api/shows.rb +11 -0
  29. data/lib/trakt_api/user.rb +124 -0
  30. data/lib/trakt_api/version.rb +3 -0
  31. data/spec/integration_spec_helper.rb +3 -0
  32. data/spec/integrations/account_spec.rb +19 -0
  33. data/spec/integrations/calendar_spec.rb +31 -0
  34. data/spec/integrations/client_spec.rb +173 -0
  35. data/spec/integrations/genres_spec.rb +19 -0
  36. data/spec/integrations/movies_spec.rb +25 -0
  37. data/spec/integrations/network_spec.rb +37 -0
  38. data/spec/integrations/search_spec.rb +37 -0
  39. data/spec/integrations/server_spec.rb +13 -0
  40. data/spec/integrations/shows_spec.rb +25 -0
  41. data/spec/integrations/support/trakt_api.rb.example +5 -0
  42. data/spec/spec_helper.rb +43 -0
  43. data/spec/trakt_api/account_spec.rb +56 -0
  44. data/spec/trakt_api/activity_spec.rb +297 -0
  45. data/spec/trakt_api/base_spec.rb +147 -0
  46. data/spec/trakt_api/calendar_spec.rb +48 -0
  47. data/spec/trakt_api/client_spec.rb +101 -0
  48. data/spec/trakt_api/comment_spec.rb +69 -0
  49. data/spec/trakt_api/genres_spec.rb +24 -0
  50. data/spec/trakt_api/lists_spec.rb +111 -0
  51. data/spec/trakt_api/movie_spec.rb +333 -0
  52. data/spec/trakt_api/movies_spec.rb +38 -0
  53. data/spec/trakt_api/network_spec.rb +105 -0
  54. data/spec/trakt_api/rate_spec.rb +132 -0
  55. data/spec/trakt_api/recommendations_spec.rb +90 -0
  56. data/spec/trakt_api/search_spec.rb +81 -0
  57. data/spec/trakt_api/server_spec.rb +15 -0
  58. data/spec/trakt_api/show_spec.rb +588 -0
  59. data/spec/trakt_api/shows_spec.rb +38 -0
  60. data/spec/trakt_api/user_spec.rb +561 -0
  61. data/trakt_api.gemspec +29 -0
  62. metadata +232 -0
@@ -0,0 +1,333 @@
1
+ require 'spec_helper'
2
+
3
+ describe TraktApi::Movie do
4
+ let(:model) { TraktApi::Movie.new(TraktApi::Client.new) }
5
+ let(:mock_model) { SampleModel.new }
6
+
7
+ describe '.cancel_checkin' do
8
+ it 'should call auth' do
9
+ model.should_receive(:auth).and_return(mock_model)
10
+
11
+ model.cancel_checkin
12
+ end
13
+
14
+ it 'should call post with specific params' do
15
+ model.instance_variable_set("@method", :post)
16
+ model.should_receive(:post).with('movie/cancelcheckin').and_return(mock_model)
17
+
18
+ model.cancel_checkin
19
+ end
20
+ end
21
+
22
+ describe '.cancel_watching' do
23
+ it 'should call auth' do
24
+ model.should_receive(:auth).and_return(mock_model)
25
+
26
+ model.cancel_watching
27
+ end
28
+
29
+ it 'should call post with specific params' do
30
+ model.instance_variable_set("@method", :post)
31
+ model.should_receive(:post).with('movie/cancelwatching').and_return(mock_model)
32
+
33
+ model.cancel_watching
34
+ end
35
+ end
36
+
37
+ describe '.checkin' do
38
+ it 'should call auth' do
39
+ model.should_receive(:auth).and_return(mock_model)
40
+
41
+ model.checkin(sample: true)
42
+ end
43
+
44
+ it 'should call post with specific params' do
45
+ model.instance_variable_set("@method", :post)
46
+ model.should_receive(:post).with('movie/checkin').and_return(mock_model)
47
+
48
+ model.checkin(sample: true)
49
+ end
50
+
51
+ it 'should call params' do
52
+ model.should_receive(:params).and_return(mock_model)
53
+
54
+ model.checkin(sample: true)
55
+ end
56
+ end
57
+
58
+ describe '.comments' do
59
+ it 'should call get with specific params' do
60
+ model.instance_variable_set("@method", :get)
61
+ model.should_receive(:get).with('movie/comments').and_return(mock_model)
62
+
63
+ model.comments(title: 'TITLE', type: 'TYPE')
64
+ end
65
+
66
+ it 'should call restful_params' do
67
+ model.should_receive(:restful_params).and_return(mock_model)
68
+
69
+ model.comments(title: 'TITLE', type: 'TYPE')
70
+ end
71
+ end
72
+
73
+ describe '.scrobble' do
74
+ it 'should call auth' do
75
+ model.should_receive(:auth).and_return(mock_model)
76
+
77
+ model.scrobble(sample: true)
78
+ end
79
+
80
+ it 'should call post with specific params' do
81
+ model.instance_variable_set("@method", :post)
82
+ model.should_receive(:post).with('movie/scrobble').and_return(mock_model)
83
+
84
+ model.scrobble(sample: true)
85
+ end
86
+
87
+ it 'should call params' do
88
+ model.should_receive(:params).and_return(mock_model)
89
+
90
+ model.scrobble(sample: true)
91
+ end
92
+ end
93
+
94
+ describe '.seen' do
95
+ it 'should call auth' do
96
+ model.should_receive(:auth).and_return(mock_model)
97
+
98
+ model.seen(sample: true)
99
+ end
100
+
101
+ it 'should call post with specific params' do
102
+ model.instance_variable_set("@method", :post)
103
+ model.should_receive(:post).with('movie/seen').and_return(mock_model)
104
+
105
+ model.seen(sample: true)
106
+ end
107
+
108
+ it 'should call params' do
109
+ model.should_receive(:params).and_return(mock_model)
110
+
111
+ model.seen(sample: true)
112
+ end
113
+ end
114
+
115
+ describe '.library' do
116
+ it 'should call auth' do
117
+ model.should_receive(:auth).and_return(mock_model)
118
+
119
+ model.library(sample: true)
120
+ end
121
+
122
+ it 'should call post with specific params' do
123
+ model.instance_variable_set("@method", :post)
124
+ model.should_receive(:post).with('movie/library').and_return(mock_model)
125
+
126
+ model.library(sample: true)
127
+ end
128
+
129
+ it 'should call params' do
130
+ model.should_receive(:params).and_return(mock_model)
131
+
132
+ model.library(sample: true)
133
+ end
134
+ end
135
+
136
+ describe '.related' do
137
+ it 'should call optional_auth' do
138
+ model.should_receive(:optional_auth).and_return(mock_model)
139
+
140
+ model.related(title: 'TITLE', hidewatched: 'HIDEWATCH')
141
+ end
142
+
143
+ it 'should call get with specific params' do
144
+ model.instance_variable_set("@method", :get)
145
+ model.should_receive(:get).with('movie/related').and_return(mock_model)
146
+
147
+ model.related(title: 'TITLE', hidewatched: 'HIDEWATCH')
148
+ end
149
+
150
+ it 'should call restful_params' do
151
+ model.should_receive(:restful_params).and_return(mock_model)
152
+
153
+ model.related(title: 'TITLE', hidewatched: 'HIDEWATCH')
154
+ end
155
+ end
156
+
157
+ describe '.stats' do
158
+ it 'should call get with specific params' do
159
+ model.instance_variable_set("@method", :get)
160
+ model.should_receive(:get).with('movie/stats').and_return(mock_model)
161
+
162
+ model.stats(title: 'TITLE')
163
+ end
164
+
165
+ it 'should call restful_params' do
166
+ model.should_receive(:restful_params).and_return(mock_model)
167
+
168
+ model.stats(title: 'TITLE')
169
+ end
170
+ end
171
+
172
+ describe '.summary' do
173
+ it 'should call optional_auth' do
174
+ model.should_receive(:optional_auth).and_return(mock_model)
175
+
176
+ model.summary(title: 'TITLE')
177
+ end
178
+
179
+ it 'should call get with specific params' do
180
+ model.instance_variable_set("@method", :get)
181
+ model.should_receive(:get).with('movie/summary').and_return(mock_model)
182
+
183
+ model.summary(title: 'TITLE')
184
+ end
185
+
186
+ it 'should call restful_params' do
187
+ model.should_receive(:restful_params).and_return(mock_model)
188
+
189
+ model.summary(title: 'TITLE')
190
+ end
191
+ end
192
+
193
+ describe '.summaries' do
194
+ it 'should call get with specific params' do
195
+ model.instance_variable_set("@method", :get)
196
+ model.should_receive(:get).with('movie/summaries').and_return(mock_model)
197
+
198
+ model.summaries(title: 'TITLE', extended: 'EXTENDED')
199
+ end
200
+
201
+ it 'should call restful_params' do
202
+ model.should_receive(:restful_params).and_return(mock_model)
203
+
204
+ model.summaries(title: 'TITLE', extended: 'EXTENDED')
205
+ end
206
+ end
207
+
208
+ describe '.unlibrary' do
209
+ it 'should call auth' do
210
+ model.should_receive(:auth).and_return(mock_model)
211
+
212
+ model.unlibrary(sample: true)
213
+ end
214
+
215
+ it 'should call post with specific params' do
216
+ model.instance_variable_set("@method", :post)
217
+ model.should_receive(:post).with('movie/unlibrary').and_return(mock_model)
218
+
219
+ model.unlibrary(sample: true)
220
+ end
221
+
222
+ it 'should call params' do
223
+ model.should_receive(:params).and_return(mock_model)
224
+
225
+ model.unlibrary(sample: true)
226
+ end
227
+ end
228
+
229
+ describe '.unseen' do
230
+ it 'should call auth' do
231
+ model.should_receive(:auth).and_return(mock_model)
232
+
233
+ model.unseen(sample: true)
234
+ end
235
+
236
+ it 'should call post with specific params' do
237
+ model.instance_variable_set("@method", :post)
238
+ model.should_receive(:post).with('movie/unseen').and_return(mock_model)
239
+
240
+ model.unseen(sample: true)
241
+ end
242
+
243
+ it 'should call params' do
244
+ model.should_receive(:params).and_return(mock_model)
245
+
246
+ model.unseen(sample: true)
247
+ end
248
+ end
249
+
250
+ describe '.unwatch_list' do
251
+ it 'should call auth' do
252
+ model.should_receive(:auth).and_return(mock_model)
253
+
254
+ model.unwatch_list(sample: true)
255
+ end
256
+
257
+ it 'should call post with specific params' do
258
+ model.instance_variable_set("@method", :post)
259
+ model.should_receive(:post).with('movie/unwatchlist').and_return(mock_model)
260
+
261
+ model.unwatch_list(sample: true)
262
+ end
263
+
264
+ it 'should call params' do
265
+ model.should_receive(:params).and_return(mock_model)
266
+
267
+ model.unwatch_list(sample: true)
268
+ end
269
+ end
270
+
271
+ describe '.watching' do
272
+ it 'should call auth' do
273
+ model.should_receive(:auth).and_return(mock_model)
274
+
275
+ model.watching(sample: true)
276
+ end
277
+
278
+ it 'should call post with specific params' do
279
+ model.instance_variable_set("@method", :post)
280
+ model.should_receive(:post).with('movie/watching').and_return(mock_model)
281
+
282
+ model.watching(sample: true)
283
+ end
284
+
285
+ it 'should call params' do
286
+ model.should_receive(:params).and_return(mock_model)
287
+
288
+ model.watching(sample: true)
289
+ end
290
+ end
291
+
292
+ describe '.watching_now' do
293
+ it 'should call optional_auth' do
294
+ model.should_receive(:optional_auth).and_return(mock_model)
295
+
296
+ model.watching_now(title: 'TITLE')
297
+ end
298
+
299
+ it 'should call get with specific params' do
300
+ model.instance_variable_set("@method", :get)
301
+ model.should_receive(:get).with('movie/watchingnow').and_return(mock_model)
302
+
303
+ model.watching_now(title: 'TITLE')
304
+ end
305
+
306
+ it 'should call restful_params' do
307
+ model.should_receive(:restful_params).and_return(mock_model)
308
+
309
+ model.watching_now(title: 'TITLE')
310
+ end
311
+ end
312
+
313
+ describe '.watch_list' do
314
+ it 'should call auth' do
315
+ model.should_receive(:auth).and_return(mock_model)
316
+
317
+ model.watch_list(sample: true)
318
+ end
319
+
320
+ it 'should call post with specific params' do
321
+ model.instance_variable_set("@method", :post)
322
+ model.should_receive(:post).with('movie/watchlist').and_return(mock_model)
323
+
324
+ model.watch_list(sample: true)
325
+ end
326
+
327
+ it 'should call params' do
328
+ model.should_receive(:params).and_return(mock_model)
329
+
330
+ model.watch_list(sample: true)
331
+ end
332
+ end
333
+ end
@@ -0,0 +1,38 @@
1
+ require 'spec_helper'
2
+
3
+ describe TraktApi::Movies do
4
+ let(:model) { TraktApi::Movies.new(TraktApi::Client.new) }
5
+ let(:mock_model) { SampleModel.new }
6
+
7
+ describe '.trending' do
8
+ it 'should call optional_auth' do
9
+ model.should_receive(:optional_auth).and_return(mock_model)
10
+
11
+ model.trending
12
+ end
13
+
14
+ it 'should call get with specific params' do
15
+ model.instance_variable_set("@method", :get)
16
+ model.should_receive(:get).with('movies/trending').and_return(mock_model)
17
+
18
+ model.trending
19
+ end
20
+ end
21
+
22
+ describe '.updated' do
23
+ let(:time) { Time.now.to_i }
24
+
25
+ it 'should call get with specific params' do
26
+ model.instance_variable_set("@method", :get)
27
+ model.should_receive(:get).with('movies/updated').and_return(mock_model)
28
+
29
+ model.updated(time: time)
30
+ end
31
+
32
+ it 'should call restful_params' do
33
+ model.should_receive(:restful_params).and_return(mock_model)
34
+
35
+ model.updated(time: time)
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,105 @@
1
+ require 'spec_helper'
2
+
3
+ describe TraktApi::Network do
4
+ let(:model) { TraktApi::Network.new(TraktApi::Client.new) }
5
+ let(:mock_model) { SampleModel.new }
6
+
7
+ describe '.approve' do
8
+ it 'should call auth' do
9
+ model.should_receive(:auth).and_return(mock_model)
10
+
11
+ model.approve(user: 'justin', follow_back: true)
12
+ end
13
+
14
+ it 'should call post with specific params' do
15
+ model.instance_variable_set("@method", :post)
16
+ model.should_receive(:post).with('network/approve').and_return(mock_model)
17
+
18
+ model.approve(user: 'justin', follow_back: true)
19
+ end
20
+
21
+ it 'should call params' do
22
+ model.should_receive(:params).and_return(mock_model)
23
+
24
+ model.approve(user: 'justin', follow_back: true)
25
+ end
26
+ end
27
+
28
+ describe '.deny' do
29
+ it 'should call auth' do
30
+ model.should_receive(:auth).and_return(mock_model)
31
+
32
+ model.deny(user: 'justin')
33
+ end
34
+
35
+ it 'should call post with specific params' do
36
+ model.instance_variable_set("@method", :post)
37
+ model.should_receive(:post).with('network/deny').and_return(mock_model)
38
+
39
+ model.deny(user: 'justin')
40
+ end
41
+
42
+ it 'should call params' do
43
+ model.should_receive(:params).and_return(mock_model)
44
+
45
+ model.deny(user: 'justin')
46
+ end
47
+ end
48
+
49
+ describe '.follow' do
50
+ it 'should call auth' do
51
+ model.should_receive(:auth).and_return(mock_model)
52
+
53
+ model.follow(user: 'justin')
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('network/follow').and_return(mock_model)
59
+
60
+ model.follow(user: 'justin')
61
+ end
62
+
63
+ it 'should call params' do
64
+ model.should_receive(:params).and_return(mock_model)
65
+
66
+ model.follow(user: 'justin')
67
+ end
68
+ end
69
+
70
+ describe '.requests' do
71
+ it 'should call auth' do
72
+ model.should_receive(:auth).and_return(mock_model)
73
+
74
+ model.requests
75
+ end
76
+
77
+ it 'should call post with specific params' do
78
+ model.instance_variable_set("@method", :post)
79
+ model.should_receive(:post).with('network/requests').and_return(mock_model)
80
+
81
+ model.requests
82
+ end
83
+ end
84
+
85
+ describe '.unfollow' do
86
+ it 'should call auth' do
87
+ model.should_receive(:auth).and_return(mock_model)
88
+
89
+ model.unfollow(user: 'justin')
90
+ end
91
+
92
+ it 'should call post with specific params' do
93
+ model.instance_variable_set("@method", :post)
94
+ model.should_receive(:post).with('network/unfollow').and_return(mock_model)
95
+
96
+ model.unfollow(user: 'justin')
97
+ end
98
+
99
+ it 'should call params' do
100
+ model.should_receive(:params).and_return(mock_model)
101
+
102
+ model.unfollow(user: 'justin')
103
+ end
104
+ end
105
+ end