tmsapi 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +86 -0
- data/.project +17 -0
- data/.rspec +2 -0
- data/.travis.yml +11 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +94 -0
- data/Rakefile +14 -0
- data/Readme.md +62 -0
- data/lib/tmsapi/api.rb +61 -0
- data/lib/tmsapi/middleware/custom_logger.rb +70 -0
- data/lib/tmsapi/model/airing.rb +24 -0
- data/lib/tmsapi/model/award.rb +14 -0
- data/lib/tmsapi/model/base.rb +9 -0
- data/lib/tmsapi/model/caption.rb +8 -0
- data/lib/tmsapi/model/episode.rb +11 -0
- data/lib/tmsapi/model/event.rb +10 -0
- data/lib/tmsapi/model/image.rb +16 -0
- data/lib/tmsapi/model/lineup.rb +12 -0
- data/lib/tmsapi/model/movie.rb +16 -0
- data/lib/tmsapi/model/person.rb +12 -0
- data/lib/tmsapi/model/program.rb +36 -0
- data/lib/tmsapi/model/quality_rating.rb +8 -0
- data/lib/tmsapi/model/rating.rb +8 -0
- data/lib/tmsapi/model/recommendation.rb +9 -0
- data/lib/tmsapi/model/showtime.rb +13 -0
- data/lib/tmsapi/model/sport_event.rb +11 -0
- data/lib/tmsapi/model/station.rb +19 -0
- data/lib/tmsapi/model/station_airings.rb +14 -0
- data/lib/tmsapi/model/team.rb +9 -0
- data/lib/tmsapi/model/theatre.rb +8 -0
- data/lib/tmsapi/model.rb +26 -0
- data/lib/tmsapi/resource/base.rb +20 -0
- data/lib/tmsapi/resource/lineups.rb +58 -0
- data/lib/tmsapi/resource/movies.rb +21 -0
- data/lib/tmsapi/resource/movies_theatres.rb +37 -0
- data/lib/tmsapi/resource/movies_tv.rb +41 -0
- data/lib/tmsapi/resource/programs.rb +103 -0
- data/lib/tmsapi/resource/series.rb +45 -0
- data/lib/tmsapi/resource/sports.rb +35 -0
- data/lib/tmsapi/resource/stations.rb +47 -0
- data/lib/tmsapi/resource.rb +13 -0
- data/lib/tmsapi/version.rb +3 -0
- data/lib/tmsapi.rb +10 -0
- data/spec/api_spec.rb +354 -0
- data/spec/factories.rb +56 -0
- data/spec/model/program_spec.rb +33 -0
- data/spec/spec_helper.rb +45 -0
- data/spec/support/vcr.rb +20 -0
- data/spec/tms_api_spec.rb +7 -0
- data/spec/vcr/cassettes/TMSAPI_API/_lineups/_airings/should_tell_me_whats_airing.yml +37649 -0
- data/spec/vcr/cassettes/TMSAPI_API/_lineups/_channels/should_list_some_channels.yml +2623 -0
- data/spec/vcr/cassettes/TMSAPI_API/_lineups/_details/should_tell_me_about_the_lineup.yml +67 -0
- data/spec/vcr/cassettes/TMSAPI_API/_lineups/_find/should_find_local_lineups.yml +103 -0
- data/spec/vcr/cassettes/TMSAPI_API/_lineups/_stations/should_list_some_channels.yml +2623 -0
- data/spec/vcr/cassettes/TMSAPI_API/_movies/_theatres/_showings/should_get_movie_showings.yml +460 -0
- data/spec/vcr/cassettes/TMSAPI_API/_movies/_tv/_airings/should_tell_me_what_movies_are_on_tv.yml +6722 -0
- data/spec/vcr/cassettes/TMSAPI_API/_movies/_tv/_versions/should_tell_me_about_that_movie.yml +1366 -0
- data/spec/vcr/cassettes/TMSAPI_API/_programs/_advance_planner/should_list_holiday_events.yml +1951 -0
- data/spec/vcr/cassettes/TMSAPI_API/_programs/_airings/should_find_airings.yml +85 -0
- data/spec/vcr/cassettes/TMSAPI_API/_programs/_details/should_be_filled_with_program_information.yml +117 -0
- data/spec/vcr/cassettes/TMSAPI_API/_programs/_genres/should_return_all_genres.yml +131 -0
- data/spec/vcr/cassettes/TMSAPI_API/_programs/_images/should_return_images.yml +225 -0
- data/spec/vcr/cassettes/TMSAPI_API/_programs/_new_past_week/should_have_programs.yml +2238 -0
- data/spec/vcr/cassettes/TMSAPI_API/_programs/_new_shows/should_find_new_shows.yml +1105 -0
- data/spec/vcr/cassettes/TMSAPI_API/_programs/_search/should_find_4_programs.yml +152 -0
- data/spec/vcr/cassettes/TMSAPI_API/_series/_airings/should_list_airings.yml +341 -0
- data/spec/vcr/cassettes/TMSAPI_API/_series/_details/should_find_the_series.yml +272 -0
- data/spec/vcr/cassettes/TMSAPI_API/_series/_episodes/should_return_episodes.yml +3492 -0
- data/spec/vcr/cassettes/TMSAPI_API/_stations/_airings/should_list_airings.yml +123 -0
- data/spec/vcr/cassettes/TMSAPI_API/_stations/_details/should_get_station_details.yml +67 -0
- data/tmsapi.gemspec +42 -0
- metadata +296 -0
data/spec/api_spec.rb
ADDED
@@ -0,0 +1,354 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe TMSAPI::API, :vcr do
|
4
|
+
subject { client = TMSAPI::API.new :api_key => api_key, :debug => false}
|
5
|
+
let(:api_key) { API_KEY }
|
6
|
+
|
7
|
+
describe '#programs' do
|
8
|
+
|
9
|
+
describe '#search' do
|
10
|
+
|
11
|
+
let(:programs) {
|
12
|
+
subject.programs.search({ :q => "The Amazing World of Gumball", :queryFields => "title", :entityType => "show"})
|
13
|
+
}
|
14
|
+
|
15
|
+
it 'should find 4 programs' do
|
16
|
+
programs.count.should be >= 4
|
17
|
+
programs.first.respond_to?(:tms_id).should be_true
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe '#details' do
|
22
|
+
|
23
|
+
let(:details) {
|
24
|
+
subject.programs.details("SH014122930000")
|
25
|
+
}
|
26
|
+
|
27
|
+
it 'should be filled with program information' do
|
28
|
+
details.ratings.count.should be >= 1
|
29
|
+
details.ratings.first.respond_to?(:body).should be_true
|
30
|
+
|
31
|
+
details.respond_to?(:title).should be_true
|
32
|
+
details.respond_to?(:long_description).should be_true
|
33
|
+
details.respond_to?(:ratings).should be_true
|
34
|
+
details.ratings.count.should be >= 1
|
35
|
+
details.ratings.first.respond_to?(:body).should be_true
|
36
|
+
details.ratings.first.respond_to?(:code).should be_true
|
37
|
+
details.respond_to?(:series_id).should be_true
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
|
42
|
+
describe '#airings' do
|
43
|
+
let(:airings) {
|
44
|
+
subject.programs.airings("SH014122930000", { :lineupId => "USA-NY31586-X", :startDateTime => "2013-12-21T17:30Z" })
|
45
|
+
}
|
46
|
+
|
47
|
+
it 'should find airings' do
|
48
|
+
airings.count.should be >= 0
|
49
|
+
|
50
|
+
airings.first.respond_to?(:start_time).should be_true
|
51
|
+
airings.first.respond_to?(:duration).should be_true
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
describe '#new_shows' do
|
56
|
+
let(:new_program_airings) {
|
57
|
+
subject.programs.new_shows({:startDateTime => "2013-12-21T13:34Z", :lineupId => "USA-NY31586-X"})
|
58
|
+
}
|
59
|
+
|
60
|
+
it 'should find new shows' do
|
61
|
+
new_program_airings.count.should be >= 10
|
62
|
+
|
63
|
+
new_program_airings.first.respond_to?(:program)
|
64
|
+
new_program_airings.first.program.respond_to?(:tms_id)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
describe '#new_past_week' do
|
69
|
+
let(:new_programs) {
|
70
|
+
subject.programs.new_past_week({:startDate => "2013-12-21", :endDate => "2013-12-21"})
|
71
|
+
}
|
72
|
+
|
73
|
+
it 'should have programs' do
|
74
|
+
new_programs.count.should be >= 10
|
75
|
+
|
76
|
+
new_programs.first.respond_to?(:tms_id).should be_true
|
77
|
+
new_programs.first.respond_to?(:long_description).should be_true
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
describe '#advance_planner' do
|
82
|
+
let(:events) {
|
83
|
+
subject.programs.advance_planner({:startDate => "2013-12-22"})
|
84
|
+
}
|
85
|
+
|
86
|
+
it 'should list holiday events' do
|
87
|
+
events.count.should be >= 10
|
88
|
+
|
89
|
+
events.first.respond_to?(:air_date).should be_true
|
90
|
+
events.first.respond_to?(:program).should be_true
|
91
|
+
events.first.program.respond_to?(:tms_id).should be_true
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
describe '#images' do
|
96
|
+
let(:images) {
|
97
|
+
subject.programs.images("SH014122930000")
|
98
|
+
}
|
99
|
+
|
100
|
+
it 'should return images' do
|
101
|
+
images.count.should be >= 5
|
102
|
+
images.first.respond_to?(:uri).should be_true
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
describe '#genres' do
|
107
|
+
let (:genres) {
|
108
|
+
subject.programs.genres
|
109
|
+
}
|
110
|
+
|
111
|
+
it 'should return all genres' do
|
112
|
+
genres.count.should be >= 10
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
end
|
117
|
+
|
118
|
+
describe '#stations' do
|
119
|
+
|
120
|
+
describe '#details' do
|
121
|
+
let(:stations) {
|
122
|
+
subject.stations.details("10359")
|
123
|
+
}
|
124
|
+
|
125
|
+
it 'should get station details' do
|
126
|
+
stations.count.should be >= 1
|
127
|
+
|
128
|
+
stations.first.respond_to?(:station_id).should be_true
|
129
|
+
stations.first.respond_to?(:name).should be_true
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
describe '#airings' do
|
134
|
+
let(:airings) {
|
135
|
+
subject.stations.airings("10359", {:startDateTime => "2013-12-21T18:30Z"})
|
136
|
+
}
|
137
|
+
|
138
|
+
it 'should list airings' do
|
139
|
+
airings.count.should be >= 4
|
140
|
+
|
141
|
+
airings.first.respond_to?(:station_id).should be_true
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
end
|
146
|
+
|
147
|
+
describe '#lineups' do
|
148
|
+
|
149
|
+
describe '#find' do
|
150
|
+
let(:lineups) {
|
151
|
+
subject.lineups.find({:postalCode => "12804"})
|
152
|
+
}
|
153
|
+
|
154
|
+
it 'should find local lineups' do
|
155
|
+
lineups.count.should be >= 15
|
156
|
+
|
157
|
+
lineups.last.respond_to?(:lineup_id).should be_true
|
158
|
+
lineups.last.respond_to?(:name).should be_true
|
159
|
+
lineups.last.respond_to?(:location).should be_true
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
describe '#details' do
|
164
|
+
let(:lineup) {
|
165
|
+
subject.lineups.details("USA-NY31586-X")
|
166
|
+
}
|
167
|
+
|
168
|
+
it 'should tell me about the lineup' do
|
169
|
+
lineup.respond_to?(:type).should be_true
|
170
|
+
lineup.respond_to?(:name).should be_true
|
171
|
+
end
|
172
|
+
|
173
|
+
end
|
174
|
+
|
175
|
+
describe '#channels' do
|
176
|
+
let(:channels) {
|
177
|
+
subject.lineups.channels("USA-NY31586-X")
|
178
|
+
}
|
179
|
+
|
180
|
+
it 'should list some channels' do
|
181
|
+
channels.count.should be >= 3
|
182
|
+
|
183
|
+
channels.first.respond_to?(:preferred_image).should be_true
|
184
|
+
channels.first.preferred_image.respond_to?(:uri).should be_true
|
185
|
+
channels.first.respond_to?(:call_sign).should be_true
|
186
|
+
end
|
187
|
+
end
|
188
|
+
|
189
|
+
describe '#stations' do
|
190
|
+
let(:stations) {
|
191
|
+
subject.lineups.stations("USA-NY31586-X")
|
192
|
+
}
|
193
|
+
|
194
|
+
it 'should list some channels' do
|
195
|
+
stations.count.should be >= 3
|
196
|
+
|
197
|
+
stations.first.respond_to?(:preferred_image).should be_true
|
198
|
+
stations.first.preferred_image.respond_to?(:uri).should be_true
|
199
|
+
stations.first.respond_to?(:call_sign).should be_true
|
200
|
+
end
|
201
|
+
end
|
202
|
+
|
203
|
+
describe '#airings' do
|
204
|
+
let (:station_airings) {
|
205
|
+
subject.lineups.airings("USA-NY31586-X", { :startDateTime => "2013-12-21T23:10Z" })
|
206
|
+
}
|
207
|
+
|
208
|
+
it 'should tell me whats airing' do
|
209
|
+
station_airings.count.should be >= 10
|
210
|
+
|
211
|
+
station_airings.first.respond_to?(:channel).should be_true
|
212
|
+
station_airings.first.respond_to?(:call_sign).should be_true
|
213
|
+
station_airings.first.respond_to?(:airings).should be_true
|
214
|
+
|
215
|
+
station_airings.first.airings.count.should be >= 1
|
216
|
+
|
217
|
+
station_airings.first.airings.first.respond_to?(:start_time).should be_true
|
218
|
+
station_airings.first.airings.first.respond_to?(:end_time).should be_true
|
219
|
+
station_airings.first.airings.first.respond_to?(:duration).should be_true
|
220
|
+
end
|
221
|
+
end
|
222
|
+
|
223
|
+
end
|
224
|
+
|
225
|
+
describe '#series' do
|
226
|
+
|
227
|
+
describe '#details' do
|
228
|
+
let(:series) {
|
229
|
+
subject.series.details("185044")
|
230
|
+
}
|
231
|
+
|
232
|
+
it 'should find the series' do
|
233
|
+
series.respond_to?(:tms_id).should be_true
|
234
|
+
series.respond_to?(:title).should be_true
|
235
|
+
series.respond_to?(:short_description).should be_true
|
236
|
+
series.respond_to?(:total_seasons).should be_true
|
237
|
+
series.respond_to?(:total_episodes).should be_true
|
238
|
+
end
|
239
|
+
end
|
240
|
+
|
241
|
+
describe '#airings' do
|
242
|
+
let(:airings) {
|
243
|
+
subject.series.airings("185044",
|
244
|
+
{ :lineupId => "USA-NY31586-X",
|
245
|
+
:startDateTime => "2013-12-22T15:30Z",
|
246
|
+
:endDateTime => "2013-12-26T15:30Z"
|
247
|
+
})
|
248
|
+
}
|
249
|
+
|
250
|
+
it 'should list airings' do
|
251
|
+
airings.count.should be >= 10
|
252
|
+
|
253
|
+
airings.first.respond_to?(:start_time).should be_true
|
254
|
+
airings.first.respond_to?(:end_time).should be_true
|
255
|
+
airings.first.respond_to?(:duration).should be_true
|
256
|
+
airings.first.respond_to?(:station).should be_true
|
257
|
+
airings.first.station.respond_to?(:call_sign).should be_true
|
258
|
+
airings.first.station.respond_to?(:station_id).should be_true
|
259
|
+
end
|
260
|
+
end
|
261
|
+
|
262
|
+
describe '#episodes' do
|
263
|
+
let(:episodes) {
|
264
|
+
subject.series.episodes("185044")
|
265
|
+
}
|
266
|
+
|
267
|
+
it 'should return episodes' do
|
268
|
+
episodes.count.should be >= 10
|
269
|
+
|
270
|
+
episodes.first.respond_to?(:tms_id).should be_true
|
271
|
+
episodes.first.respond_to?(:title).should be_true
|
272
|
+
episodes.first.respond_to?(:short_description).should be_true
|
273
|
+
episodes.first.respond_to?(:episode_title).should be_true
|
274
|
+
episodes.first.respond_to?(:season_num).should be_true
|
275
|
+
episodes.first.respond_to?(:episode_num).should be_true
|
276
|
+
|
277
|
+
end
|
278
|
+
end
|
279
|
+
|
280
|
+
end
|
281
|
+
|
282
|
+
describe '#movies' do
|
283
|
+
|
284
|
+
describe '#tv' do
|
285
|
+
|
286
|
+
describe '#airings' do
|
287
|
+
let(:airings) {
|
288
|
+
subject.movies.tv.airings( { :lineupId => "USA-NY31586-X", :startDateTime => "2013-12-22T15:30Z" } )
|
289
|
+
}
|
290
|
+
|
291
|
+
it 'should tell me what movies are on tv' do
|
292
|
+
airings.count.should be >= 10
|
293
|
+
|
294
|
+
airings.first.respond_to?(:start_time).should be_true
|
295
|
+
airings.first.respond_to?(:end_time).should be_true
|
296
|
+
airings.first.respond_to?(:duration).should be_true
|
297
|
+
airings.first.respond_to?(:channels).should be_true
|
298
|
+
airings.first.channels.count.should be >= 1
|
299
|
+
airings.first.respond_to?(:station).should be_true
|
300
|
+
airings.first.station.respond_to?(:call_sign).should be_true
|
301
|
+
airings.first.respond_to?(:program).should be_true
|
302
|
+
airings.first.program.respond_to?(:tms_id).should be_true
|
303
|
+
airings.first.program.respond_to?(:title).should be_true
|
304
|
+
end
|
305
|
+
end
|
306
|
+
|
307
|
+
describe '#versions' do
|
308
|
+
let(:versions) {
|
309
|
+
subject.movies.tv.versions("3542039")
|
310
|
+
}
|
311
|
+
|
312
|
+
it 'should tell me about that movie' do
|
313
|
+
versions.count.should be >= 5
|
314
|
+
|
315
|
+
versions.first.respond_to?(:tms_id).should be_true
|
316
|
+
versions.first.respond_to?(:title).should be_true
|
317
|
+
versions.first.respond_to?(:short_description).should be_true
|
318
|
+
|
319
|
+
versions.first.respond_to?(:ratings).should be_true
|
320
|
+
versions.first.ratings.count.should be >= 5
|
321
|
+
versions.first.ratings.first.respond_to?(:body).should be_true
|
322
|
+
versions.first.ratings.first.respond_to?(:code).should be_true
|
323
|
+
end
|
324
|
+
end
|
325
|
+
|
326
|
+
end
|
327
|
+
|
328
|
+
describe '#theatres' do
|
329
|
+
|
330
|
+
describe '#showings' do
|
331
|
+
let(:showings) {
|
332
|
+
subject.movies.theatres.showings({:startDate => "2013-12-22", :zip => "12804"})
|
333
|
+
}
|
334
|
+
|
335
|
+
it 'should get movie showings' do
|
336
|
+
showings.count.should be >= 10
|
337
|
+
|
338
|
+
showings.first.respond_to?(:release_year).should be_true
|
339
|
+
showings.first.respond_to?(:run_time).should be_true
|
340
|
+
showings.first.respond_to?(:showtimes).should be_true
|
341
|
+
showings.first.showtimes.first.respond_to?(:date_time).should be_true
|
342
|
+
showings.first.showtimes.first.respond_to?(:theatre).should be_true
|
343
|
+
showings.first.showtimes.first.respond_to?(:quals).should be_true
|
344
|
+
showings.first.showtimes.first.theatre.respond_to?(:id).should be_true
|
345
|
+
showings.first.showtimes.first.theatre.respond_to?(:name).should be_true
|
346
|
+
end
|
347
|
+
|
348
|
+
end
|
349
|
+
|
350
|
+
end
|
351
|
+
|
352
|
+
end
|
353
|
+
|
354
|
+
end
|
data/spec/factories.rb
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
FactoryGirl.define do
|
2
|
+
factory :program, class: TMSAPI::Model::Program do
|
3
|
+
tms_id "SH014122930000"
|
4
|
+
root_id "8648428"
|
5
|
+
series_id "8648428"
|
6
|
+
title "The Amazing World of Gumball"
|
7
|
+
title_lang "en"
|
8
|
+
long_description "No, this animated series is not about anthropomorphic chewing gum, it's about a young cat named Gumball Watterson. Gumball has a penchant for getting into trouble, often resulting from schemes he comes up with, but he never seems to learn his lesson. Gumball's best friend is a fish named Darwin, who used to be the family pet until he grew legs and became part of the family. Gumball resents his younger sister, Anais, because she is the smartest member of the family. Gumball's mother is the breadwinner in the family, working long hours at the rainbow factory, and his father stays at home watching TV and playing video games."
|
9
|
+
description_lang "en"
|
10
|
+
genres ["Children", "Comedy", "Animated"]
|
11
|
+
orig_air_date "2011-05-03"
|
12
|
+
sub_type "Series"
|
13
|
+
total_seasons 1
|
14
|
+
total_episodes 485
|
15
|
+
entity_type "Show"
|
16
|
+
|
17
|
+
association :preferred_image, factory: :image, strategy: :build
|
18
|
+
|
19
|
+
after(:build) { |user|
|
20
|
+
user.ratings = build_list(:rating, 3)
|
21
|
+
user.recommendations = build_list(:recommendation, 2)
|
22
|
+
user.cast = build_list(:person, 4)
|
23
|
+
}
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
factory :rating, class: TMSAPI::Model::Rating do
|
28
|
+
sequence(:body) { |n| "Rating Body #{n}" }
|
29
|
+
sequence(:code) { |n| "Rating #{n}" }
|
30
|
+
end
|
31
|
+
|
32
|
+
factory :recommendation, class: TMSAPI::Model::Recommendation do
|
33
|
+
sequence(:tms_id) { |n| "SH01362768000#{n}" }
|
34
|
+
sequence(:root_id) { |n| "843663#{n}" }
|
35
|
+
title "The Fairly OddParents"
|
36
|
+
end
|
37
|
+
|
38
|
+
factory :person, class: TMSAPI::Model::Person do
|
39
|
+
sequence(:person_id) { |n| "62332#{n}" }
|
40
|
+
sequence(:name_id) { |n| "15682#{n}" }
|
41
|
+
name "Logan Grove"
|
42
|
+
role "Voice"
|
43
|
+
character_name "Gumball Watterson"
|
44
|
+
sequence(:billing_order) { |n| "#{n}" }
|
45
|
+
end
|
46
|
+
|
47
|
+
factory :image, class: TMSAPI::Model::Image do
|
48
|
+
uri "http://demo.tmsimg.com/assets/p8648428_b_v5_aa.jpg"
|
49
|
+
height 360
|
50
|
+
width 240
|
51
|
+
primary true
|
52
|
+
category "Banner-L1"
|
53
|
+
tier "Series"
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe TMSAPI::Model::Program do
|
4
|
+
|
5
|
+
let(:prog) { build(:program) }
|
6
|
+
|
7
|
+
it 'should be filled with data' do
|
8
|
+
prog.respond_to?(:tms_id).should be_true
|
9
|
+
prog.respond_to?(:root_id).should be_true
|
10
|
+
prog.respond_to?(:series_id).should be_true
|
11
|
+
prog.respond_to?(:active).should be_true
|
12
|
+
prog.respond_to?(:title).should be_true
|
13
|
+
prog.respond_to?(:title_lang).should be_true
|
14
|
+
prog.respond_to?(:short_description).should be_true
|
15
|
+
prog.respond_to?(:long_description).should be_true
|
16
|
+
prog.respond_to?(:ratings).should be_true
|
17
|
+
prog.ratings.first.respond_to?(:body).should be_true
|
18
|
+
prog.ratings.first.respond_to?(:code).should be_true
|
19
|
+
prog.respond_to?(:genres).should be_true
|
20
|
+
prog.genres.count.should be >= 3
|
21
|
+
prog.respond_to?(:recommendations).should be_true
|
22
|
+
prog.recommendations.first.respond_to?(:tms_id).should be_true
|
23
|
+
prog.respond_to?(:top_cast).should be_true
|
24
|
+
prog.respond_to?(:orig_air_date).should be_true
|
25
|
+
prog.respond_to?(:preferred_image).should be_true
|
26
|
+
prog.preferred_image.respond_to?(:uri).should be_true
|
27
|
+
prog.respond_to?(:sub_type).should be_true
|
28
|
+
prog.respond_to?(:total_seasons).should be_true
|
29
|
+
prog.respond_to?(:total_episodes).should be_true
|
30
|
+
prog.respond_to?(:entity_type).should be_true
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
|
2
|
+
require 'simplecov'
|
3
|
+
require 'coveralls'
|
4
|
+
require 'factory_girl'
|
5
|
+
SimpleCov.formatter = Coveralls::SimpleCov::Formatter
|
6
|
+
SimpleCov.start do
|
7
|
+
add_filter 'support/vcr'
|
8
|
+
end
|
9
|
+
|
10
|
+
Coveralls.wear!
|
11
|
+
|
12
|
+
require 'rspec/autorun'
|
13
|
+
require 'tmsapi'
|
14
|
+
|
15
|
+
if ENV['RECORDING']
|
16
|
+
API_KEY = ENV['TMS_API_KEY']
|
17
|
+
else
|
18
|
+
API_KEY = 'api_key_YYYYYYYYYYYYYYYYYYYYY'
|
19
|
+
end
|
20
|
+
|
21
|
+
RSpec.configure do |c|
|
22
|
+
# VCR:
|
23
|
+
# so we can use :vcr rather than :vcr => true;
|
24
|
+
# in RSpec 3 this will no longer be necessary.
|
25
|
+
c.treat_symbols_as_metadata_keys_with_true_values = true
|
26
|
+
|
27
|
+
#FactoryGirl
|
28
|
+
c.include FactoryGirl::Syntax::Methods
|
29
|
+
end
|
30
|
+
|
31
|
+
Dir["./spec/support/**/*.rb"].sort.each {|f| require f}
|
32
|
+
|
33
|
+
require 'stringio'
|
34
|
+
|
35
|
+
def capture_stdout &block
|
36
|
+
old_stdout = $stdout
|
37
|
+
fake_stdout = StringIO.new
|
38
|
+
$stdout = fake_stdout
|
39
|
+
block.call
|
40
|
+
fake_stdout.string
|
41
|
+
ensure
|
42
|
+
$stdout = old_stdout
|
43
|
+
end
|
44
|
+
|
45
|
+
FactoryGirl.find_definitions
|
data/spec/support/vcr.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'vcr'
|
2
|
+
require 'pp'
|
3
|
+
|
4
|
+
VCR.configure do |c|
|
5
|
+
c.cassette_library_dir = 'spec/vcr/cassettes'
|
6
|
+
c.hook_into :faraday
|
7
|
+
c.configure_rspec_metadata!
|
8
|
+
|
9
|
+
if ENV['RECORDING']
|
10
|
+
c.filter_sensitive_data('api_key_YYYYYYYYYYYYYYYYYYYYY') { ENV['TMS_API_KEY'] }
|
11
|
+
end
|
12
|
+
|
13
|
+
c.filter_sensitive_data('XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') do |http_interaction|
|
14
|
+
#Not sure if this needs removing, but better safe than sorry...
|
15
|
+
if http_interaction.response.headers['x-newrelic-app-data'] != nil
|
16
|
+
http_interaction.response.headers['x-newrelic-app-data'].first
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|