everybit 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +18 -0
- data/Gemfile +4 -0
- data/LICENSE +21 -0
- data/README.md +281 -0
- data/Rakefile +32 -0
- data/bin/everybit-console +7 -0
- data/everybit.gemspec +33 -0
- data/lib/everybit/account.rb +8 -0
- data/lib/everybit/collection.rb +17 -0
- data/lib/everybit/errors/authentication_error.rb +4 -0
- data/lib/everybit/errors/everybit_error.rb +20 -0
- data/lib/everybit/everybit_object.rb +32 -0
- data/lib/everybit/modules/createable.rb +13 -0
- data/lib/everybit/modules/deleteable.rb +14 -0
- data/lib/everybit/modules/listable.rb +15 -0
- data/lib/everybit/modules/updateable.rb +28 -0
- data/lib/everybit/resource.rb +21 -0
- data/lib/everybit/version.rb +3 -0
- data/lib/everybit/video.rb +33 -0
- data/lib/everybit.rb +78 -0
- data/spec/account_spec.rb +46 -0
- data/spec/misc_spec.rb +49 -0
- data/spec/spec_helper.rb +277 -0
- data/spec/video_spec.rb +318 -0
- metadata +139 -0
data/spec/video_spec.rb
ADDED
@@ -0,0 +1,318 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
# this file contains all the tests for video resources
|
5
|
+
|
6
|
+
describe Everybit, 'Video Specs' do
|
7
|
+
|
8
|
+
before do
|
9
|
+
Everybit.api_key = '1a2b3c4d5e6f7g8h9i'
|
10
|
+
end
|
11
|
+
|
12
|
+
after do
|
13
|
+
Everybit.api_key = nil
|
14
|
+
end
|
15
|
+
|
16
|
+
describe 'getting all videos' do
|
17
|
+
|
18
|
+
before do
|
19
|
+
@params = {mock_response: 'mock_all_videos'}
|
20
|
+
end
|
21
|
+
|
22
|
+
after do
|
23
|
+
@params = {}
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'should wrap the response in an Everybit::Collection object' do
|
27
|
+
res = Everybit::Video.all(@params)
|
28
|
+
res.must_be_instance_of Everybit::Collection
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'should return an array of Everybit::Video objects' do
|
32
|
+
res = Everybit::Video.all(@params)
|
33
|
+
res.data.each do |video|
|
34
|
+
video.must_be_instance_of Everybit::Video
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'should create a code attribute' do
|
39
|
+
res = Everybit::Video.all(@params)
|
40
|
+
res.code.must_equal 200
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'should create a status attribute' do
|
44
|
+
res = Everybit::Video.all(@params)
|
45
|
+
res.status.must_equal true
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'should create the correct url' do
|
49
|
+
res = Everybit::Video.all(@params)
|
50
|
+
res.data.each do |video|
|
51
|
+
video[:opts][:url].must_equal 'https://api.everybit.co/v1/videos'
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
it 'should use the :get HTTP verb' do
|
56
|
+
res = Everybit::Video.all(@params)
|
57
|
+
res.data.each do |video|
|
58
|
+
video[:opts][:method].must_equal 'get'
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
end # getting all videos
|
63
|
+
|
64
|
+
describe 'single video details' do
|
65
|
+
|
66
|
+
before do
|
67
|
+
@params = {mock_response: 'mock_video_details'}
|
68
|
+
end
|
69
|
+
|
70
|
+
after do
|
71
|
+
@params = {}
|
72
|
+
end
|
73
|
+
|
74
|
+
it 'should wrap the response in an Everybit::Video object' do
|
75
|
+
res = Everybit::Video.details('787c8956-1857-4771-9d4e-b99b4dedfeae', @params)
|
76
|
+
res.must_be_instance_of Everybit::Video
|
77
|
+
end
|
78
|
+
|
79
|
+
it 'should create the correct url' do
|
80
|
+
res = Everybit::Video.details('787c8956-1857-4771-9d4e-b99b4dedfeae', @params)
|
81
|
+
res[:opts][:url].must_equal 'https://api.everybit.co/v1/videos/787c8956-1857-4771-9d4e-b99b4dedfeae'
|
82
|
+
end
|
83
|
+
|
84
|
+
it 'should require a uuid' do
|
85
|
+
assert_raises ArgumentError do
|
86
|
+
Everybit::Video.details()
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
it 'should create a code attribute' do
|
91
|
+
res = Everybit::Video.details('787c8956-1857-4771-9d4e-b99b4dedfeae', @params)
|
92
|
+
res.code.must_equal 200
|
93
|
+
end
|
94
|
+
|
95
|
+
it 'should create a status attribute' do
|
96
|
+
res = Everybit::Video.details('787c8956-1857-4771-9d4e-b99b4dedfeae', @params)
|
97
|
+
res.status.must_equal true
|
98
|
+
end
|
99
|
+
|
100
|
+
it 'should expose correct data' do
|
101
|
+
actual = Everybit::Video.details('787c8956-1857-4771-9d4e-b99b4dedfeae', @params)
|
102
|
+
expected = mock_video_details
|
103
|
+
expected[:data].delete :opts
|
104
|
+
expected[:data].each { |key, value| actual[key].must_equal value }
|
105
|
+
expected[:data][:player_attributes].each { |key, value| actual[:player_attributes][key].must_equal value }
|
106
|
+
expected[:data][:media_info].each { |key, value| actual[:media_info][key].must_equal value }
|
107
|
+
|
108
|
+
expected[:data][:versions].each_with_index do |version, index|
|
109
|
+
version.each { |key, value| actual[:versions][index][key].must_equal value }
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
it 'should use the :get HTTP verb' do
|
114
|
+
res = Everybit::Video.details('787c8956-1857-4771-9d4e-b99b4dedfeae', @params)
|
115
|
+
res[:opts][:method].must_equal 'get'
|
116
|
+
end
|
117
|
+
|
118
|
+
end # single video details
|
119
|
+
|
120
|
+
describe 'single video status' do
|
121
|
+
|
122
|
+
before do
|
123
|
+
@params = {mock_response: 'mock_video_status'}
|
124
|
+
end
|
125
|
+
|
126
|
+
after do
|
127
|
+
@params = {}
|
128
|
+
end
|
129
|
+
|
130
|
+
it 'should wrap the response in an Everybit::Video object' do
|
131
|
+
res = Everybit::Video.status('787c8956-1857-4771-9d4e-b99b4dedfeae', @params)
|
132
|
+
res.must_be_instance_of Everybit::Video
|
133
|
+
end
|
134
|
+
|
135
|
+
it 'should create the correct url' do
|
136
|
+
res = Everybit::Video.status('787c8956-1857-4771-9d4e-b99b4dedfeae', @params)
|
137
|
+
res[:opts][:url].must_equal 'https://api.everybit.co/v1/videos/787c8956-1857-4771-9d4e-b99b4dedfeae/status'
|
138
|
+
end
|
139
|
+
|
140
|
+
it 'should require a uuid' do
|
141
|
+
assert_raises ArgumentError do
|
142
|
+
Everybit::Video.status()
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
it 'should create a code attribute' do
|
147
|
+
res = Everybit::Video.status('787c8956-1857-4771-9d4e-b99b4dedfeae', @params)
|
148
|
+
res.code.must_equal 200
|
149
|
+
end
|
150
|
+
|
151
|
+
it 'should create a status attribute' do
|
152
|
+
res = Everybit::Video.status('787c8956-1857-4771-9d4e-b99b4dedfeae', @params)
|
153
|
+
res.status.must_equal true
|
154
|
+
end
|
155
|
+
|
156
|
+
it 'should expose correct data' do
|
157
|
+
actual = Everybit::Video.status('787c8956-1857-4771-9d4e-b99b4dedfeae', @params)
|
158
|
+
expected = mock_video_status
|
159
|
+
expected[:data].delete :opts
|
160
|
+
expected[:data].each { |key, value| actual[key].must_equal value }
|
161
|
+
end
|
162
|
+
|
163
|
+
it 'should use the :get HTTP verb' do
|
164
|
+
res = Everybit::Video.status('787c8956-1857-4771-9d4e-b99b4dedfeae', @params)
|
165
|
+
res[:opts][:method].must_equal 'get'
|
166
|
+
end
|
167
|
+
|
168
|
+
end # single video status
|
169
|
+
|
170
|
+
describe 'creating a video' do
|
171
|
+
|
172
|
+
before do
|
173
|
+
@params = {mock_response: 'mock_create_video_success'}
|
174
|
+
end
|
175
|
+
|
176
|
+
after do
|
177
|
+
@params = {}
|
178
|
+
end
|
179
|
+
|
180
|
+
it 'should wrap the response in an Everybit::Video object' do
|
181
|
+
res = Everybit::Video.create(@params)
|
182
|
+
res.must_be_instance_of Everybit::Video
|
183
|
+
end
|
184
|
+
|
185
|
+
it 'should create the correct url' do
|
186
|
+
res = Everybit::Video.create(@params)
|
187
|
+
res[:opts][:url].must_equal 'https://api.everybit.co/v1/videos'
|
188
|
+
end
|
189
|
+
|
190
|
+
it 'should create a code attribute' do
|
191
|
+
res = Everybit::Video.create(@params)
|
192
|
+
res.code.must_equal 200
|
193
|
+
end
|
194
|
+
|
195
|
+
it 'should create a status attribute' do
|
196
|
+
res = Everybit::Video.create(@params)
|
197
|
+
res.status.must_equal true
|
198
|
+
end
|
199
|
+
|
200
|
+
it 'should return a uuid when successful' do
|
201
|
+
res = Everybit::Video.create(@params)
|
202
|
+
res[:uuid].must_equal '787c8956-1857-4771-9d4e-b99b4dedfeae'
|
203
|
+
end
|
204
|
+
|
205
|
+
it 'should have an error message when not successful' do
|
206
|
+
@params = {mock_response: 'mock_create_video_error'}
|
207
|
+
res = Everybit::Video.create(@params)
|
208
|
+
res.status.must_equal false
|
209
|
+
res[:error].must_equal 'some error message here'
|
210
|
+
end
|
211
|
+
|
212
|
+
it 'should use the :post HTTP verb' do
|
213
|
+
res = Everybit::Video.create(@params)
|
214
|
+
res[:opts][:method].must_equal 'post'
|
215
|
+
end
|
216
|
+
|
217
|
+
end # creating a video
|
218
|
+
|
219
|
+
describe 'updating a video' do
|
220
|
+
|
221
|
+
before do
|
222
|
+
@params = {mock_response: 'mock_video_details'}
|
223
|
+
@video = Everybit::Video.details('787c8956-1857-4771-9d4e-b99b4dedfeae', @params)
|
224
|
+
end
|
225
|
+
|
226
|
+
after do
|
227
|
+
@params = nil
|
228
|
+
@video = nil
|
229
|
+
end
|
230
|
+
|
231
|
+
it 'should create the correct url' do
|
232
|
+
@video.save({mock_response: 'mock_update_video_success'})
|
233
|
+
@video[:opts][:url].must_equal 'https://api.everybit.co/v1/videos/787c8956-1857-4771-9d4e-b99b4dedfeae'
|
234
|
+
end
|
235
|
+
|
236
|
+
it 'should update the code attribute when unsuccessful' do
|
237
|
+
@video.save({mock_response: 'mock_update_video_error'})
|
238
|
+
@video.code.must_equal 200
|
239
|
+
end
|
240
|
+
|
241
|
+
it 'should update the status attribute when unsuccessful' do
|
242
|
+
@video.save({mock_response: 'mock_update_video_error'})
|
243
|
+
@video.status.must_equal false
|
244
|
+
end
|
245
|
+
|
246
|
+
it 'should have a success message when successful' do
|
247
|
+
@video.save({mock_response: 'mock_update_video_success'})
|
248
|
+
@video[:message].must_equal 'your video was updated successfully'
|
249
|
+
end
|
250
|
+
|
251
|
+
it 'should have an error message when unsuccessful' do
|
252
|
+
@video.save({mock_response: 'mock_update_video_error'})
|
253
|
+
@video[:error].must_equal 'some error message here'
|
254
|
+
end
|
255
|
+
|
256
|
+
it 'should use the :put HTTP verb' do
|
257
|
+
@video.save({mock_response: 'mock_update_video_success'})
|
258
|
+
@video[:opts][:method].must_equal 'put'
|
259
|
+
end
|
260
|
+
|
261
|
+
end # updating a video
|
262
|
+
|
263
|
+
describe 'deleting a video' do
|
264
|
+
|
265
|
+
before do
|
266
|
+
@params = {mock_response: 'mock_delete_video_success'}
|
267
|
+
end
|
268
|
+
|
269
|
+
after do
|
270
|
+
@params = {}
|
271
|
+
end
|
272
|
+
|
273
|
+
it 'should wrap the response in an Everybit::Video object' do
|
274
|
+
res = Everybit::Video.delete('787c8956-1857-4771-9d4e-b99b4dedfeae', @params)
|
275
|
+
res.must_be_instance_of Everybit::Video
|
276
|
+
end
|
277
|
+
|
278
|
+
it 'should create the correct url' do
|
279
|
+
res = Everybit::Video.delete('787c8956-1857-4771-9d4e-b99b4dedfeae', @params)
|
280
|
+
res[:opts][:url].must_equal 'https://api.everybit.co/v1/videos/787c8956-1857-4771-9d4e-b99b4dedfeae'
|
281
|
+
end
|
282
|
+
|
283
|
+
it 'should require a uuid' do
|
284
|
+
assert_raises ArgumentError do
|
285
|
+
Everybit::Video.delete()
|
286
|
+
end
|
287
|
+
end
|
288
|
+
|
289
|
+
it 'should create a code attribute' do
|
290
|
+
res = Everybit::Video.delete('787c8956-1857-4771-9d4e-b99b4dedfeae', @params)
|
291
|
+
res.code.must_equal 200
|
292
|
+
end
|
293
|
+
|
294
|
+
it 'should create a status attribute' do
|
295
|
+
res = Everybit::Video.delete('787c8956-1857-4771-9d4e-b99b4dedfeae', @params)
|
296
|
+
res.status.must_equal true
|
297
|
+
end
|
298
|
+
|
299
|
+
it 'should have a success message when successful' do
|
300
|
+
res = Everybit::Video.delete('787c8956-1857-4771-9d4e-b99b4dedfeae', @params)
|
301
|
+
res[:message].must_equal 'your video was deleted successfully'
|
302
|
+
end
|
303
|
+
|
304
|
+
it 'should have an error message when not successful' do
|
305
|
+
@params = {mock_response: 'mock_delete_video_error'}
|
306
|
+
res = Everybit::Video.delete('787c8956-1857-4771-9d4e-b99b4dedfeae', @params)
|
307
|
+
res.status.must_equal false
|
308
|
+
res[:error].must_equal 'some error message here'
|
309
|
+
end
|
310
|
+
|
311
|
+
it 'should use the :delete HTTP verb' do
|
312
|
+
res = Everybit::Video.delete('787c8956-1857-4771-9d4e-b99b4dedfeae', @params)
|
313
|
+
res[:opts][:method].must_equal 'delete'
|
314
|
+
end
|
315
|
+
|
316
|
+
end # deleting a video
|
317
|
+
|
318
|
+
end # Video Specs
|
metadata
ADDED
@@ -0,0 +1,139 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: everybit
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Dominic Giglio
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-03-10 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rest-client
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '1.6'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '1.6'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: multi_json
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ~>
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '1.5'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '1.5'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: minitest
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: turn
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
description: This gem defines methods for controlling your media through Everybit's
|
79
|
+
API.
|
80
|
+
email:
|
81
|
+
- humanshell@gmail.com
|
82
|
+
executables:
|
83
|
+
- everybit-console
|
84
|
+
extensions: []
|
85
|
+
extra_rdoc_files: []
|
86
|
+
files:
|
87
|
+
- .gitignore
|
88
|
+
- Gemfile
|
89
|
+
- LICENSE
|
90
|
+
- README.md
|
91
|
+
- Rakefile
|
92
|
+
- bin/everybit-console
|
93
|
+
- everybit.gemspec
|
94
|
+
- lib/everybit.rb
|
95
|
+
- lib/everybit/account.rb
|
96
|
+
- lib/everybit/collection.rb
|
97
|
+
- lib/everybit/errors/authentication_error.rb
|
98
|
+
- lib/everybit/errors/everybit_error.rb
|
99
|
+
- lib/everybit/everybit_object.rb
|
100
|
+
- lib/everybit/modules/createable.rb
|
101
|
+
- lib/everybit/modules/deleteable.rb
|
102
|
+
- lib/everybit/modules/listable.rb
|
103
|
+
- lib/everybit/modules/updateable.rb
|
104
|
+
- lib/everybit/resource.rb
|
105
|
+
- lib/everybit/version.rb
|
106
|
+
- lib/everybit/video.rb
|
107
|
+
- spec/account_spec.rb
|
108
|
+
- spec/misc_spec.rb
|
109
|
+
- spec/spec_helper.rb
|
110
|
+
- spec/video_spec.rb
|
111
|
+
homepage: http://dev.everybit.co
|
112
|
+
licenses: []
|
113
|
+
post_install_message:
|
114
|
+
rdoc_options: []
|
115
|
+
require_paths:
|
116
|
+
- lib
|
117
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
118
|
+
none: false
|
119
|
+
requirements:
|
120
|
+
- - ! '>='
|
121
|
+
- !ruby/object:Gem::Version
|
122
|
+
version: '0'
|
123
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
124
|
+
none: false
|
125
|
+
requirements:
|
126
|
+
- - ! '>='
|
127
|
+
- !ruby/object:Gem::Version
|
128
|
+
version: '0'
|
129
|
+
requirements: []
|
130
|
+
rubyforge_project: everybit
|
131
|
+
rubygems_version: 1.8.23
|
132
|
+
signing_key:
|
133
|
+
specification_version: 3
|
134
|
+
summary: Access Everybit API
|
135
|
+
test_files:
|
136
|
+
- spec/account_spec.rb
|
137
|
+
- spec/misc_spec.rb
|
138
|
+
- spec/spec_helper.rb
|
139
|
+
- spec/video_spec.rb
|