proteus_client 0.0.7 → 1.0.1
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.
- data/lib/proteus_client.rb +7 -1
- data/lib/proteus_client/config.rb +4 -3
- data/lib/proteus_client/models/recording.rb +12 -0
- data/lib/proteus_client/models/thumbnail.rb +11 -0
- data/lib/proteus_client/models/version.rb +11 -0
- data/lib/proteus_client/models/video.rb +11 -0
- data/lib/proteus_client/proxy.rb +50 -69
- data/lib/proteus_client/representers/recording.rb +23 -0
- data/lib/proteus_client/representers/video.rb +46 -0
- metadata +58 -6
- data/spec/proteus_client_spec.rb +0 -242
data/lib/proteus_client.rb
CHANGED
@@ -3,6 +3,12 @@ require 'rest_client'
|
|
3
3
|
|
4
4
|
require_relative 'proteus_client/config'
|
5
5
|
require_relative 'proteus_client/proxy'
|
6
|
+
require_relative 'proteus_client/representers/video'
|
7
|
+
require_relative 'proteus_client/representers/recording'
|
8
|
+
require_relative 'proteus_client/models/recording'
|
9
|
+
require_relative 'proteus_client/models/video'
|
10
|
+
require_relative 'proteus_client/models/thumbnail'
|
11
|
+
require_relative 'proteus_client/models/version'
|
6
12
|
|
7
13
|
# Provides an interface to use Proteus rest services features
|
8
14
|
#
|
@@ -12,4 +18,4 @@ module ProteusClient
|
|
12
18
|
@config ||= ProteusClient::Config.new
|
13
19
|
end
|
14
20
|
|
15
|
-
end
|
21
|
+
end
|
@@ -2,11 +2,12 @@ module ProteusClient
|
|
2
2
|
|
3
3
|
# Used to configure default values used for creating a ProteusClient::Proxy
|
4
4
|
# @example Configuring values
|
5
|
-
# ProteusClient.config.
|
5
|
+
# ProteusClient.config.root = "http://localhost:9292"
|
6
6
|
# ProteusClient.config.api_key= "api_key"
|
7
|
+
# ProteusClient.config.account = "account"
|
7
8
|
#
|
8
9
|
class Config
|
9
|
-
attr_accessor :
|
10
|
+
attr_accessor :root, :api_key, :account
|
10
11
|
end
|
11
12
|
|
12
|
-
end
|
13
|
+
end
|
data/lib/proteus_client/proxy.rb
CHANGED
@@ -3,116 +3,97 @@ module ProteusClient
|
|
3
3
|
# Provides an interface for Proteus REST service to encode videos
|
4
4
|
# @example Creating a new proxy
|
5
5
|
# ProteusClient::Proxy.new
|
6
|
-
# ProteusClient::Proxy.new({
|
7
|
-
#
|
8
|
-
# @example Testing service
|
9
|
-
# proteus_client.test_api #=> {message: 'Welcome to Proteus'}
|
6
|
+
# ProteusClient::Proxy.new({account: "", api_key: "", root: "http://localhost:9292"})
|
10
7
|
#
|
11
8
|
# @example Calling a method
|
12
9
|
# proteus_client.create_video("video_id","type")
|
13
10
|
#
|
14
11
|
# @raise [APIKeyNotDefined] if api_key is not defined in ProteusClient.config or sent as param
|
15
|
-
# @raise [
|
12
|
+
# @raise [RootNotDefined] if root is not defined in ProteusClient.config or sent as param
|
16
13
|
# @raise [RestClient::Exception] if status code returned from services is not in 200..207
|
17
14
|
#
|
18
15
|
class Proxy
|
19
16
|
|
20
17
|
def initialize(options = {})
|
21
18
|
options = {
|
19
|
+
account: ProteusClient.config.account,
|
22
20
|
api_key: ProteusClient.config.api_key,
|
23
|
-
|
21
|
+
root: ProteusClient.config.root
|
24
22
|
}.merge(options)
|
25
23
|
|
26
|
-
raise "
|
27
|
-
raise "
|
24
|
+
raise "AccountNotDefined" unless options[:account]
|
25
|
+
raise "APIKeyNotDefined" unless options[:api_key]
|
26
|
+
raise "RootNotDefined" unless options[:root]
|
28
27
|
|
29
|
-
@
|
30
|
-
@
|
28
|
+
@user = options[:account]
|
29
|
+
@password = options[:api_key]
|
30
|
+
@root = resource(options[:root])
|
31
31
|
end
|
32
32
|
|
33
|
-
def
|
34
|
-
|
35
|
-
|
36
|
-
{ message: response.body }
|
37
|
-
end
|
33
|
+
def create_recordings
|
34
|
+
recordings = link(@root, 'proteus:recordings')
|
38
35
|
|
39
|
-
|
40
|
-
|
36
|
+
response = resource(recordings).post({})
|
37
|
+
properties = Representers::Recording.new(response).to_hash
|
41
38
|
|
42
|
-
|
43
|
-
submit_request_and_parse_json(:post, '/video_locations', params)
|
44
|
-
format_video_locations(video_locations)
|
39
|
+
ProteusClient::Recording.new(properties)
|
45
40
|
end
|
46
41
|
|
47
|
-
def
|
48
|
-
|
49
|
-
|
50
|
-
count: count)
|
51
|
-
video_locations.map { |v| format_video_locations(v) }
|
52
|
-
end
|
42
|
+
def get_recording(id)
|
43
|
+
url = link(@root, 'proteus:recording')
|
44
|
+
recording = expand_templated_route(url, 'id', id)
|
53
45
|
|
54
|
-
|
55
|
-
|
56
|
-
submit_request_and_parse_json(:post, '/videos',
|
57
|
-
video_locations_id: video_locations_id,
|
58
|
-
type: type)
|
46
|
+
response = resource(recording).get
|
47
|
+
properties = Representers::Recording.new(response).to_hash
|
59
48
|
|
60
|
-
|
49
|
+
ProteusClient::Recording.new(properties)
|
61
50
|
end
|
62
51
|
|
63
|
-
def
|
64
|
-
|
65
|
-
params[:version_settings] = settings if settings
|
66
|
-
params[:output_type] = output_type
|
52
|
+
def create_video(url, solution, version_name)
|
53
|
+
videos = link(@root, 'proteus:videos')
|
67
54
|
|
68
|
-
|
55
|
+
params = { url: url, solution: solution, version_name: version_name }
|
56
|
+
response = resource(videos).post(params)
|
57
|
+
properties = Representers::Video.new(response).to_hash
|
69
58
|
|
70
|
-
|
59
|
+
ProteusClient::Video.new(properties)
|
71
60
|
end
|
72
61
|
|
73
|
-
def get_video(
|
74
|
-
|
75
|
-
|
62
|
+
def get_video(id)
|
63
|
+
url = link(@root, 'proteus:video')
|
64
|
+
video = expand_templated_route(url, 'id', id)
|
65
|
+
|
66
|
+
response = resource(video).get
|
67
|
+
properties = Representers::Video.new(response).to_hash
|
76
68
|
|
77
|
-
|
78
|
-
submit_request_and_parse_json(:get_raw, "/videos", ids: video_ids)
|
69
|
+
ProteusClient::Video.new(properties)
|
79
70
|
end
|
80
71
|
|
81
|
-
def
|
82
|
-
url
|
83
|
-
|
72
|
+
def create_version(video_id, version_name, solution)
|
73
|
+
url = link(@root, 'proteus:video')
|
74
|
+
video = expand_templated_route(url, 'id', video_id)
|
75
|
+
versions = link(resource(video), 'proteus:video:versions')
|
76
|
+
|
77
|
+
params = { version_name: version_name, solution: solution }
|
78
|
+
response = resource(versions).post(params)
|
79
|
+
|
80
|
+
{message: 'success'}
|
84
81
|
end
|
85
82
|
|
86
83
|
private
|
87
84
|
|
88
|
-
def
|
89
|
-
|
90
|
-
|
85
|
+
def resource(url)
|
86
|
+
RestClient::Resource.new(url, content_type: :json,
|
87
|
+
user: @user, password: @password)
|
91
88
|
end
|
92
89
|
|
93
|
-
def
|
94
|
-
|
95
|
-
|
96
|
-
case method
|
97
|
-
when :get
|
98
|
-
@domain[route].get(params: params)
|
99
|
-
when :get_raw
|
100
|
-
string_params = RestClient::Payload::UrlEncoded.new(params).to_s
|
101
|
-
@domain["#{route}?#{string_params}"].get()
|
102
|
-
when :post
|
103
|
-
@domain[route].post(params, content_type: :json)
|
104
|
-
else
|
105
|
-
raise 'Undefined method'
|
106
|
-
end
|
90
|
+
def link(resource, link)
|
91
|
+
JSON.parse(resource.get)['_links'][link]['href']
|
107
92
|
end
|
108
93
|
|
109
|
-
def
|
110
|
-
|
111
|
-
stream: video_locations['url_stream'] }
|
112
|
-
|
113
|
-
{ video_locations_id: video_locations['_id'], urls: urls }
|
94
|
+
def expand_templated_route(url, key, value)
|
95
|
+
url.gsub("{/#{key.to_s}}", "/#{value}")
|
114
96
|
end
|
115
97
|
|
116
98
|
end
|
117
|
-
|
118
99
|
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module ProteusClient
|
2
|
+
module Representers
|
3
|
+
class Recording
|
4
|
+
|
5
|
+
def initialize(raw_response)
|
6
|
+
response = JSON.parse(raw_response)
|
7
|
+
|
8
|
+
@properties = {
|
9
|
+
id: response['id'],
|
10
|
+
adobe_rtmpe_file: response['_links']['adobe_rtmpe:file']['href'],
|
11
|
+
adobe_rtmpe_write: response['_links']['adobe_rtmpe:write']['href'],
|
12
|
+
adobe_rtmpe_read: response['_links']['adobe_rtmpe:read']['href'],
|
13
|
+
generic_https: response['_links']['generic_https']['href']
|
14
|
+
}
|
15
|
+
end
|
16
|
+
|
17
|
+
def to_hash
|
18
|
+
@properties
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
module ProteusClient
|
2
|
+
module Representers
|
3
|
+
class Video
|
4
|
+
|
5
|
+
def initialize(raw_response)
|
6
|
+
response = JSON.parse(raw_response)
|
7
|
+
versions_hash = response['_embedded']['proteus:video:versions']
|
8
|
+
thumbnails_hash = response['_embedded']['proteus:video:thumbnails']
|
9
|
+
|
10
|
+
@properties = {
|
11
|
+
id: response['id'],
|
12
|
+
thumbnails: create_thumbnails(thumbnails_hash),
|
13
|
+
versions: create_versions(versions_hash)
|
14
|
+
}
|
15
|
+
end
|
16
|
+
|
17
|
+
def to_hash
|
18
|
+
@properties
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def create_thumbnails(thumbnails_hash)
|
24
|
+
thumbnails_hash.map do |hash|
|
25
|
+
options = {
|
26
|
+
size: hash['name'],
|
27
|
+
url: hash['_links']['alternate']['href']
|
28
|
+
}
|
29
|
+
ProteusClient::Thumbnail.new(options)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def create_versions(versions_hash)
|
34
|
+
versions_hash.map do |hash|
|
35
|
+
options = {
|
36
|
+
name: hash['name'],
|
37
|
+
solution: hash['solution'],
|
38
|
+
url: hash['_links']['alternate']['href']
|
39
|
+
}
|
40
|
+
ProteusClient::Version.new(options)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: proteus_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.0.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-03-07 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: json
|
@@ -43,6 +43,22 @@ dependencies:
|
|
43
43
|
- - ~>
|
44
44
|
- !ruby/object:Gem::Version
|
45
45
|
version: 1.6.7
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: rake
|
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'
|
46
62
|
- !ruby/object:Gem::Dependency
|
47
63
|
name: rspec
|
48
64
|
requirement: !ruby/object:Gem::Requirement
|
@@ -75,16 +91,53 @@ dependencies:
|
|
75
91
|
- - ! '>='
|
76
92
|
- !ruby/object:Gem::Version
|
77
93
|
version: '0'
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: vcr
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ! '>='
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
type: :development
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
- !ruby/object:Gem::Dependency
|
111
|
+
name: webmock
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
113
|
+
none: false
|
114
|
+
requirements:
|
115
|
+
- - ! '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
122
|
+
requirements:
|
123
|
+
- - ! '>='
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0'
|
78
126
|
description: It provides an interface to use proteus features
|
79
127
|
email: 1.27201@gmail.com
|
80
128
|
executables: []
|
81
129
|
extensions: []
|
82
130
|
extra_rdoc_files: []
|
83
131
|
files:
|
84
|
-
- lib/proteus_client.rb
|
132
|
+
- lib/proteus_client/representers/recording.rb
|
133
|
+
- lib/proteus_client/representers/video.rb
|
134
|
+
- lib/proteus_client/models/recording.rb
|
135
|
+
- lib/proteus_client/models/thumbnail.rb
|
136
|
+
- lib/proteus_client/models/version.rb
|
137
|
+
- lib/proteus_client/models/video.rb
|
85
138
|
- lib/proteus_client/config.rb
|
86
139
|
- lib/proteus_client/proxy.rb
|
87
|
-
-
|
140
|
+
- lib/proteus_client.rb
|
88
141
|
homepage: https://github.com/solojavier/proteus_client
|
89
142
|
licenses: []
|
90
143
|
post_install_message:
|
@@ -109,6 +162,5 @@ rubygems_version: 1.8.21
|
|
109
162
|
signing_key:
|
110
163
|
specification_version: 3
|
111
164
|
summary: Ruby client to use proteus rest service
|
112
|
-
test_files:
|
113
|
-
- spec/proteus_client_spec.rb
|
165
|
+
test_files: []
|
114
166
|
has_rdoc:
|
data/spec/proteus_client_spec.rb
DELETED
@@ -1,242 +0,0 @@
|
|
1
|
-
require 'simplecov'
|
2
|
-
SimpleCov.start
|
3
|
-
|
4
|
-
require 'stubs'
|
5
|
-
require_relative '../lib/proteus_client'
|
6
|
-
|
7
|
-
describe ProteusClient::Proxy do
|
8
|
-
|
9
|
-
let(:api_key) { "api_key" }
|
10
|
-
|
11
|
-
let(:proteus_client_wrong_api) do
|
12
|
-
described_class.new(domain: 'http://localhost:9292', api_key: 'wrong_api')
|
13
|
-
end
|
14
|
-
|
15
|
-
let(:proteus_client) do
|
16
|
-
ProteusClient.config.domain = 'http://localhost:9292'
|
17
|
-
ProteusClient.config.api_key = 'api_key'
|
18
|
-
described_class.new()
|
19
|
-
end
|
20
|
-
|
21
|
-
it "creates a new instance of proteus with correct api_key" do
|
22
|
-
proteus_client
|
23
|
-
ProteusClient.config.api_key.should == api_key
|
24
|
-
end
|
25
|
-
|
26
|
-
context 'call to test_api' do
|
27
|
-
|
28
|
-
before(:all) do
|
29
|
-
stub_response(:get, '/', 200, 'Welcome to proteus')
|
30
|
-
@response = proteus_client.test_api
|
31
|
-
end
|
32
|
-
|
33
|
-
it "returns correct message" do
|
34
|
-
@response[:message].should == 'Welcome to proteus'
|
35
|
-
end
|
36
|
-
|
37
|
-
end
|
38
|
-
|
39
|
-
context 'call to create_video_locations'do
|
40
|
-
|
41
|
-
before(:all) do
|
42
|
-
stub_create_video_locations
|
43
|
-
@response = proteus_client.create_video_locations
|
44
|
-
end
|
45
|
-
|
46
|
-
it "returns a hash" do
|
47
|
-
@response.class.should == Hash
|
48
|
-
end
|
49
|
-
|
50
|
-
it "returns video_locations_id" do
|
51
|
-
@response[:video_locations_id].should == '4fe0f752831a9d08bb000010'
|
52
|
-
end
|
53
|
-
|
54
|
-
it "returns urls" do
|
55
|
-
@response[:urls].should ==
|
56
|
-
{ direct: 'direct/4fe0f752831a9d08bb000010.flv',
|
57
|
-
stream: 'stream/4fe0f752831a9d08bb000010.flv'}
|
58
|
-
end
|
59
|
-
|
60
|
-
it "creates with id sent" do
|
61
|
-
id = '4fe0f752831a9d08bb000011'
|
62
|
-
stub_create_video_locations_with_id(id)
|
63
|
-
response = proteus_client.create_video_locations(id)
|
64
|
-
|
65
|
-
response[:video_locations_id].should == id
|
66
|
-
end
|
67
|
-
|
68
|
-
end
|
69
|
-
|
70
|
-
context 'call to create_multiple_video_locations' do
|
71
|
-
|
72
|
-
before(:all) do
|
73
|
-
stub_create_multiple_video_locations
|
74
|
-
@response = proteus_client.create_multiple_video_locations(2)
|
75
|
-
end
|
76
|
-
|
77
|
-
it "returns an array with two hashes" do
|
78
|
-
@response.class.should == Array
|
79
|
-
@response.size.should == 2
|
80
|
-
@response[0].class.should == Hash
|
81
|
-
end
|
82
|
-
|
83
|
-
it "returns video_locations_id" do
|
84
|
-
@response[0][:video_locations_id].should == '4fe0f752831a9d08bb000010'
|
85
|
-
end
|
86
|
-
|
87
|
-
it "returns urls" do
|
88
|
-
@response[0][:urls].should ==
|
89
|
-
{ direct: 'direct/4fe0f752831a9d08bb000010.flv',
|
90
|
-
stream: 'stream/4fe0f752831a9d08bb000010.flv'}
|
91
|
-
end
|
92
|
-
|
93
|
-
end
|
94
|
-
|
95
|
-
context 'call to create_video'do
|
96
|
-
|
97
|
-
before(:all) do
|
98
|
-
stub_create_video
|
99
|
-
@response = proteus_client.
|
100
|
-
create_video('4fe0f752831a9d08bb000010','direct')
|
101
|
-
end
|
102
|
-
|
103
|
-
it "returns a hash" do
|
104
|
-
@response.class.should == Hash
|
105
|
-
end
|
106
|
-
|
107
|
-
it "returns video url" do
|
108
|
-
@response[:url].should == 'direct/4fe0f752831a9d08bb000010.flv'
|
109
|
-
end
|
110
|
-
|
111
|
-
end
|
112
|
-
|
113
|
-
context 'call to create_video_versions'do
|
114
|
-
|
115
|
-
context 'with valid id' do
|
116
|
-
|
117
|
-
before(:all) do
|
118
|
-
stub_response_with_params(:post, '/videos/4fe0f752831a9d08bb000010/versions',
|
119
|
-
200, '', output_type: 'direct')
|
120
|
-
@response = proteus_client.
|
121
|
-
create_video_versions('4fe0f752831a9d08bb000010', 'direct')
|
122
|
-
end
|
123
|
-
|
124
|
-
it "returns success message" do
|
125
|
-
@response[:message].should == 'success'
|
126
|
-
end
|
127
|
-
|
128
|
-
end
|
129
|
-
|
130
|
-
context 'with valid id and type' do
|
131
|
-
|
132
|
-
before(:all) do
|
133
|
-
stub_response_with_params(:post, '/videos/4fe0f752831a9d08bb000010/versions',
|
134
|
-
200, '', version_settings: 'mobile', output_type: 'stream')
|
135
|
-
@response = proteus_client.
|
136
|
-
create_video_versions('4fe0f752831a9d08bb000010', 'stream', 'mobile')
|
137
|
-
end
|
138
|
-
|
139
|
-
it "returns true" do
|
140
|
-
@response[:message].should == 'success'
|
141
|
-
end
|
142
|
-
|
143
|
-
end
|
144
|
-
|
145
|
-
end
|
146
|
-
|
147
|
-
context 'call to get_video'do
|
148
|
-
|
149
|
-
before(:all) do
|
150
|
-
stub_get_video
|
151
|
-
@response = proteus_client.get_video('4fe0f752831a9d08bb000010')
|
152
|
-
end
|
153
|
-
|
154
|
-
it "returns a hash" do
|
155
|
-
@response.class.should == Hash
|
156
|
-
end
|
157
|
-
|
158
|
-
it "returns video with correct format" do
|
159
|
-
@response['url'].class.should == String
|
160
|
-
@response['duration'].class.should == Fixnum
|
161
|
-
@response['versions'].class.should == Array
|
162
|
-
@response['versions'][0].class.should == Hash
|
163
|
-
end
|
164
|
-
|
165
|
-
end
|
166
|
-
|
167
|
-
context 'call to get_videos' do
|
168
|
-
|
169
|
-
before(:all) do
|
170
|
-
stub_get_videos
|
171
|
-
@response = proteus_client.get_videos(%w{4fe0f752831a9d08bb000010
|
172
|
-
4fe0f752831a9d08bb000010})
|
173
|
-
end
|
174
|
-
|
175
|
-
it "returns an array with hashes" do
|
176
|
-
@response.class.should == Array
|
177
|
-
@response.size.should == 2
|
178
|
-
@response.first.class.should == Hash
|
179
|
-
end
|
180
|
-
|
181
|
-
it "returns videos with correct format" do
|
182
|
-
video = @response.first
|
183
|
-
|
184
|
-
video['url'].class.should == String
|
185
|
-
video['duration'].class.should == Fixnum
|
186
|
-
video['versions'].class.should == Array
|
187
|
-
video['versions'][0].class.should == Hash
|
188
|
-
end
|
189
|
-
|
190
|
-
end
|
191
|
-
|
192
|
-
context 'call to get_video_locations' do
|
193
|
-
|
194
|
-
context 'with valid arguments' do
|
195
|
-
|
196
|
-
before(:all) do
|
197
|
-
stub_get_video_locations
|
198
|
-
@response = proteus_client.
|
199
|
-
get_video_locations('4fe0f752831a9d08bb000010')
|
200
|
-
end
|
201
|
-
|
202
|
-
it "returns a hash" do
|
203
|
-
@response.class.should == Hash
|
204
|
-
end
|
205
|
-
|
206
|
-
it "returns video with correct format" do
|
207
|
-
@response['url_direct'].class.should == String
|
208
|
-
@response['url_stream'].class.should == String
|
209
|
-
end
|
210
|
-
|
211
|
-
end
|
212
|
-
|
213
|
-
end
|
214
|
-
|
215
|
-
context 'submit request' do
|
216
|
-
|
217
|
-
it 'call with :get works returns a correct response' do
|
218
|
-
stub_resource(:get)
|
219
|
-
proteus_client.send(:submit_request, :get, '/', {})
|
220
|
-
.class.should == String
|
221
|
-
end
|
222
|
-
|
223
|
-
it 'call with :post works returns a correct response' do
|
224
|
-
stub_resource(:post)
|
225
|
-
proteus_client.send(:submit_request, :post, '/', {})
|
226
|
-
.class.should == String
|
227
|
-
end
|
228
|
-
|
229
|
-
it 'call with :get works returns a correct response' do
|
230
|
-
stub_resource(:get)
|
231
|
-
proteus_client.send(:submit_request, :get_raw, '/', {})
|
232
|
-
.class.should == String
|
233
|
-
end
|
234
|
-
|
235
|
-
it 'call with not defined method works raises exception' do
|
236
|
-
lambda { proteus_client.send(:submit_request, :put, '/', {}) }.
|
237
|
-
should raise_error
|
238
|
-
end
|
239
|
-
|
240
|
-
end
|
241
|
-
|
242
|
-
end
|