helix 0.0.2.7.pre → 0.0.2.8.pre
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/README.md +11 -74
- data/lib/helix.rb +2 -0
- data/lib/helix/album.rb +1 -1
- data/lib/helix/base.rb +23 -3
- data/lib/helix/config.rb +38 -4
- data/lib/helix/durationed_media.rb +5 -5
- data/lib/helix/library.rb +3 -1
- data/lib/helix/media.rb +3 -62
- data/lib/helix/restful.rb +89 -0
- data/lib/helix/track.rb +2 -0
- data/lib/helix/uploadable.rb +52 -0
- data/lib/helix/video.rb +42 -16
- data/spec/album_spec.rb +2 -1
- data/spec/base_spec.rb +50 -73
- data/spec/config_spec.rb +82 -1
- data/spec/durationed_media_spec.rb +2 -1
- data/spec/image_spec.rb +2 -1
- data/spec/library_spec.rb +14 -9
- data/spec/media_spec.rb +80 -43
- data/spec/tag_spec.rb +1 -1
- data/spec/track_spec.rb +117 -5
- data/spec/video_spec.rb +188 -8
- metadata +24 -23
data/spec/image_spec.rb
CHANGED
@@ -5,7 +5,8 @@ describe Helix::Image do
|
|
5
5
|
let(:klass) { Helix::Image }
|
6
6
|
|
7
7
|
subject { klass }
|
8
|
-
|
8
|
+
mods = [ Helix::Base, Helix::Media ]
|
9
|
+
mods.each { |mod| its(:ancestors) { should include(mod) } }
|
9
10
|
its(:guid_name) { should eq('image_id') }
|
10
11
|
its(:resource_label_sym) { should be(:image) }
|
11
12
|
its(:plural_resource_label) { should eq('images') }
|
data/spec/library_spec.rb
CHANGED
@@ -3,20 +3,25 @@ require 'helix'
|
|
3
3
|
|
4
4
|
describe Helix::Library do
|
5
5
|
|
6
|
-
let(:klass)
|
7
|
-
subject
|
8
|
-
|
9
|
-
|
10
|
-
its(:
|
6
|
+
let(:klass) { Helix::Library }
|
7
|
+
subject { klass }
|
8
|
+
|
9
|
+
mods = [ Helix::Base, Helix::RESTful ]
|
10
|
+
mods.each { |mod| its(:ancestors) { should include(mod) } }
|
11
|
+
its(:ancestors) { should_not include(Helix::Media) }
|
12
|
+
|
13
|
+
its(:guid_name) { should eq('library_id') }
|
14
|
+
its(:resource_label_sym) { should be(:library) }
|
15
|
+
its(:plural_resource_label) { should eq('libraries') }
|
11
16
|
[:find, :create, :all, :find_all, :where].each do |crud_call|
|
12
17
|
it { should respond_to(crud_call) }
|
13
18
|
end
|
14
19
|
|
15
20
|
describe ".known_attributes" do
|
16
21
|
let(:meth) { :known_attributes }
|
17
|
-
let(:expected_attrs) { [ :player_profile,
|
18
|
-
:ingest_profile,
|
19
|
-
:secure_stream_callback_url,
|
22
|
+
let(:expected_attrs) { [ :player_profile,
|
23
|
+
:ingest_profile,
|
24
|
+
:secure_stream_callback_url,
|
20
25
|
:hooks_attributes] }
|
21
26
|
it "should equal expected_attrs" do
|
22
27
|
expect(klass.send(meth)).to eq(expected_attrs)
|
@@ -33,4 +38,4 @@ describe Helix::Library do
|
|
33
38
|
it { should respond_to(crud_call) }
|
34
39
|
end
|
35
40
|
end
|
36
|
-
end
|
41
|
+
end
|
data/spec/media_spec.rb
CHANGED
@@ -7,6 +7,9 @@ describe Helix::Media do
|
|
7
7
|
|
8
8
|
subject { klass }
|
9
9
|
|
10
|
+
mods = [ Helix::RESTful, Helix::Uploadable ]
|
11
|
+
mods.each { |mod| its(:ancestors) { should include(mod) } }
|
12
|
+
|
10
13
|
describe ".create" do
|
11
14
|
let(:meth) { :create }
|
12
15
|
let(:mock_config) { mock(Helix::Config) }
|
@@ -17,29 +20,37 @@ describe Helix::Media do
|
|
17
20
|
let(:resp_json) { "JSON" }
|
18
21
|
let(:params) { { signature: "some_sig" } }
|
19
22
|
let(:expected) { { attributes: { attribute: :value }, config: mock_config } }
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
Helix::Config.stub(:instance) { mock_config }
|
26
|
-
end
|
27
|
-
it "should get an ingest signature" do
|
28
|
-
mock_config.should_receive(:build_url).with(resource_label: :klasses,
|
29
|
-
content_type: :xml)
|
30
|
-
RestClient.stub(:post).with(:url, params) { resp_json }
|
31
|
-
Hash.should_receive(:from_xml).with(resp_json) { resp_value }
|
32
|
-
klass.stub(:new).with(expected)
|
33
|
-
mock_config.should_receive(:signature).with(:update) { "some_sig" }
|
34
|
-
klass.send(meth)
|
23
|
+
context "when a Helix:Config instance is absent" do
|
24
|
+
before(:each) do Helix::Config.stub(:instance) { nil } end
|
25
|
+
it "should raise a NoConfigurationLoaded exception" do
|
26
|
+
lambda { klass.send(meth) }.should raise_error(Helix::NoConfigurationLoaded)
|
27
|
+
end
|
35
28
|
end
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
29
|
+
context "when a Helix:Config instance is present" do
|
30
|
+
before(:each) do
|
31
|
+
klass.stub(:plural_resource_label) { :klasses }
|
32
|
+
klass.stub(:resource_label_sym) { klass_sym }
|
33
|
+
mock_config.stub(:build_url).with(content_type: :xml, resource_label: :klasses) { :url }
|
34
|
+
mock_config.stub(:signature).with(:update) { "some_sig" }
|
35
|
+
Helix::Config.stub(:instance) { mock_config }
|
36
|
+
end
|
37
|
+
it "should get an ingest signature" do
|
38
|
+
mock_config.should_receive(:build_url).with(resource_label: :klasses,
|
39
|
+
content_type: :xml)
|
40
|
+
RestClient.stub(:post).with(:url, params) { resp_json }
|
41
|
+
Hash.should_receive(:from_xml).with(resp_json) { resp_value }
|
42
|
+
klass.stub(:new).with(expected)
|
43
|
+
mock_config.should_receive(:signature).with(:update) { "some_sig" }
|
44
|
+
klass.send(meth)
|
45
|
+
end
|
46
|
+
it "should do an HTTP post call, parse response and call new" do
|
47
|
+
mock_config.should_receive(:build_url).with(resource_label: :klasses,
|
48
|
+
content_type: :xml)
|
49
|
+
RestClient.should_receive(:post).with(:url, params) { resp_json }
|
50
|
+
Hash.should_receive(:from_xml).with(resp_json) { resp_value }
|
51
|
+
klass.should_receive(:new).with(expected)
|
52
|
+
klass.send(meth)
|
53
|
+
end
|
43
54
|
end
|
44
55
|
end
|
45
56
|
|
@@ -49,30 +60,56 @@ describe Helix::Media do
|
|
49
60
|
let(:mock_obj) { mock(klass, :load => :output_of_load) }
|
50
61
|
subject { klass.method(meth) }
|
51
62
|
its(:arity) { should eq(1) }
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
63
|
+
context "when a Helix:Config instance is absent" do
|
64
|
+
before(:each) do Helix::Config.stub(:instance) { nil } end
|
65
|
+
context "and given a guid" do
|
66
|
+
let(:guid_name) { :the_guid_name }
|
67
|
+
let(:mock_attrs) { mock(Object, :[]= => :output_of_setting_val) }
|
68
|
+
before(:each) do
|
69
|
+
klass.stub(:attributes) { mock_attrs }
|
70
|
+
klass.stub(:guid_name) { guid_name }
|
71
|
+
klass.stub(:new) { mock_obj }
|
72
|
+
end
|
73
|
+
context "and the guid is nil" do
|
74
|
+
it "should raise an ArgumentError complaining about a nil guid" do
|
75
|
+
msg = 'find requires a non-nil guid argument - received a nil argument.'
|
76
|
+
lambda { klass.send(meth, nil) }.should raise_error(ArgumentError, msg)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
context "and the guid is non-nil" do
|
80
|
+
let(:guid) { :a_guid }
|
81
|
+
it "should raise a NoConfigurationLoaded exception" do
|
82
|
+
lambda { klass.send(meth, guid) }.should raise_error(Helix::NoConfigurationLoaded)
|
83
|
+
end
|
65
84
|
end
|
66
85
|
end
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
86
|
+
end
|
87
|
+
context "when a Helix::Config instance is present" do
|
88
|
+
before(:each) do Helix::Config.stub(:instance) { mock_config } end
|
89
|
+
context "and given a guid" do
|
90
|
+
let(:guid_name) { :the_guid_name }
|
91
|
+
let(:mock_attrs) { mock(Object, :[]= => :output_of_setting_val) }
|
92
|
+
before(:each) do
|
93
|
+
klass.stub(:attributes) { mock_attrs }
|
94
|
+
klass.stub(:guid_name) { guid_name }
|
95
|
+
klass.stub(:new) { mock_obj }
|
96
|
+
end
|
97
|
+
context "and the guid is nil" do
|
98
|
+
it "should raise an ArgumentError complaining about a nil guid" do
|
99
|
+
msg = 'find requires a non-nil guid argument - received a nil argument.'
|
100
|
+
lambda { klass.send(meth, nil) }.should raise_error(ArgumentError, msg)
|
101
|
+
end
|
72
102
|
end
|
73
|
-
|
74
|
-
|
75
|
-
|
103
|
+
context "and the guid is non-nil" do
|
104
|
+
let(:guid) { :a_guid }
|
105
|
+
it "should instantiate with {attributes: guid_name => the_guid, config: config}" do
|
106
|
+
klass.should_receive(:new).with({attributes: {guid_name => guid}, config: mock_config})
|
107
|
+
klass.send(meth, guid)
|
108
|
+
end
|
109
|
+
it "should load" do
|
110
|
+
mock_obj.should_receive(:load)
|
111
|
+
klass.send(meth, guid)
|
112
|
+
end
|
76
113
|
end
|
77
114
|
end
|
78
115
|
end
|
data/spec/tag_spec.rb
CHANGED
data/spec/track_spec.rb
CHANGED
@@ -3,17 +3,21 @@ require 'helix'
|
|
3
3
|
|
4
4
|
describe Helix::Track do
|
5
5
|
|
6
|
-
let(:klass)
|
7
|
-
subject
|
8
|
-
|
9
|
-
its(:
|
10
|
-
its(:
|
6
|
+
let(:klass) { Helix::Track }
|
7
|
+
subject { klass }
|
8
|
+
mods = [ Helix::Base, Helix::DurationedMedia, Helix::Media ]
|
9
|
+
mods.each { |mod| its(:ancestors) { should include(mod) } }
|
10
|
+
its(:guid_name) { should eq('track_id') }
|
11
|
+
its(:resource_label_sym) { should be(:track) }
|
12
|
+
its(:plural_resource_label) { should eq('tracks') }
|
11
13
|
[:find, :create, :all, :find_all, :where].each do |crud_call|
|
12
14
|
it { should respond_to(crud_call) }
|
13
15
|
end
|
14
16
|
|
15
17
|
describe "Constants"
|
16
18
|
|
19
|
+
### INSTANCE METHODS
|
20
|
+
|
17
21
|
describe "an instance" do
|
18
22
|
let(:obj) { klass.new({'track_id' => 'some_track_guid'}) }
|
19
23
|
subject { obj }
|
@@ -22,4 +26,112 @@ describe Helix::Track do
|
|
22
26
|
it { should respond_to(crud_call) }
|
23
27
|
end
|
24
28
|
end
|
29
|
+
|
30
|
+
### CLASS METHODS
|
31
|
+
|
32
|
+
describe ".upload" do
|
33
|
+
let(:meth) { :upload }
|
34
|
+
let(:mock_config) { mock(Helix::Config) }
|
35
|
+
subject { klass.method(meth) }
|
36
|
+
its(:arity) { should eq(1) }
|
37
|
+
let(:file_hash) { { file: :some_file } }
|
38
|
+
let(:multipart_hash) { { multipart: true } }
|
39
|
+
it "should call upload_server_name and RestClient.post with params" do
|
40
|
+
klass.should_receive(:upload_server_name) { :some_server_url }
|
41
|
+
File.should_receive(:new).with(:some_file.to_s, "rb") { :some_file }
|
42
|
+
RestClient.should_receive(:post).with(:some_server_url,
|
43
|
+
file_hash,
|
44
|
+
multipart_hash)
|
45
|
+
klass.should_receive(:http_close)
|
46
|
+
klass.send(meth, :some_file)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
describe ".upload_server_name" do
|
51
|
+
let(:meth) { :upload_server_name }
|
52
|
+
let(:mock_config) { mock(Helix::Config) }
|
53
|
+
subject { klass.method(meth) }
|
54
|
+
its(:arity) { should eq(0) }
|
55
|
+
let(:url_opts) { { resource_label: "upload_sessions",
|
56
|
+
guid: :some_sig,
|
57
|
+
action: :http_open,
|
58
|
+
content_type: "" } }
|
59
|
+
before { Helix::Config.stub(:instance) { mock_config } }
|
60
|
+
it "should call RestClient.get with correct url building" do
|
61
|
+
mock_config.should_receive(:build_url).with(url_opts) { :url }
|
62
|
+
mock_config.should_receive(:signature).with(:ingest) { :some_sig }
|
63
|
+
RestClient.should_receive(:get).with(:url)
|
64
|
+
klass.send(meth)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
describe ".http_close" do
|
69
|
+
let(:meth) { :http_close }
|
70
|
+
let(:mock_config) { mock(Helix::Config) }
|
71
|
+
subject { klass.method(meth) }
|
72
|
+
its(:arity) { should eq(0) }
|
73
|
+
let(:url_opts) { { resource_label: "upload_sessions",
|
74
|
+
guid: :some_sig,
|
75
|
+
action: :http_close,
|
76
|
+
content_type: "" } }
|
77
|
+
before { Helix::Config.stub(:instance) { mock_config } }
|
78
|
+
it "should call RestClient.get with correct url building" do
|
79
|
+
mock_config.should_receive(:build_url).with(url_opts) { :url }
|
80
|
+
mock_config.should_receive(:signature).with(:ingest) { :some_sig }
|
81
|
+
RestClient.should_receive(:get).with(:url)
|
82
|
+
klass.send(meth)
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
describe ".upload_get" do
|
87
|
+
let(:meth) { :upload_get }
|
88
|
+
let(:mock_config) { mock(Helix::Config) }
|
89
|
+
subject { klass.method(meth) }
|
90
|
+
its(:arity) { should eq(1) }
|
91
|
+
let(:url_opts) { { resource_label: "upload_sessions",
|
92
|
+
guid: :some_sig,
|
93
|
+
action: :upload_get,
|
94
|
+
content_type: "" } }
|
95
|
+
before { Helix::Config.stub(:instance) { mock_config } }
|
96
|
+
it "should call RestClient.get with correct url building" do
|
97
|
+
mock_config.should_receive(:build_url).with(url_opts) { :url }
|
98
|
+
mock_config.should_receive(:signature).with(:ingest) { :some_sig }
|
99
|
+
RestClient.should_receive(:get).with(:url)
|
100
|
+
klass.send(meth, :upload_get)
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
describe ".http_open" do
|
105
|
+
let(:meth) { :http_open }
|
106
|
+
let(:mock_config) { mock(Helix::Config) }
|
107
|
+
subject { klass.method(meth) }
|
108
|
+
its(:arity) { should eq(0) }
|
109
|
+
it "should call upload_server_name" do
|
110
|
+
klass.should_receive(:upload_server_name)
|
111
|
+
klass.send(meth)
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
describe ".upload_open" do
|
116
|
+
let(:meth) { :upload_open }
|
117
|
+
let(:mock_config) { mock(Helix::Config) }
|
118
|
+
subject { klass.method(meth) }
|
119
|
+
its(:arity) { should eq(0) }
|
120
|
+
it "should call upload_server_name" do
|
121
|
+
klass.should_receive(:upload_server_name)
|
122
|
+
klass.send(meth)
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
describe ".upload_close" do
|
127
|
+
let(:meth) { :upload_close }
|
128
|
+
let(:mock_config) { mock(Helix::Config) }
|
129
|
+
subject { klass.method(meth) }
|
130
|
+
its(:arity) { should eq(0) }
|
131
|
+
it "should call upload_server_name" do
|
132
|
+
klass.should_receive(:http_close)
|
133
|
+
klass.send(meth)
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
25
137
|
end
|
data/spec/video_spec.rb
CHANGED
@@ -7,11 +7,13 @@ describe Helix::Video do
|
|
7
7
|
{ list: { entry: values[:url_params] || {} } }.to_xml(root: :add)
|
8
8
|
end
|
9
9
|
|
10
|
-
let(:klass)
|
11
|
-
subject
|
12
|
-
|
13
|
-
its(:
|
14
|
-
its(:
|
10
|
+
let(:klass) { Helix::Video }
|
11
|
+
subject { klass }
|
12
|
+
mods = [ Helix::Base, Helix::DurationedMedia, Helix::Media ]
|
13
|
+
mods.each { |mod| its(:ancestors) { should include(mod) } }
|
14
|
+
its(:guid_name) { should eq('video_id') }
|
15
|
+
its(:resource_label_sym) { should be(:video) }
|
16
|
+
its(:plural_resource_label) { should eq('videos') }
|
15
17
|
[:find, :create, :all, :find_all, :where].each do |crud_call|
|
16
18
|
it { should respond_to(crud_call) }
|
17
19
|
end
|
@@ -94,11 +96,84 @@ describe Helix::Video do
|
|
94
96
|
its(:arity) { should eq(-1) }
|
95
97
|
it "should call self.class.get_stillframe" do
|
96
98
|
obj.stub(:guid) { :some_guid }
|
97
|
-
klass.should_receive(:
|
99
|
+
klass.should_receive(:stillframe_for)
|
98
100
|
obj.send(meth)
|
99
101
|
end
|
100
102
|
end
|
101
103
|
|
104
|
+
describe "serialization" do
|
105
|
+
let(:mock_attributes) {
|
106
|
+
{
|
107
|
+
"created_at"=>"2013-04-09 16:33:58 UTC",
|
108
|
+
"description"=>"description of updated via rest-client",
|
109
|
+
"hidden"=>false,
|
110
|
+
"publisher_name"=>"kbaird@twistage.com",
|
111
|
+
"title"=>"updated via rest-client",
|
112
|
+
"video_id"=>"ece0d3fd03bf0",
|
113
|
+
"status"=>"available",
|
114
|
+
"contributor"=>"kbaird@twistage.com",
|
115
|
+
"site_name"=>"11701",
|
116
|
+
"library_name"=>"11701",
|
117
|
+
"main_asset_url"=>"http://service-staging.twistage.com/videos/ece0d3fd03bf0/assets/438894/file.flv",
|
118
|
+
"source_asset_url"=>"http://service-staging.twistage.com/videos/ece0d3fd03bf0/assets/438893/file.mp4",
|
119
|
+
"hits_count"=>0,
|
120
|
+
"plays_count"=>0,
|
121
|
+
"duration"=>255.791,
|
122
|
+
"total_size"=>158410133,
|
123
|
+
"availability"=>"available",
|
124
|
+
"main_asset_id"=>438894,
|
125
|
+
"progress"=>100,
|
126
|
+
"artist"=>"",
|
127
|
+
"genre"=>"",
|
128
|
+
"assets"=>[
|
129
|
+
{"id"=>438893, "size"=>140035687, "status_code"=>30, "acodec"=>"er aac ld", "audio_bitrate"=>128, "container"=>"mp4",
|
130
|
+
"download_url"=>"http://service-staging.twistage.com/videos/ece0d3fd03bf0/assets/438893/file.mp4", "duration"=>255.84,
|
131
|
+
"frame_rate"=>25.0, "hresolution"=>1280, "is_main_asset"=>false, "vcodec"=>"avc1", "video_bitrate"=>4247,
|
132
|
+
"video_format_name"=>"source", "vresolution"=>720, "status"=>"complete", "detailed_status"=>nil},
|
133
|
+
{"id"=>438894, "size"=>18374446, "status_code"=>30, "acodec"=>"mp3", "audio_bitrate"=>67, "container"=>"flv",
|
134
|
+
"download_url"=>"http://service-staging.twistage.com/videos/ece0d3fd03bf0/assets/438894/file.flv", "duration"=>255.791,
|
135
|
+
"frame_rate"=>25.0039099155, "hresolution"=>480, "is_main_asset"=>true, "vcodec"=>"h263", "video_bitrate"=>487,
|
136
|
+
"video_format_name"=>"flash-low", "vresolution"=>270, "status"=>"complete", "detailed_status"=>nil}
|
137
|
+
],
|
138
|
+
"screenshots"=>[
|
139
|
+
{"frame"=>141.4, "content_type"=>"image/jpeg", "width"=>1280, "height"=>720, "size"=>260548,
|
140
|
+
"url"=>"http://service-staging.twistage.com:80/videos/ece0d3fd03bf0/screenshots/original.jpg"}
|
141
|
+
],
|
142
|
+
"tags"=>[],
|
143
|
+
"custom_fields"=>[{"name"=>"blaaagghhh", "value"=>""}, {"name"=>"videoCF", "value"=>""}]
|
144
|
+
}
|
145
|
+
}
|
146
|
+
before(:each) do obj.instance_variable_set(:@attributes, mock_attributes) end
|
147
|
+
|
148
|
+
describe "#to_json" do
|
149
|
+
let(:meth) { :to_json }
|
150
|
+
context "arity" do
|
151
|
+
subject { obj.method(meth) }
|
152
|
+
its(:arity) { should eq(0) }
|
153
|
+
end
|
154
|
+
subject { obj.send(meth) }
|
155
|
+
it { should eq({video: mock_attributes}.to_json) }
|
156
|
+
end
|
157
|
+
|
158
|
+
describe "#to_xml" do
|
159
|
+
let(:meth) { :to_xml }
|
160
|
+
context "arity" do
|
161
|
+
subject { obj.method(meth) }
|
162
|
+
its(:arity) { should eq(0) }
|
163
|
+
end
|
164
|
+
subject { obj.send(meth) }
|
165
|
+
let(:modified_attributes) {
|
166
|
+
custom_fields = mock_attributes['custom_fields']
|
167
|
+
new_cfs = custom_fields.inject({}) do |memo,cf|
|
168
|
+
memo.merge(cf['name'] => cf['value'])
|
169
|
+
end
|
170
|
+
mock_attributes.merge('custom_fields' => new_cfs)
|
171
|
+
}
|
172
|
+
it { should eq(modified_attributes.to_xml(root: :video)) }
|
173
|
+
end
|
174
|
+
|
175
|
+
end
|
176
|
+
|
102
177
|
[:destroy, :update].each do |crud_call|
|
103
178
|
it { should respond_to(crud_call) }
|
104
179
|
end
|
@@ -107,6 +182,111 @@ describe Helix::Video do
|
|
107
182
|
|
108
183
|
### CLASS METHODS
|
109
184
|
|
185
|
+
describe ".upload" do
|
186
|
+
let(:meth) { :upload }
|
187
|
+
let(:mock_config) { mock(Helix::Config) }
|
188
|
+
subject { klass.method(meth) }
|
189
|
+
its(:arity) { should eq(1) }
|
190
|
+
let(:file_hash) { { file: :some_file } }
|
191
|
+
let(:multipart_hash) { { multipart: true } }
|
192
|
+
it "should call upload_server_name and RestClient.post with params" do
|
193
|
+
klass.should_receive(:upload_server_name) { :some_server_url }
|
194
|
+
File.should_receive(:new).with(:some_file.to_s, "rb") { :some_file }
|
195
|
+
RestClient.should_receive(:post).with(:some_server_url,
|
196
|
+
file_hash,
|
197
|
+
multipart_hash)
|
198
|
+
klass.should_receive(:http_close)
|
199
|
+
klass.send(meth, :some_file)
|
200
|
+
end
|
201
|
+
end
|
202
|
+
|
203
|
+
describe ".upload_server_name" do
|
204
|
+
let(:meth) { :upload_server_name }
|
205
|
+
let(:mock_config) { mock(Helix::Config) }
|
206
|
+
subject { klass.method(meth) }
|
207
|
+
its(:arity) { should eq(0) }
|
208
|
+
let(:url_opts) { { resource_label: "upload_sessions",
|
209
|
+
guid: :some_sig,
|
210
|
+
action: :http_open,
|
211
|
+
content_type: "" } }
|
212
|
+
before { Helix::Config.stub(:instance) { mock_config } }
|
213
|
+
it "should call RestClient.get with correct url building" do
|
214
|
+
mock_config.should_receive(:build_url).with(url_opts) { :url }
|
215
|
+
mock_config.should_receive(:signature).with(:ingest) { :some_sig }
|
216
|
+
RestClient.should_receive(:get).with(:url)
|
217
|
+
klass.send(meth)
|
218
|
+
end
|
219
|
+
end
|
220
|
+
|
221
|
+
describe ".http_close" do
|
222
|
+
let(:meth) { :http_close }
|
223
|
+
let(:mock_config) { mock(Helix::Config) }
|
224
|
+
subject { klass.method(meth) }
|
225
|
+
its(:arity) { should eq(0) }
|
226
|
+
let(:url_opts) { { resource_label: "upload_sessions",
|
227
|
+
guid: :some_sig,
|
228
|
+
action: :http_close,
|
229
|
+
content_type: "" } }
|
230
|
+
before { Helix::Config.stub(:instance) { mock_config } }
|
231
|
+
it "should call RestClient.get with correct url building" do
|
232
|
+
mock_config.should_receive(:build_url).with(url_opts) { :url }
|
233
|
+
mock_config.should_receive(:signature).with(:ingest) { :some_sig }
|
234
|
+
RestClient.should_receive(:get).with(:url)
|
235
|
+
klass.send(meth)
|
236
|
+
end
|
237
|
+
end
|
238
|
+
|
239
|
+
describe ".upload_get" do
|
240
|
+
let(:meth) { :upload_get }
|
241
|
+
let(:mock_config) { mock(Helix::Config) }
|
242
|
+
subject { klass.method(meth) }
|
243
|
+
its(:arity) { should eq(1) }
|
244
|
+
let(:url_opts) { { resource_label: "upload_sessions",
|
245
|
+
guid: :some_sig,
|
246
|
+
action: :upload_get,
|
247
|
+
content_type: "" } }
|
248
|
+
before { Helix::Config.stub(:instance) { mock_config } }
|
249
|
+
it "should call RestClient.get with correct url building" do
|
250
|
+
mock_config.should_receive(:build_url).with(url_opts) { :url }
|
251
|
+
mock_config.should_receive(:signature).with(:ingest) { :some_sig }
|
252
|
+
RestClient.should_receive(:get).with(:url)
|
253
|
+
klass.send(meth, :upload_get)
|
254
|
+
end
|
255
|
+
end
|
256
|
+
|
257
|
+
describe ".http_open" do
|
258
|
+
let(:meth) { :http_open }
|
259
|
+
let(:mock_config) { mock(Helix::Config) }
|
260
|
+
subject { klass.method(meth) }
|
261
|
+
its(:arity) { should eq(0) }
|
262
|
+
it "should call upload_server_name" do
|
263
|
+
klass.should_receive(:upload_server_name)
|
264
|
+
klass.send(meth)
|
265
|
+
end
|
266
|
+
end
|
267
|
+
|
268
|
+
describe ".upload_open" do
|
269
|
+
let(:meth) { :upload_open }
|
270
|
+
let(:mock_config) { mock(Helix::Config) }
|
271
|
+
subject { klass.method(meth) }
|
272
|
+
its(:arity) { should eq(0) }
|
273
|
+
it "should call upload_server_name" do
|
274
|
+
klass.should_receive(:upload_server_name)
|
275
|
+
klass.send(meth)
|
276
|
+
end
|
277
|
+
end
|
278
|
+
|
279
|
+
describe ".upload_close" do
|
280
|
+
let(:meth) { :upload_close }
|
281
|
+
let(:mock_config) { mock(Helix::Config) }
|
282
|
+
subject { klass.method(meth) }
|
283
|
+
its(:arity) { should eq(0) }
|
284
|
+
it "should call upload_server_name" do
|
285
|
+
klass.should_receive(:http_close)
|
286
|
+
klass.send(meth)
|
287
|
+
end
|
288
|
+
end
|
289
|
+
|
110
290
|
describe ".slice" do
|
111
291
|
let(:meth) { :slice }
|
112
292
|
let(:mock_config) { mock(Helix::Config) }
|
@@ -131,8 +311,8 @@ describe Helix::Video do
|
|
131
311
|
end
|
132
312
|
end
|
133
313
|
|
134
|
-
describe ".
|
135
|
-
let(:meth) { :
|
314
|
+
describe ".stillframe_for" do
|
315
|
+
let(:meth) { :stillframe_for }
|
136
316
|
let(:mock_config) { mock(Helix::Config) }
|
137
317
|
subject { klass.method(meth) }
|
138
318
|
its(:arity) { should eq(-2) }
|