sproutvideo-rb 1.6.0 → 1.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/Gemfile +2 -4
- data/Gemfile.lock +25 -17
- data/LICENSE.txt +1 -1
- data/README.markdown +275 -29
- data/lib/sproutvideo/access_grant.rb +4 -0
- data/lib/sproutvideo/analytics.rb +62 -38
- data/lib/sproutvideo/call_to_action.rb +39 -0
- data/lib/sproutvideo/folder.rb +28 -0
- data/lib/sproutvideo/live_stream.rb +43 -0
- data/lib/sproutvideo/resource.rb +10 -14
- data/lib/sproutvideo/subtitle.rb +39 -0
- data/lib/sproutvideo/version.rb +1 -1
- data/lib/sproutvideo/video.rb +4 -5
- data/lib/sproutvideo.rb +16 -12
- data/spec/sproutvideo/access_grant_spec.rb +14 -3
- data/spec/sproutvideo/analytics_spec.rb +128 -14
- data/spec/sproutvideo/call_to_action_spec.rb +98 -0
- data/spec/sproutvideo/folder_spec.rb +107 -0
- data/spec/sproutvideo/live_stream_spec.rb +152 -0
- data/spec/sproutvideo/login_spec.rb +1 -1
- data/spec/sproutvideo/playlist_spec.rb +1 -1
- data/spec/sproutvideo/subtitle_spec.rb +98 -0
- data/spec/sproutvideo/tag_spec.rb +1 -1
- data/spec/sproutvideo/video_spec.rb +4 -4
- data/sproutvideo-rb.gemspec +19 -21
- metadata +43 -45
@@ -12,7 +12,7 @@ describe Sproutvideo::Analytics do
|
|
12
12
|
@url = "#{Sproutvideo.base_url}/stats/counts"
|
13
13
|
end
|
14
14
|
|
15
|
-
it "should GET the correct url for overall method call and return a response" do
|
15
|
+
it "should GET the correct url for overall method call and return a response" do
|
16
16
|
RestClient.should_receive(:get).with(
|
17
17
|
@url,
|
18
18
|
{'SproutVideo-Api-Key' => @api_key, :params => {}}).and_return(@msg)
|
@@ -24,6 +24,12 @@ describe Sproutvideo::Analytics do
|
|
24
24
|
{'SproutVideo-Api-Key' => @api_key, :params => {}}).and_return(@msg)
|
25
25
|
Sproutvideo::Analytics.play_counts(:video_id => 'abc123').class.should == Sproutvideo::Response
|
26
26
|
end
|
27
|
+
it "should GET the correct url for individual live stream method call and return a response" do
|
28
|
+
RestClient.should_receive(:get).with(
|
29
|
+
"#{Sproutvideo.base_url}/stats/live_streams/abc123/counts",
|
30
|
+
{'SproutVideo-Api-Key' => @api_key, :params => {}}).and_return(@msg)
|
31
|
+
Sproutvideo::Analytics.play_counts(:live_stream_id => 'abc123').class.should == Sproutvideo::Response
|
32
|
+
end
|
27
33
|
it "should GET the correct url if dates are passed in" do
|
28
34
|
RestClient.should_receive(:get).with(
|
29
35
|
@url,
|
@@ -32,12 +38,39 @@ describe Sproutvideo::Analytics do
|
|
32
38
|
end
|
33
39
|
end
|
34
40
|
|
41
|
+
describe '#download_counts' do
|
42
|
+
before(:each) do
|
43
|
+
@url = "#{Sproutvideo.base_url}/stats/downloads"
|
44
|
+
end
|
45
|
+
|
46
|
+
it "should GET the correct url for overall method call and return a response" do
|
47
|
+
RestClient.should_receive(:get).with(
|
48
|
+
@url,
|
49
|
+
{'SproutVideo-Api-Key' => @api_key, :params => {}}).and_return(@msg)
|
50
|
+
Sproutvideo::Analytics.download_counts.class.should == Sproutvideo::Response
|
51
|
+
end
|
52
|
+
|
53
|
+
it 'should GET the correct url for individual video method call and return a response' do
|
54
|
+
RestClient.should_receive(:get).with(
|
55
|
+
"#{@url}/abc123",
|
56
|
+
{'SproutVideo-Api-Key' => @api_key, :params => {}}).and_return(@msg)
|
57
|
+
Sproutvideo::Analytics.download_counts(:video_id => 'abc123').class.should == Sproutvideo::Response
|
58
|
+
end
|
59
|
+
|
60
|
+
it 'should GET the correct url if dates are passed in' do
|
61
|
+
RestClient.should_receive(:get).with(
|
62
|
+
@url,
|
63
|
+
{'SproutVideo-Api-Key' => @api_key, :params => {:start_date => '2012-12-31', :end_date => '2013-12-31'}}).and_return(@msg)
|
64
|
+
Sproutvideo::Analytics.download_counts(:start_date => '2012-12-31', :end_date => '2013-12-31').class.should == Sproutvideo::Response
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
35
68
|
describe "#domains" do
|
36
69
|
before(:each) do
|
37
70
|
@url = "#{Sproutvideo.base_url}/stats/domains"
|
38
71
|
end
|
39
72
|
|
40
|
-
it "should GET the correct url for overall method call and return a response" do
|
73
|
+
it "should GET the correct url for overall method call and return a response" do
|
41
74
|
RestClient.should_receive(:get).with(
|
42
75
|
@url,
|
43
76
|
{'SproutVideo-Api-Key' => @api_key, :params => {}}).and_return(@msg)
|
@@ -49,6 +82,12 @@ describe Sproutvideo::Analytics do
|
|
49
82
|
{'SproutVideo-Api-Key' => @api_key, :params => {}}).and_return(@msg)
|
50
83
|
Sproutvideo::Analytics.domains(:video_id => 'abc123').class.should == Sproutvideo::Response
|
51
84
|
end
|
85
|
+
it "should GET the correct url for individual live stream method call and return a response" do
|
86
|
+
RestClient.should_receive(:get).with(
|
87
|
+
"#{Sproutvideo.base_url}/stats/live_streams/abc123/device_types",
|
88
|
+
{'SproutVideo-Api-Key' => @api_key, :params => {}}).and_return(@msg)
|
89
|
+
Sproutvideo::Analytics.device_types(:live_stream_id => 'abc123').class.should == Sproutvideo::Response
|
90
|
+
end
|
52
91
|
it "should GET the correct url if dates are passed in" do
|
53
92
|
RestClient.should_receive(:get).with(
|
54
93
|
@url,
|
@@ -62,7 +101,7 @@ describe Sproutvideo::Analytics do
|
|
62
101
|
@url = "#{Sproutvideo.base_url}/stats/geo"
|
63
102
|
end
|
64
103
|
|
65
|
-
it "should GET the correct url for overall method call and return a response" do
|
104
|
+
it "should GET the correct url for overall method call and return a response" do
|
66
105
|
RestClient.should_receive(:get).with(
|
67
106
|
@url,
|
68
107
|
{'SproutVideo-Api-Key' => @api_key, :params => {}}).and_return(@msg)
|
@@ -74,6 +113,12 @@ describe Sproutvideo::Analytics do
|
|
74
113
|
{'SproutVideo-Api-Key' => @api_key, :params => {}}).and_return(@msg)
|
75
114
|
Sproutvideo::Analytics.geo(:video_id => 'abc123').class.should == Sproutvideo::Response
|
76
115
|
end
|
116
|
+
it "should GET the correct url for individual live stream method call and return a response" do
|
117
|
+
RestClient.should_receive(:get).with(
|
118
|
+
"#{Sproutvideo.base_url}/stats/live_streams/abc123/geo",
|
119
|
+
{'SproutVideo-Api-Key' => @api_key, :params => {}}).and_return(@msg)
|
120
|
+
Sproutvideo::Analytics.geo(:live_stream_id => 'abc123').class.should == Sproutvideo::Response
|
121
|
+
end
|
77
122
|
it "should GET the correct url if dates are passed in" do
|
78
123
|
RestClient.should_receive(:get).with(
|
79
124
|
@url,
|
@@ -93,7 +138,7 @@ describe Sproutvideo::Analytics do
|
|
93
138
|
@url = "#{Sproutvideo.base_url}/stats/video_types"
|
94
139
|
end
|
95
140
|
|
96
|
-
it "should GET the correct url for overall method call and return a response" do
|
141
|
+
it "should GET the correct url for overall method call and return a response" do
|
97
142
|
RestClient.should_receive(:get).with(
|
98
143
|
@url,
|
99
144
|
{'SproutVideo-Api-Key' => @api_key, :params => {}}).and_return(@msg)
|
@@ -118,7 +163,7 @@ describe Sproutvideo::Analytics do
|
|
118
163
|
@url = "#{Sproutvideo.base_url}/stats/playback_types"
|
119
164
|
end
|
120
165
|
|
121
|
-
it "should GET the correct url for overall method call and return a response" do
|
166
|
+
it "should GET the correct url for overall method call and return a response" do
|
122
167
|
RestClient.should_receive(:get).with(
|
123
168
|
@url,
|
124
169
|
{'SproutVideo-Api-Key' => @api_key, :params => {}}).and_return(@msg)
|
@@ -143,7 +188,7 @@ describe Sproutvideo::Analytics do
|
|
143
188
|
@url = "#{Sproutvideo.base_url}/stats/device_types"
|
144
189
|
end
|
145
190
|
|
146
|
-
it "should GET the correct url for overall method call and return a response" do
|
191
|
+
it "should GET the correct url for overall method call and return a response" do
|
147
192
|
RestClient.should_receive(:get).with(
|
148
193
|
@url,
|
149
194
|
{'SproutVideo-Api-Key' => @api_key, :params => {}}).and_return(@msg)
|
@@ -168,7 +213,7 @@ describe Sproutvideo::Analytics do
|
|
168
213
|
@url = "#{Sproutvideo.base_url}/stats/engagement"
|
169
214
|
end
|
170
215
|
|
171
|
-
it "should GET the correct url for overall method call and return a response" do
|
216
|
+
it "should GET the correct url for overall method call and return a response" do
|
172
217
|
RestClient.should_receive(:get).with(
|
173
218
|
@url,
|
174
219
|
{'SproutVideo-Api-Key' => @api_key, :params => {}}).and_return(@msg)
|
@@ -182,24 +227,93 @@ describe Sproutvideo::Analytics do
|
|
182
227
|
end
|
183
228
|
end
|
184
229
|
|
230
|
+
describe "#live_stream_engagment" do
|
231
|
+
it "should GET the correct url for live streams method call and return a response" do
|
232
|
+
RestClient.should_receive(:get).with(
|
233
|
+
"#{Sproutvideo.base_url}/stats/live_streams/engagement",
|
234
|
+
{'SproutVideo-Api-Key' => @api_key, :params => {}}).and_return(@msg)
|
235
|
+
Sproutvideo::Analytics.live_stream_engagement.class.should == Sproutvideo::Response
|
236
|
+
end
|
237
|
+
it "should GET the correct url for individual live stream method call and return a response" do
|
238
|
+
RestClient.should_receive(:get).with(
|
239
|
+
"#{Sproutvideo.base_url}/stats/live_streams/abc123/engagement",
|
240
|
+
{'SproutVideo-Api-Key' => @api_key, :params => {}}).and_return(@msg)
|
241
|
+
Sproutvideo::Analytics.live_stream_engagement(:live_stream_id => 'abc123').class.should == Sproutvideo::Response
|
242
|
+
end
|
243
|
+
end
|
244
|
+
|
185
245
|
describe "#engagement_sessions" do
|
186
246
|
before(:each) do
|
187
|
-
@
|
247
|
+
@id = "abc123"
|
188
248
|
end
|
189
|
-
|
249
|
+
|
250
|
+
it "should GET the correct url for overall method call and return a response" do
|
190
251
|
RestClient.should_receive(:get).with(
|
191
|
-
|
252
|
+
"#{Sproutvideo.base_url}/stats/engagement/sessions",
|
192
253
|
{'SproutVideo-Api-Key' => @api_key, :params => {}}).and_return(@msg)
|
193
|
-
Sproutvideo::Analytics.engagement_sessions
|
254
|
+
Sproutvideo::Analytics.engagement_sessions.class.should == Sproutvideo::Response
|
194
255
|
end
|
195
256
|
|
196
257
|
it "should use pagination params" do
|
197
258
|
RestClient.should_receive(:get).with(
|
198
|
-
|
259
|
+
"#{Sproutvideo.base_url}/stats/engagement/sessions",
|
199
260
|
{'SproutVideo-Api-Key' => @api_key, :params => {:page => 2, :per_page => 5}}).and_return(@msg)
|
200
|
-
Sproutvideo::Analytics.engagement_sessions(
|
261
|
+
Sproutvideo::Analytics.engagement_sessions(nil, :page => 2, :per_page => 5)
|
262
|
+
end
|
263
|
+
|
264
|
+
it "should GET the correct url for video specific method call and return a response" do
|
265
|
+
RestClient.should_receive(:get).with(
|
266
|
+
"#{Sproutvideo.base_url}/stats/engagement/#{@id}/sessions",
|
267
|
+
{'SproutVideo-Api-Key' => @api_key, :params => {}}).and_return(@msg)
|
268
|
+
Sproutvideo::Analytics.engagement_sessions(@id).class.should == Sproutvideo::Response
|
269
|
+
end
|
270
|
+
end
|
271
|
+
|
272
|
+
describe "#live_stream_engagement_sessions" do
|
273
|
+
before(:each) do
|
274
|
+
@id = "abc123"
|
275
|
+
end
|
276
|
+
|
277
|
+
it "should GET the correct url for overall live stream method call and return a response" do
|
278
|
+
RestClient.should_receive(:get).with(
|
279
|
+
"#{Sproutvideo.base_url}/stats/live_streams/engagement/sessions",
|
280
|
+
{'SproutVideo-Api-Key' => @api_key, :params => {}}).and_return(@msg)
|
281
|
+
Sproutvideo::Analytics.live_stream_engagement_sessions.class.should == Sproutvideo::Response
|
282
|
+
end
|
283
|
+
|
284
|
+
it "should GET the correct url for livestream specific method call and return a response" do
|
285
|
+
RestClient.should_receive(:get).with(
|
286
|
+
"#{Sproutvideo.base_url}/stats/live_streams/#{@id}/engagement/sessions",
|
287
|
+
{'SproutVideo-Api-Key' => @api_key, :params => {}}).and_return(@msg)
|
288
|
+
Sproutvideo::Analytics.live_stream_engagement_sessions(@id).class.should == Sproutvideo::Response
|
201
289
|
end
|
202
290
|
end
|
203
291
|
|
292
|
+
describe "#popular_videos" do
|
293
|
+
it "should GET the correct url for overall method call and return a response" do
|
294
|
+
RestClient.should_receive(:get).with(
|
295
|
+
"#{Sproutvideo.base_url}/stats/popular_videos",
|
296
|
+
{'SproutVideo-Api-Key' => @api_key, :params => {}}).and_return(@msg)
|
297
|
+
Sproutvideo::Analytics.popular_videos.class.should == Sproutvideo::Response
|
298
|
+
end
|
299
|
+
end
|
204
300
|
|
205
|
-
|
301
|
+
describe "#popular_downloads" do
|
302
|
+
it "should GET the correct url for overall method call and return a response" do
|
303
|
+
RestClient.should_receive(:get).with(
|
304
|
+
"#{Sproutvideo.base_url}/stats/popular_downloads",
|
305
|
+
{'SproutVideo-Api-Key' => @api_key, :params => {}}).and_return(@msg)
|
306
|
+
Sproutvideo::Analytics.popular_downloads.class.should == Sproutvideo::Response
|
307
|
+
end
|
308
|
+
end
|
309
|
+
|
310
|
+
describe "#live_stream_overview" do
|
311
|
+
it "should GET the correct url for overall method call and return a response" do
|
312
|
+
id = "abc123"
|
313
|
+
RestClient.should_receive(:get).with(
|
314
|
+
"#{Sproutvideo.base_url}/stats/live_streams/#{id}/overview",
|
315
|
+
{'SproutVideo-Api-Key' => @api_key, :params => {}}).and_return(@msg)
|
316
|
+
Sproutvideo::Analytics.live_stream_overview(id)
|
317
|
+
end
|
318
|
+
end
|
319
|
+
end
|
@@ -0,0 +1,98 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper.rb')
|
2
|
+
describe Sproutvideo::CallToAction do
|
3
|
+
before(:each) do
|
4
|
+
@api_key = 'abc123'
|
5
|
+
@video_id = 1
|
6
|
+
Sproutvideo.api_key = @api_key
|
7
|
+
Sproutvideo.base_url = 'https://api.sproutvideo.com/v1'
|
8
|
+
@msg = mock(:to_s => "{}", :code => 200)
|
9
|
+
end
|
10
|
+
|
11
|
+
describe "#create" do
|
12
|
+
it "should POST the correct url and return a response" do
|
13
|
+
request_data = { :text => 'join now!', :url => 'https://sproutvideo.com', start_time: 1, end_time: 2 }
|
14
|
+
RestClient.should_receive(:post).with(
|
15
|
+
"#{Sproutvideo.base_url}/videos/#{@video_id}/calls_to_action",
|
16
|
+
MultiJson.encode(request_data),
|
17
|
+
{'SproutVideo-Api-Key' => @api_key}).and_return(@msg)
|
18
|
+
data = request_data
|
19
|
+
data[:video_id] = @video_id
|
20
|
+
Sproutvideo::CallToAction.create(data).class.should == Sproutvideo::Response
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe "#list" do
|
25
|
+
before(:each) do
|
26
|
+
@url = "#{Sproutvideo.base_url}/videos/#{@video_id}/calls_to_action"
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should GET the correct url and return a response" do
|
30
|
+
|
31
|
+
RestClient.should_receive(:get).with(
|
32
|
+
@url,
|
33
|
+
{'SproutVideo-Api-Key' => @api_key, :params => {:page => 1, :per_page => 25}}).and_return(@msg)
|
34
|
+
Sproutvideo::CallToAction.list(video_id: @video_id).class.should == Sproutvideo::Response
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should merge params" do
|
38
|
+
RestClient.should_receive(:get).with(
|
39
|
+
@url,
|
40
|
+
{'SproutVideo-Api-Key' => @api_key, :params => {:page => 1, :per_page => 25, :foo => 'bar'}}).and_return(@msg)
|
41
|
+
Sproutvideo::CallToAction.list(video_id: @video_id, :foo => 'bar')
|
42
|
+
end
|
43
|
+
|
44
|
+
it "should use pagination params" do
|
45
|
+
RestClient.should_receive(:get).with(
|
46
|
+
@url,
|
47
|
+
{'SproutVideo-Api-Key' => @api_key, :params => {:page => 2, :per_page => 5}}).and_return(@msg)
|
48
|
+
Sproutvideo::CallToAction.list(video_id: @video_id, :page => 2, :per_page => 5)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
describe "#details" do
|
53
|
+
before(:each) do
|
54
|
+
@cta_id = '12'
|
55
|
+
@url = "#{Sproutvideo.base_url}/videos/#{@video_id}/calls_to_action/#{@cta_id}"
|
56
|
+
end
|
57
|
+
|
58
|
+
it "should get the correct url and return a response" do
|
59
|
+
RestClient.should_receive(:get).with(
|
60
|
+
@url,
|
61
|
+
{'SproutVideo-Api-Key' => @api_key, :params => { id: @cta_id }}).and_return(@msg)
|
62
|
+
Sproutvideo::CallToAction.details(id: @cta_id, video_id: @video_id).class.should == Sproutvideo::Response
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
describe "#update" do
|
67
|
+
before(:each) do
|
68
|
+
@cta_id = '12'
|
69
|
+
@url = "#{Sproutvideo.base_url}/videos/#{@video_id}/calls_to_action/#{@cta_id}"
|
70
|
+
end
|
71
|
+
|
72
|
+
it "should PUT the correct url and return a response" do
|
73
|
+
request_data = {:text => 'joinnnnnn', id: @cta_id}
|
74
|
+
|
75
|
+
RestClient.should_receive(:put).with(
|
76
|
+
@url,
|
77
|
+
MultiJson.encode(request_data),
|
78
|
+
{'SproutVideo-Api-Key' => @api_key}).and_return(@msg)
|
79
|
+
data = request_data
|
80
|
+
data[:video_id] = @video_id
|
81
|
+
Sproutvideo::CallToAction.update(data).class.should == Sproutvideo::Response
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
describe "#delete" do
|
86
|
+
before(:each) do
|
87
|
+
@cta_id = '12'
|
88
|
+
@url = "#{Sproutvideo.base_url}/videos/#{@video_id}/calls_to_action/#{@cta_id}"
|
89
|
+
end
|
90
|
+
|
91
|
+
it "should DELETE the correct url and return a response" do
|
92
|
+
RestClient.should_receive(:delete).with(
|
93
|
+
@url,
|
94
|
+
{'SproutVideo-Api-Key' => @api_key, :params => { id: @cta_id }}).and_return(@msg)
|
95
|
+
Sproutvideo::CallToAction.destroy(id: @cta_id, video_id: @video_id).class.should == Sproutvideo::Response
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
@@ -0,0 +1,107 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper.rb')
|
2
|
+
describe Sproutvideo::Folder do
|
3
|
+
before(:each) do
|
4
|
+
@api_key = 'abc123'
|
5
|
+
Sproutvideo.api_key = @api_key
|
6
|
+
Sproutvideo.base_url = 'https://api.sproutvideo.com/v1'
|
7
|
+
@msg = mock(:to_s => "{}", :code => 200)
|
8
|
+
end
|
9
|
+
|
10
|
+
describe "#create" do
|
11
|
+
before(:each) do
|
12
|
+
@url = "#{Sproutvideo.base_url}/folders"
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should POST the correct url and return a response" do
|
16
|
+
data = { :name => 'test folder', :parent_id => 'abc123' }
|
17
|
+
RestClient.should_receive(:post).with(
|
18
|
+
@url,
|
19
|
+
MultiJson.encode(data),
|
20
|
+
{'SproutVideo-Api-Key' => @api_key}).and_return(@msg)
|
21
|
+
Sproutvideo::Folder.create(data).class.should == Sproutvideo::Response
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe "#list" do
|
26
|
+
before(:each) do
|
27
|
+
@url = "#{Sproutvideo.base_url}/folders"
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should GET the correct url and return a response" do
|
31
|
+
|
32
|
+
RestClient.should_receive(:get).with(
|
33
|
+
@url,
|
34
|
+
{'SproutVideo-Api-Key' => @api_key, :params => {:page => 1, :per_page => 25}}).and_return(@msg)
|
35
|
+
Sproutvideo::Folder.list.class.should == Sproutvideo::Response
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should merge params" do
|
39
|
+
RestClient.should_receive(:get).with(
|
40
|
+
@url,
|
41
|
+
{'SproutVideo-Api-Key' => @api_key, :params => {:page => 1, :per_page => 25, :foo => 'bar'}}).and_return(@msg)
|
42
|
+
Sproutvideo::Folder.list(:foo => 'bar')
|
43
|
+
end
|
44
|
+
|
45
|
+
it "should use pagination params" do
|
46
|
+
RestClient.should_receive(:get).with(
|
47
|
+
@url,
|
48
|
+
{'SproutVideo-Api-Key' => @api_key, :params => {:page => 2, :per_page => 5}}).and_return(@msg)
|
49
|
+
Sproutvideo::Folder.list(:page => 2, :per_page => 5)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
describe "#details" do
|
54
|
+
before(:each) do
|
55
|
+
@folder_id = 1
|
56
|
+
@url = "#{Sproutvideo.base_url}/folders/#{@folder_id}"
|
57
|
+
end
|
58
|
+
|
59
|
+
it "should get the correct url and return a response" do
|
60
|
+
RestClient.should_receive(:get).with(
|
61
|
+
@url,
|
62
|
+
{'SproutVideo-Api-Key' => @api_key, :params => {}}).and_return(@msg)
|
63
|
+
Sproutvideo::Folder.details(@folder_id).class.should == Sproutvideo::Response
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
describe "#update" do
|
68
|
+
before(:each) do
|
69
|
+
@folder_id = 1
|
70
|
+
@url = "#{Sproutvideo.base_url}/folders/#{@folder_id}"
|
71
|
+
end
|
72
|
+
|
73
|
+
it "should PUT the correct url and return a response" do
|
74
|
+
data = {:name => 'new name'}
|
75
|
+
|
76
|
+
RestClient.should_receive(:put).with(
|
77
|
+
@url,
|
78
|
+
MultiJson.encode(data),
|
79
|
+
{'SproutVideo-Api-Key' => @api_key}).and_return(@msg)
|
80
|
+
Sproutvideo::Folder.update(@folder_id, data).class.should == Sproutvideo::Response
|
81
|
+
end
|
82
|
+
|
83
|
+
end
|
84
|
+
|
85
|
+
describe "#delete" do
|
86
|
+
before(:each) do
|
87
|
+
@folder_id = 1
|
88
|
+
@url = "#{Sproutvideo.base_url}/folders/#{@folder_id}"
|
89
|
+
end
|
90
|
+
|
91
|
+
it "should DELETE the correct url and return a response" do
|
92
|
+
RestClient.should_receive(:delete).with(
|
93
|
+
@url,
|
94
|
+
{'SproutVideo-Api-Key' => @api_key, :params =>{}}).and_return(@msg)
|
95
|
+
Sproutvideo::Folder.destroy(@folder_id).class.should == Sproutvideo::Response
|
96
|
+
end
|
97
|
+
|
98
|
+
it 'should delete with the proper params' do
|
99
|
+
RestClient.should_receive(:delete).with(
|
100
|
+
@url,
|
101
|
+
{'SproutVideo-Api-Key' => @api_key, :params => {delete_all: true}}
|
102
|
+
).and_return(@msg)
|
103
|
+
Sproutvideo::Folder.destroy(@folder_id, delete_all: true).class.should == Sproutvideo::Response
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
end
|
@@ -0,0 +1,152 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper.rb')
|
2
|
+
describe Sproutvideo::LiveStream do
|
3
|
+
before(:each) do
|
4
|
+
@api_key = 'abc123'
|
5
|
+
Sproutvideo.api_key = @api_key
|
6
|
+
Sproutvideo.base_url = 'https://api.sproutvideo.com/v1'
|
7
|
+
@msg = mock(:to_s => "{}", :code => 200)
|
8
|
+
end
|
9
|
+
|
10
|
+
describe "#create" do
|
11
|
+
it "should POST the correct url and return a response" do
|
12
|
+
data = { title: 'newww live stream'}
|
13
|
+
RestClient.should_receive(:post).with(
|
14
|
+
"#{Sproutvideo.base_url}/live_streams",
|
15
|
+
MultiJson.encode(data),
|
16
|
+
{'SproutVideo-Api-Key' => @api_key}).and_return(@msg)
|
17
|
+
|
18
|
+
Sproutvideo::LiveStream.create(data).class.should == Sproutvideo::Response
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should POST the correct url with file and return a response" do
|
22
|
+
File.open("upload_test", "w+") do |f|
|
23
|
+
f.syswrite("upload!")
|
24
|
+
end
|
25
|
+
|
26
|
+
file = File.open('upload_test')
|
27
|
+
|
28
|
+
File.stub!(:open).with('upload_test').and_yield(file)
|
29
|
+
|
30
|
+
RestClient.should_receive(:post).with(
|
31
|
+
"#{Sproutvideo.base_url}/live_streams",
|
32
|
+
{:custom_poster_frame => file, :title => 'test title'},
|
33
|
+
{'SproutVideo-Api-Key' => @api_key, :timeout => 18000}).and_return(@msg)
|
34
|
+
Sproutvideo::LiveStream.create({:title => 'test title', :custom_poster_frame => 'upload_test' }).class.should == Sproutvideo::Response
|
35
|
+
|
36
|
+
FileUtils.rm('upload_test')
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
describe "#list" do
|
41
|
+
before(:each) do
|
42
|
+
@url = "#{Sproutvideo.base_url}/live_streams"
|
43
|
+
end
|
44
|
+
|
45
|
+
it "should GET the correct url and return a response" do
|
46
|
+
|
47
|
+
RestClient.should_receive(:get).with(
|
48
|
+
@url,
|
49
|
+
{'SproutVideo-Api-Key' => @api_key, :params => {:page => 1, :per_page => 25}}).and_return(@msg)
|
50
|
+
Sproutvideo::LiveStream.list.class.should == Sproutvideo::Response
|
51
|
+
end
|
52
|
+
|
53
|
+
it "should merge params" do
|
54
|
+
RestClient.should_receive(:get).with(
|
55
|
+
@url,
|
56
|
+
{'SproutVideo-Api-Key' => @api_key, :params => {:page => 1, :per_page => 25, :foo => 'bar'}}).and_return(@msg)
|
57
|
+
Sproutvideo::LiveStream.list(:foo => 'bar')
|
58
|
+
end
|
59
|
+
|
60
|
+
it "should use pagination params" do
|
61
|
+
RestClient.should_receive(:get).with(
|
62
|
+
@url,
|
63
|
+
{'SproutVideo-Api-Key' => @api_key, :params => {:page => 2, :per_page => 5}}).and_return(@msg)
|
64
|
+
Sproutvideo::LiveStream.list(:page => 2, :per_page => 5)
|
65
|
+
end
|
66
|
+
|
67
|
+
it "should request live_streams for a tag if tag_id is passed in" do
|
68
|
+
RestClient.should_receive(:get).with(
|
69
|
+
@url,
|
70
|
+
{'SproutVideo-Api-Key' => @api_key, :params => {:page => 1, :per_page => 25, :tag_id => 'asdf'}}).and_return(@msg)
|
71
|
+
Sproutvideo::LiveStream.list(:tag_id => 'asdf')
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
describe "#details" do
|
76
|
+
before(:each) do
|
77
|
+
@live_stream_id = 1
|
78
|
+
@url = "#{Sproutvideo.base_url}/live_streams/#{@live_stream_id}"
|
79
|
+
end
|
80
|
+
|
81
|
+
it "should get the correct url and return a response" do
|
82
|
+
RestClient.should_receive(:get).with(
|
83
|
+
@url,
|
84
|
+
{'SproutVideo-Api-Key' => @api_key, :params => {}}).and_return(@msg)
|
85
|
+
Sproutvideo::LiveStream.details(@live_stream_id).class.should == Sproutvideo::Response
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
describe "#update" do
|
90
|
+
before(:each) do
|
91
|
+
@live_stream_id = 1
|
92
|
+
@url = "#{Sproutvideo.base_url}/live_streams/#{@live_stream_id}"
|
93
|
+
end
|
94
|
+
|
95
|
+
it "should PUT the correct url and return a response" do
|
96
|
+
data = {:title => 'new title'}
|
97
|
+
|
98
|
+
RestClient.should_receive(:put).with(
|
99
|
+
@url,
|
100
|
+
MultiJson.encode(data),
|
101
|
+
{'SproutVideo-Api-Key' => @api_key}).and_return(@msg)
|
102
|
+
Sproutvideo::LiveStream.update(@live_stream_id, data).class.should == Sproutvideo::Response
|
103
|
+
end
|
104
|
+
|
105
|
+
it "should PUT the correct url and return a response" do
|
106
|
+
File.open("upload_test2", "w+") do |f|
|
107
|
+
f.syswrite("upload!")
|
108
|
+
end
|
109
|
+
|
110
|
+
file = File.open('upload_test2')
|
111
|
+
|
112
|
+
File.stub!(:open).with('upload_test2').and_yield(file)
|
113
|
+
|
114
|
+
RestClient.should_receive(:put).with(
|
115
|
+
"#{Sproutvideo.base_url}/live_streams/#{@live_stream_id}",
|
116
|
+
{:custom_poster_frame => file, :title => 'test title'},
|
117
|
+
{'SproutVideo-Api-Key' => @api_key, :timeout => 18000}).and_return(@msg)
|
118
|
+
Sproutvideo::LiveStream.update(@live_stream_id, {:title => 'test title', :custom_poster_frame => 'upload_test2' }).class.should == Sproutvideo::Response
|
119
|
+
|
120
|
+
FileUtils.rm('upload_test2')
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
describe "#delete" do
|
125
|
+
before(:each) do
|
126
|
+
@live_stream_id = 1
|
127
|
+
@url = "#{Sproutvideo.base_url}/live_streams/#{@live_stream_id}"
|
128
|
+
end
|
129
|
+
|
130
|
+
it "should DELETE the correct url and return a response" do
|
131
|
+
RestClient.should_receive(:delete).with(
|
132
|
+
@url,
|
133
|
+
{'SproutVideo-Api-Key' => @api_key, :params => {}}).and_return(@msg)
|
134
|
+
Sproutvideo::LiveStream.destroy(@live_stream_id).class.should == Sproutvideo::Response
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
describe "#end_stream" do
|
139
|
+
before(:each) do
|
140
|
+
@live_stream_id = 1
|
141
|
+
@url = "#{Sproutvideo.base_url}/live_streams/#{@live_stream_id}/end_stream"
|
142
|
+
end
|
143
|
+
|
144
|
+
it "should PUT the correct url and return a response" do
|
145
|
+
RestClient.should_receive(:put).with(
|
146
|
+
@url,
|
147
|
+
"{}",
|
148
|
+
{'SproutVideo-Api-Key' => @api_key}).and_return(@msg)
|
149
|
+
Sproutvideo::LiveStream.end_stream(@live_stream_id).class.should == Sproutvideo::Response
|
150
|
+
end
|
151
|
+
end
|
152
|
+
end
|
@@ -91,7 +91,7 @@ describe Sproutvideo::Login do
|
|
91
91
|
it "should DELETE the correct url and return a response" do
|
92
92
|
RestClient.should_receive(:delete).with(
|
93
93
|
@url,
|
94
|
-
{'SproutVideo-Api-Key' => @api_key}).and_return(@msg)
|
94
|
+
{'SproutVideo-Api-Key' => @api_key, :params => {}}).and_return(@msg)
|
95
95
|
Sproutvideo::Login.destroy(@login_id).class.should == Sproutvideo::Response
|
96
96
|
end
|
97
97
|
end
|
@@ -91,7 +91,7 @@ describe Sproutvideo::Playlist do
|
|
91
91
|
it "should DELETE the correct url and return a response" do
|
92
92
|
RestClient.should_receive(:delete).with(
|
93
93
|
@url,
|
94
|
-
{'SproutVideo-Api-Key' => @api_key}).and_return(@msg)
|
94
|
+
{'SproutVideo-Api-Key' => @api_key, :params => {}}).and_return(@msg)
|
95
95
|
Sproutvideo::Playlist.destroy(@playlist_id).class.should == Sproutvideo::Response
|
96
96
|
end
|
97
97
|
end
|