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,19 @@
1
+ require 'integration_spec_helper'
2
+
3
+ describe TraktApi::Genres do
4
+ let(:model) { TraktApi::Genres.new(TraktApi::Client.new) }
5
+
6
+ describe 'real request' do
7
+ describe '.movies' do
8
+ it 'should return response class' do
9
+ model.movies.class.should == HTTParty::Response
10
+ end
11
+ end
12
+
13
+ describe '.shows' do
14
+ it 'should return response class' do
15
+ model.shows.class.should == HTTParty::Response
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,25 @@
1
+ require 'integration_spec_helper'
2
+
3
+ describe TraktApi::Movies do
4
+ let(:model) { TraktApi::Movies.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).class.should == HTTParty::Response
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,37 @@
1
+ require 'integration_spec_helper'
2
+
3
+ describe TraktApi::Network do
4
+ let(:model) { TraktApi::Network.new(TraktApi::Client.new) }
5
+
6
+ describe 'real request' do
7
+ describe '.approve' do
8
+ it 'should return response class' do
9
+ model.approve(user: 'justin').class.should == HTTParty::Response
10
+ end
11
+ end
12
+
13
+ describe '.deny' do
14
+ it 'should return response class' do
15
+ model.deny(user: 'justin').class.should == HTTParty::Response
16
+ end
17
+ end
18
+
19
+ describe '.follow' do
20
+ it 'should return response class' do
21
+ model.follow(user: 'justin').class.should == HTTParty::Response
22
+ end
23
+ end
24
+
25
+ describe '.requests' do
26
+ it 'should return response class' do
27
+ model.requests.class.should == HTTParty::Response
28
+ end
29
+ end
30
+
31
+ describe '.unfollow' do
32
+ it 'should return response class' do
33
+ model.unfollow(user: 'justin').class.should == HTTParty::Response
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,37 @@
1
+ require 'integration_spec_helper'
2
+
3
+ describe TraktApi::Search do
4
+ let(:model) { TraktApi::Search.new(TraktApi::Client.new) }
5
+
6
+ describe 'real request' do
7
+ describe '.episodes' do
8
+ it 'should return response class' do
9
+ model.episodes('test').class.should == HTTParty::Response
10
+ end
11
+ end
12
+
13
+ describe '.movies' do
14
+ it 'should return response class' do
15
+ model.movies('test').class.should == HTTParty::Response
16
+ end
17
+ end
18
+
19
+ describe '.people' do
20
+ it 'should return response class' do
21
+ model.people('test').class.should == HTTParty::Response
22
+ end
23
+ end
24
+
25
+ describe '.shows' do
26
+ it 'should return response class' do
27
+ model.shows('test').class.should == HTTParty::Response
28
+ end
29
+ end
30
+
31
+ describe '.users' do
32
+ it 'should return response class' do
33
+ model.users('test').class.should == HTTParty::Response
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,13 @@
1
+ require 'integration_spec_helper'
2
+
3
+ describe TraktApi::Server do
4
+ let(:model) { TraktApi::Server.new(TraktApi::Client.new) }
5
+
6
+ describe 'real request' do
7
+ describe '.time' do
8
+ it 'should return response class' do
9
+ model.time.class.should == HTTParty::Response
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,25 @@
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
@@ -0,0 +1,5 @@
1
+ TraktApi::Configuration.configure do |config|
2
+ config.api_key = ''
3
+ config.username = ''
4
+ config.password = ''
5
+ end
@@ -0,0 +1,43 @@
1
+ require 'rubygems'
2
+ require 'bundler/setup'
3
+ require 'coveralls'
4
+ Coveralls.wear!
5
+
6
+ require 'trakt_api'
7
+
8
+ TraktApi::Configuration.configure do |config|
9
+ config.username = 'tester'
10
+ config.password = 'qwerty'
11
+ end
12
+
13
+ class SampleModel
14
+ def auth
15
+ self
16
+ end
17
+
18
+ def optional_auth(options = {})
19
+ self
20
+ end
21
+
22
+ def get(uri)
23
+ self
24
+ end
25
+
26
+ def post(uri)
27
+ self
28
+ end
29
+
30
+ def params(options = {}, fields = [])
31
+ self
32
+ end
33
+
34
+ def restful_params(options = {}, fields = [])
35
+ self
36
+ end
37
+
38
+ def response
39
+ end
40
+ end
41
+
42
+ RSpec.configure do |config|
43
+ end
@@ -0,0 +1,56 @@
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
@@ -0,0 +1,297 @@
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 optional_auth' do
9
+ model.should_receive(:optional_auth).and_return(mock_model)
10
+
11
+ model.community
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('activity/community').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
+
27
+ it 'should call params' do
28
+ model.should_receive(:params).and_return(mock_model)
29
+
30
+ model.community
31
+ end
32
+ end
33
+
34
+ describe '.episodes' do
35
+ it 'should call optional_auth' do
36
+ model.should_receive(:optional_auth).and_return(mock_model)
37
+
38
+ model.episodes(title: 'test', season: 1, episode: 2)
39
+ end
40
+
41
+ it 'should call get with specific params' do
42
+ model.instance_variable_set("@method", :get)
43
+ model.should_receive(:get).with('activity/episodes').and_return(mock_model)
44
+
45
+ model.episodes(title: 'test', season: 1, episode: 2)
46
+ end
47
+
48
+ it 'should call restful_params' do
49
+ model.should_receive(:restful_params).and_return(mock_model)
50
+
51
+ model.episodes(title: 'test', season: 1, episode: 2)
52
+ end
53
+
54
+ it 'should call params' do
55
+ model.should_receive(:params).and_return(mock_model)
56
+
57
+ model.episodes(title: 'test', season: 1, episode: 2)
58
+ end
59
+ end
60
+
61
+ describe '.friends' do
62
+ it 'should call auth' do
63
+ model.should_receive(:auth).and_return(mock_model)
64
+
65
+ model.friends
66
+ end
67
+
68
+ it 'should call post with specific params' do
69
+ model.instance_variable_set("@method", :post)
70
+ model.should_receive(:post).with('activity/friends').and_return(mock_model)
71
+
72
+ model.friends
73
+ end
74
+
75
+ it 'should call params' do
76
+ model.should_receive(:params).and_return(mock_model)
77
+
78
+ model.friends
79
+ end
80
+ end
81
+
82
+ describe '.movies' do
83
+ it 'should call optional_auth' do
84
+ model.should_receive(:optional_auth).and_return(mock_model)
85
+
86
+ model.movies(title: 'test')
87
+ end
88
+
89
+ it 'should call get with specific params' do
90
+ model.instance_variable_set("@method", :get)
91
+ model.should_receive(:get).with('activity/movies').and_return(mock_model)
92
+
93
+ model.movies(title: 'test')
94
+ end
95
+
96
+ it 'should call restful_params' do
97
+ model.should_receive(:restful_params).and_return(mock_model)
98
+
99
+ model.movies(title: 'test')
100
+ end
101
+
102
+ it 'should call params' do
103
+ model.should_receive(:params).and_return(mock_model)
104
+
105
+ model.movies(title: 'test')
106
+ end
107
+ end
108
+
109
+ describe '.seasons' do
110
+ it 'should call optional_auth' do
111
+ model.should_receive(:optional_auth).and_return(mock_model)
112
+
113
+ model.seasons(title: 'test', season: 1)
114
+ end
115
+
116
+ it 'should call get with specific params' do
117
+ model.instance_variable_set("@method", :get)
118
+ model.should_receive(:get).with('activity/seasons').and_return(mock_model)
119
+
120
+ model.seasons(title: 'test', season: 1)
121
+ end
122
+
123
+ it 'should call restful_params' do
124
+ model.should_receive(:restful_params).and_return(mock_model)
125
+
126
+ model.seasons(title: 'test', season: 1)
127
+ end
128
+
129
+ it 'should call params' do
130
+ model.should_receive(:params).and_return(mock_model)
131
+
132
+ model.seasons(title: 'test', season: 1)
133
+ end
134
+ end
135
+
136
+ describe '.shows' do
137
+ it 'should call optional_auth' do
138
+ model.should_receive(:optional_auth).and_return(mock_model)
139
+
140
+ model.shows(title: 'test')
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('activity/shows').and_return(mock_model)
146
+
147
+ model.shows(title: 'test')
148
+ end
149
+
150
+ it 'should call restful_params' do
151
+ model.should_receive(:restful_params).and_return(mock_model)
152
+
153
+ model.shows(title: 'test')
154
+ end
155
+
156
+ it 'should call params' do
157
+ model.should_receive(:params).and_return(mock_model)
158
+
159
+ model.shows(title: 'test')
160
+ end
161
+ end
162
+
163
+ describe '.user' do
164
+ it 'should call optional_auth' do
165
+ model.should_receive(:optional_auth).and_return(mock_model)
166
+
167
+ model.user(username: 'test')
168
+ end
169
+
170
+ it 'should call get with specific params' do
171
+ model.instance_variable_set("@method", :get)
172
+ model.should_receive(:get).with('activity/user').and_return(mock_model)
173
+
174
+ model.user(username: 'test')
175
+ end
176
+
177
+ it 'should call restful_params' do
178
+ model.should_receive(:restful_params).and_return(mock_model)
179
+
180
+ model.user(username: 'test')
181
+ end
182
+
183
+ it 'should call params' do
184
+ model.should_receive(:params).and_return(mock_model)
185
+
186
+ model.user(username: 'test')
187
+ end
188
+ end
189
+
190
+ describe '.user_episodes' do
191
+ it 'should call optional_auth' do
192
+ model.should_receive(:optional_auth).and_return(mock_model)
193
+
194
+ model.user_episodes(username: 'justin', title: 'test', season: 1, episode: 2)
195
+ end
196
+
197
+ it 'should call get with specific params' do
198
+ model.instance_variable_set("@method", :get)
199
+ model.should_receive(:get).with('activity/user/episodes').and_return(mock_model)
200
+
201
+ model.user_episodes(username: 'justin', title: 'test', season: 1, episode: 2)
202
+ end
203
+
204
+ it 'should call restful_params' do
205
+ model.should_receive(:restful_params).and_return(mock_model)
206
+
207
+ model.user_episodes(username: 'justin', title: 'test', season: 1, episode: 2)
208
+ end
209
+
210
+ it 'should call params' do
211
+ model.should_receive(:params).and_return(mock_model)
212
+
213
+ model.user_episodes(username: 'justin', title: 'test', season: 1, episode: 2)
214
+ end
215
+ end
216
+
217
+ describe '.user_movies' do
218
+ it 'should call optional_auth' do
219
+ model.should_receive(:optional_auth).and_return(mock_model)
220
+
221
+ model.user_movies(username: 'justin', title: 'test')
222
+ end
223
+
224
+ it 'should call get with specific params' do
225
+ model.instance_variable_set("@method", :get)
226
+ model.should_receive(:get).with('activity/user/movies').and_return(mock_model)
227
+
228
+ model.user_movies(username: 'justin', title: 'test')
229
+ end
230
+
231
+ it 'should call restful_params' do
232
+ model.should_receive(:restful_params).and_return(mock_model)
233
+
234
+ model.user_movies(username: 'justin', title: 'test')
235
+ end
236
+
237
+ it 'should call params' do
238
+ model.should_receive(:params).and_return(mock_model)
239
+
240
+ model.user_movies(username: 'justin', title: 'test')
241
+ end
242
+ end
243
+
244
+ describe '.user_seasons' do
245
+ it 'should call optional_auth' do
246
+ model.should_receive(:optional_auth).and_return(mock_model)
247
+
248
+ model.user_seasons(username: 'justin', title: 'test', season: 1)
249
+ end
250
+
251
+ it 'should call get with specific params' do
252
+ model.instance_variable_set("@method", :get)
253
+ model.should_receive(:get).with('activity/user/seasons').and_return(mock_model)
254
+
255
+ model.user_seasons(username: 'justin', title: 'test', season: 1)
256
+ end
257
+
258
+ it 'should call restful_params' do
259
+ model.should_receive(:restful_params).and_return(mock_model)
260
+
261
+ model.user_seasons(username: 'justin', title: 'test', season: 1)
262
+ end
263
+
264
+ it 'should call params' do
265
+ model.should_receive(:params).and_return(mock_model)
266
+
267
+ model.user_seasons(username: 'justin', title: 'test', season: 1)
268
+ end
269
+ end
270
+
271
+ describe '.user_shows' do
272
+ it 'should call optional_auth' do
273
+ model.should_receive(:optional_auth).and_return(mock_model)
274
+
275
+ model.user_shows(username: 'justin', title: 'test')
276
+ end
277
+
278
+ it 'should call get with specific params' do
279
+ model.instance_variable_set("@method", :get)
280
+ model.should_receive(:get).with('activity/user/shows').and_return(mock_model)
281
+
282
+ model.user_shows(username: 'justin', title: 'test')
283
+ end
284
+
285
+ it 'should call restful_params' do
286
+ model.should_receive(:restful_params).and_return(mock_model)
287
+
288
+ model.user_shows(username: 'justin', title: 'test')
289
+ end
290
+
291
+ it 'should call params' do
292
+ model.should_receive(:params).and_return(mock_model)
293
+
294
+ model.user_shows(username: 'justin', title: 'test')
295
+ end
296
+ end
297
+ end