helix 0.0.3.9.pre → 0.0.4.0.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.
@@ -154,7 +154,8 @@ module Helix
154
154
 
155
155
  lk = license_key
156
156
  @signature_expiration_for[lk][sig_type] = Time.now + TIME_OFFSET
157
- @signature_for[lk][sig_type] = RestClient.get(url_for(sig_type, opts))
157
+ new_sig_url = url_for(sig_type, opts)
158
+ @signature_for[lk][sig_type] = RestClient.get(new_sig_url)
158
159
  end
159
160
 
160
161
  def proxy
@@ -226,11 +227,12 @@ module Helix
226
227
  end
227
228
 
228
229
  def url_for(sig_type, opts={})
229
- contributor, library_id = [:contributor, :library_id].map { |key| opts[key] }
230
- contributor ||= credentials[:contributor]
230
+ contributor, library_id, company_id = [:contributor, :library_id, :company_id].map { |key| opts[key] }
231
+ contributor ||= (credentials[:contributor] || 'helix_default_contributor')
231
232
  url = "#{credentials[:site]}/api/#{sig_type}_key?licenseKey=#{credentials[:license_key]}&duration=#{SIG_DURATION}"
232
- url += "&contributor=#{contributor}" if contributor
233
- url += "&library_id=#{library_id}" if library_id
233
+ url += "&contributor=#{contributor}" if sig_type == :ingest
234
+ url += "&library_id=#{library_id}" if library_id
235
+ url += "&company_id=#{company_id}" if company_id
234
236
  url
235
237
  end
236
238
 
@@ -7,14 +7,15 @@ module Helix
7
7
  module ClassMethods
8
8
 
9
9
  def upload(file_name)
10
- RestClient.post(upload_server_name,
11
- { file: File.new(file_name.to_s, "rb") },
12
- { multipart: true } )
10
+ url = upload_server_name
11
+ payload = { file: File.new(file_name.to_s, "rb") }
12
+ headers = { multipart: true }
13
+ RestClient.post(url, payload, headers)
13
14
  http_close
14
15
  end
15
16
 
16
17
  def upload_server_name
17
- upload_get(:http_open)
18
+ upload_get(:http_open, ingest_opts)
18
19
  end
19
20
 
20
21
  def http_open
@@ -35,9 +36,19 @@ module Helix
35
36
 
36
37
  private
37
38
 
38
- def upload_get(action)
39
- url = config.build_url( resource_label: "upload_sessions",
40
- guid: config.signature(:ingest),
39
+ def ingest_opts
40
+ cc = config.credentials
41
+ ingest_opts = {
42
+ contributor: cc[:contributor],
43
+ company_id: cc[:company],
44
+ library_id: cc[:library],
45
+ }
46
+ end
47
+
48
+ def upload_get(action, opts={})
49
+ guid = config.signature(:ingest, opts)
50
+ url = config.build_url(resource_label: "upload_sessions",
51
+ guid: guid,
41
52
  action: action,
42
53
  content_type: "" )
43
54
  RestClient.get(url)
@@ -10,16 +10,20 @@ elsif %w(1 t true).include?(ENV['SKIP_INTEGRATION'])
10
10
  puts "Skipping integration specs due to user request"
11
11
  else
12
12
 
13
- media_by_id = {
13
+ default_query_proc = lambda { |h,k| h[k] = 'rest-client' }
14
+ query_by_guid_key = Hash.new(&default_query_proc).merge(tag_id: '8143')
15
+
16
+ resource_by_id = {
14
17
  album_id: Helix::Album,
15
18
  document_id: Helix::Document,
16
19
  image_id: Helix::Image,
17
20
  playlist_id: Helix::Playlist,
21
+ tag_id: Helix::Tag,
18
22
  track_id: Helix::Track,
19
23
  video_id: Helix::Video
20
24
  }
21
25
 
22
- media_by_id.each do |guid_key,klass|
26
+ resource_by_id.each do |guid_key,klass|
23
27
 
24
28
  describe "Integration Specs for #{klass.to_s}" do
25
29
 
@@ -28,9 +32,18 @@ else
28
32
  it { should_not be_empty }
29
33
  end
30
34
 
31
- describe ".where(query: 'rest-client')" do
35
+ query = query_by_guid_key[guid_key]
36
+ describe ".where(query: '#{query}')" do
32
37
  it "should not raise an exception" do
33
- lambda { klass.where(query: 'rest-client') }.should_not raise_error
38
+ lambda { klass.where(query: query) }.should_not raise_error
39
+ end
40
+ if guid_key == :tag_id
41
+ subject { klass.where(query: query).first }
42
+ it { should be_a Helix::Tag }
43
+ its(:name) { should be_a String }
44
+ its(:name) { should eq '8143' }
45
+ its(:count) { should be_a Integer }
46
+ its(:count) { should eq 2 }
34
47
  end
35
48
  end
36
49
 
@@ -51,7 +64,7 @@ else
51
64
  end
52
65
 
53
66
  shared_examples_for "found #{klass}" do
54
- it { should_not be_empty }
67
+ it { should_not be_nil }
55
68
  if klass == Helix::Playlist
56
69
  # Playlist Metadata is just a wrapper for an Array of media items: no guid
57
70
  its(guid_key) { should eq(nil) }
@@ -66,7 +79,7 @@ else
66
79
  "width" => 1280,
67
80
  "height" => 720,
68
81
  "size" => 260548,
69
- "url" => "http://edited-yet-again-staging.twistage.com:80/videos/ece0d3fd03bf0/screenshots/original.jpg"
82
+ "url" => "http://service-staging.twistage.com:80/videos/ece0d3fd03bf0/screenshots/original.jpg"
70
83
  }
71
84
  subject { item.screenshots.first }
72
85
  it { should eq(expected_ss) }
@@ -87,7 +100,7 @@ else
87
100
  end
88
101
  end
89
102
 
90
- unless guid_key == :document_id # no Document stats yet
103
+ unless [:document_id, :playlist_id, :tag_id].include?(guid_key) # no stats for these yet
91
104
  describe "Stats" do
92
105
  media_type = guid_key.to_s.split(/_/).first
93
106
  helix_stats = Helix::Statistics
@@ -38,7 +38,7 @@ describe Helix::Base do
38
38
  context "when there is a config instance" do
39
39
  let(:mock_config) do
40
40
  dss = (0..2).map { |x| :"attrs_#{x}" }
41
- mock(Helix::Config, build_url: :built_url, get_aggregated_data_sets: dss)
41
+ double(Helix::Config, build_url: :built_url, get_aggregated_data_sets: dss)
42
42
  end
43
43
  before(:each) do Helix::Config.stub(:instance) { mock_config } end
44
44
  context "and NOT given an opts Hash" do
@@ -68,7 +68,7 @@ describe Helix::Base do
68
68
  context "when there is a config instance" do
69
69
  let(:mock_config) do
70
70
  dss = (0..2).map { |x| :"attrs_#{x}" }
71
- mock(Helix::Config, build_url: :built_url, get_aggregated_data_sets: dss)
71
+ double(Helix::Config, build_url: :built_url, get_aggregated_data_sets: dss)
72
72
  end
73
73
  before(:each) do Helix::Config.stub(:instance) { mock_config } end
74
74
  context "and NOT given an opts Hash" do
@@ -221,7 +221,7 @@ describe Helix::Base do
221
221
  describe "#guid" do
222
222
  let(:meth) { :guid }
223
223
  it "should return @attributes[guid_name]" do
224
- mock_attributes = mock(Object)
224
+ mock_attributes = double(Object)
225
225
  obj.instance_variable_set(:@attributes, mock_attributes)
226
226
  obj.should_receive(:guid_name) { :the_guid_name }
227
227
  mock_attributes.should_receive(:[]).with(:the_guid_name) { :expected }
@@ -239,7 +239,7 @@ describe Helix::Base do
239
239
 
240
240
  describe "#load" do
241
241
  let(:meth) { :load }
242
- let(:mock_config) { mock(Helix::Config) }
242
+ let(:mock_config) { double(Helix::Config) }
243
243
  subject { obj.method(meth) }
244
244
  its(:arity) { should eq(-1) }
245
245
  before(:each) do
@@ -307,7 +307,7 @@ describe Helix::Base do
307
307
  its(:arity) { should eq(1) }
308
308
  context "when given method_sym" do
309
309
  let(:method_sym) { :method_sym }
310
- let(:mock_attributes) { mock(Object) }
310
+ let(:mock_attributes) { double(Object) }
311
311
  before(:each) do obj.instance_variable_set(:@attributes, mock_attributes) end
312
312
  context "and @attributes[method_sym.to_s] raises an exception" do
313
313
  before(:each) do mock_attributes.should_receive(:[]).with(method_sym.to_s).and_raise("some exception") end
@@ -51,8 +51,8 @@ describe Helix::Config do
51
51
 
52
52
  describe ".load" do
53
53
  let(:meth) { :load }
54
- let(:mock_obj) { mock(klass, proxy: :stubbed_proxy) }
55
- let(:mock_file) { mock(File) }
54
+ let(:mock_obj) { double(klass, proxy: :stubbed_proxy) }
55
+ let(:mock_file) { double(File) }
56
56
  let(:mock_cred) { {key1: 'value1', 'key2' => 'value2'} }
57
57
  let(:symbolized_cred) { {key1: 'value1', key2: 'value2'} }
58
58
  before(:each) do
@@ -335,8 +335,8 @@ describe Helix::Config do
335
335
  opts1 = {params: base_opts.merge(page: 1)}
336
336
  opts2 = {params: base_opts.merge(page: 2)}
337
337
  opts3 = {params: base_opts.merge(page: 3)}
338
- non_final_response = mock(String, headers: {is_last_page: 'false'})
339
- final_response = mock(String, headers: {is_last_page: 'true'})
338
+ non_final_response = double(String, headers: {is_last_page: 'false'})
339
+ final_response = double(String, headers: {is_last_page: 'true'})
340
340
  RestClient.should_receive(:get).with(:a_url, opts1) { non_final_response }
341
341
  RestClient.should_receive(:get).with(:a_url, opts2) { non_final_response }
342
342
  RestClient.should_receive(:get).with(:a_url, opts3) { final_response }
@@ -433,7 +433,7 @@ describe Helix::Config do
433
433
  it { should be false }
434
434
  end
435
435
  context "when there is a @response" do
436
- let(:mock_response) { mock(String) }
436
+ let(:mock_response) { double(String) }
437
437
  before(:each) { obj.instance_variable_set(:@response, mock_response) }
438
438
  context "and there is no @response.headers" do
439
439
  before(:each) { mock_response.stub(:headers) { nil } }
@@ -532,7 +532,7 @@ describe Helix::Config do
532
532
  obj.stub(:prepare_signature_memoization)
533
533
  end
534
534
 
535
- let(:mock_response) { mock(Object) }
535
+ let(:mock_response) { double(Object) }
536
536
  context "when given :some_invalid_sig_type" do
537
537
  let(:sig_type) { :some_invalid_sig_type }
538
538
  it "should raise an ArgumentError" do
@@ -551,12 +551,13 @@ describe Helix::Config do
551
551
  end
552
552
  it "should call RestClient.get(#{url})" do
553
553
  set_stubs(obj)
554
- url = "#{obj.credentials[:site]}/api/#{sig_type}_key?licenseKey=#{license_key}&duration=1200"
554
+ url = "#{obj.credentials[:site]}/api/#{sig_type}_key?licenseKey=#{license_key}&duration=1200"
555
+ url += "&contributor=helix_default_contributor" if sig_type == :ingest
555
556
  RestClient.should_receive(:get).with(url) { :fresh_sig }
556
557
  expect(obj.send(meth, sig_type)).to be(:fresh_sig)
557
558
  end
558
559
  it "sets a new sig expiration time" do
559
- mock_time = mock(Time)
560
+ mock_time = double(Time)
560
561
  Time.should_receive(:now) { mock_time }
561
562
  mock_time.should_receive(:+).with(klass::TIME_OFFSET) { :new_time }
562
563
  obj.send(meth, sig_type)
@@ -596,8 +597,8 @@ describe Helix::Config do
596
597
 
597
598
  context "when given a sig_type" do
598
599
  let(:sig_type) { :a_sig_type }
599
- let(:mock_expired) { mock(Time) }
600
- let(:mock_now) { mock(Time) }
600
+ let(:mock_expired) { double(Time) }
601
+ let(:mock_now) { double(Time) }
601
602
  subject { obj.send(meth, sig_type) }
602
603
  context "when @signature_expiration_for[license_key][sig_type] is nil" do
603
604
  before(:each) do obj.instance_variable_set(:@signature_expiration_for, {license_key => {sig_type => nil}}) end
@@ -29,9 +29,41 @@ describe Helix::Document do
29
29
 
30
30
  ### CLASS METHODS
31
31
 
32
+ describe ".ingest_opts" do
33
+ let(:meth) { :ingest_opts }
34
+ let(:mock_config) { double(Helix::Config, credentials: {}) }
35
+ subject { klass.method(meth) }
36
+ its(:arity) { should eq(0) }
37
+ it "should be private" do expect(klass.private_methods).to include(meth) end
38
+ context "when called" do
39
+ subject { klass.send(meth) }
40
+ before(:each) do klass.stub(:config) { mock_config } end
41
+ it "should be a Hash" do expect(klass.send(meth)).to be_a(Hash) end
42
+ its(:keys) { should match_array([:contributor, :company_id, :library_id]) }
43
+ context "the value for :contributor" do
44
+ it "should be config.credentials[:contributor]" do
45
+ mock_config.should_receive(:credentials) { {contributor: :expected_contributor} }
46
+ expect(klass.send(meth)[:contributor]).to be(:expected_contributor)
47
+ end
48
+ end
49
+ context "the value for :company_id" do
50
+ it "should be config.credentials[:company]" do
51
+ mock_config.should_receive(:credentials) { {company: :expected_company} }
52
+ expect(klass.send(meth)[:company_id]).to be(:expected_company)
53
+ end
54
+ end
55
+ context "the value for :library_id" do
56
+ it "should be config.credentials[:library]" do
57
+ mock_config.should_receive(:credentials) { {library: :expected_library} }
58
+ expect(klass.send(meth)[:library_id]).to be(:expected_library)
59
+ end
60
+ end
61
+ end
62
+ end
63
+
32
64
  describe ".upload" do
33
65
  let(:meth) { :upload }
34
- let(:mock_config) { mock(Helix::Config) }
66
+ let(:mock_config) { double(Helix::Config) }
35
67
  subject { klass.method(meth) }
36
68
  its(:arity) { should eq(1) }
37
69
  let(:file_hash) { { file: :some_file } }
@@ -49,7 +81,7 @@ describe Helix::Document do
49
81
 
50
82
  describe ".upload_server_name" do
51
83
  let(:meth) { :upload_server_name }
52
- let(:mock_config) { mock(Helix::Config) }
84
+ let(:mock_config) { double(Helix::Config) }
53
85
  subject { klass.method(meth) }
54
86
  its(:arity) { should eq(0) }
55
87
  let(:url_opts) { { resource_label: "upload_sessions",
@@ -58,8 +90,9 @@ describe Helix::Document do
58
90
  content_type: "" } }
59
91
  before { Helix::Config.stub(:instance) { mock_config } }
60
92
  it "should call RestClient.get with correct url building" do
93
+ klass.should_receive(:ingest_opts) { :ingest_opts }
61
94
  mock_config.should_receive(:build_url).with(url_opts) { :url }
62
- mock_config.should_receive(:signature).with(:ingest) { :some_sig }
95
+ mock_config.should_receive(:signature).with(:ingest, :ingest_opts) { :some_sig }
63
96
  RestClient.should_receive(:get).with(:url)
64
97
  klass.send(meth)
65
98
  end
@@ -67,7 +100,7 @@ describe Helix::Document do
67
100
 
68
101
  describe ".http_close" do
69
102
  let(:meth) { :http_close }
70
- let(:mock_config) { mock(Helix::Config) }
103
+ let(:mock_config) { double(Helix::Config) }
71
104
  subject { klass.method(meth) }
72
105
  its(:arity) { should eq(0) }
73
106
  let(:url_opts) { { resource_label: "upload_sessions",
@@ -77,7 +110,7 @@ describe Helix::Document do
77
110
  before { Helix::Config.stub(:instance) { mock_config } }
78
111
  it "should call RestClient.get with correct url building" do
79
112
  mock_config.should_receive(:build_url).with(url_opts) { :url }
80
- mock_config.should_receive(:signature).with(:ingest) { :some_sig }
113
+ mock_config.should_receive(:signature).with(:ingest, {}) { :some_sig }
81
114
  RestClient.should_receive(:get).with(:url)
82
115
  klass.send(meth)
83
116
  end
@@ -85,9 +118,9 @@ describe Helix::Document do
85
118
 
86
119
  describe ".upload_get" do
87
120
  let(:meth) { :upload_get }
88
- let(:mock_config) { mock(Helix::Config) }
121
+ let(:mock_config) { double(Helix::Config) }
89
122
  subject { klass.method(meth) }
90
- its(:arity) { should eq(1) }
123
+ its(:arity) { should eq(-2) }
91
124
  let(:url_opts) { { resource_label: "upload_sessions",
92
125
  guid: :some_sig,
93
126
  action: :upload_get,
@@ -95,7 +128,7 @@ describe Helix::Document do
95
128
  before { Helix::Config.stub(:instance) { mock_config } }
96
129
  it "should call RestClient.get with correct url building" do
97
130
  mock_config.should_receive(:build_url).with(url_opts) { :url }
98
- mock_config.should_receive(:signature).with(:ingest) { :some_sig }
131
+ mock_config.should_receive(:signature).with(:ingest, {}) { :some_sig }
99
132
  RestClient.should_receive(:get).with(:url)
100
133
  klass.send(meth, :upload_get)
101
134
  end
@@ -103,7 +136,7 @@ describe Helix::Document do
103
136
 
104
137
  describe ".http_open" do
105
138
  let(:meth) { :http_open }
106
- let(:mock_config) { mock(Helix::Config) }
139
+ let(:mock_config) { double(Helix::Config) }
107
140
  subject { klass.method(meth) }
108
141
  its(:arity) { should eq(0) }
109
142
  it "should call upload_server_name" do
@@ -114,7 +147,7 @@ describe Helix::Document do
114
147
 
115
148
  describe ".upload_open" do
116
149
  let(:meth) { :upload_open }
117
- let(:mock_config) { mock(Helix::Config) }
150
+ let(:mock_config) { double(Helix::Config) }
118
151
  subject { klass.method(meth) }
119
152
  its(:arity) { should eq(0) }
120
153
  it "should call upload_server_name" do
@@ -125,7 +158,7 @@ describe Helix::Document do
125
158
 
126
159
  describe ".upload_close" do
127
160
  let(:meth) { :upload_close }
128
- let(:mock_config) { mock(Helix::Config) }
161
+ let(:mock_config) { double(Helix::Config) }
129
162
  subject { klass.method(meth) }
130
163
  its(:arity) { should eq(0) }
131
164
  it "should call upload_server_name" do
@@ -24,7 +24,7 @@ describe Helix::Durationed do
24
24
 
25
25
  describe ".import" do
26
26
  let(:meth) { :import }
27
- let(:mock_config) { mock(Helix::Config) }
27
+ let(:mock_config) { double(Helix::Config) }
28
28
  subject { klass.method(meth) }
29
29
  its(:arity) { should eq(-1) }
30
30
  let(:params) { { params: { signature: :some_sig },
@@ -36,7 +36,7 @@ describe Helix::Media do
36
36
 
37
37
  describe ".create" do
38
38
  let(:meth) { :create }
39
- let(:mock_config) { mock(Helix::Config) }
39
+ let(:mock_config) { double(Helix::Config) }
40
40
  subject { klass.method(meth) }
41
41
  its(:arity) { should eq(-1) }
42
42
  let(:hash_from_xml) { { klass_sym.to_s => { attribute: :value } } }
@@ -108,15 +108,15 @@ describe Helix::Media do
108
108
 
109
109
  describe ".find" do
110
110
  let(:meth) { :find }
111
- let(:mock_config) { mock(Helix::Config) }
112
- let(:mock_obj) { mock(klass, :load => :output_of_load) }
111
+ let(:mock_config) { double(Helix::Config) }
112
+ let(:mock_obj) { double(klass, :load => :output_of_load) }
113
113
  subject { klass.method(meth) }
114
114
  its(:arity) { should eq(-2) }
115
115
  context "when a Helix:Config instance is absent" do
116
116
  before(:each) do Helix::Config.stub(:instance) { nil } end
117
117
  context "and given a guid" do
118
118
  let(:guid_name) { :the_guid_name }
119
- let(:mock_attrs) { mock(Object, :[]= => :output_of_setting_val) }
119
+ let(:mock_attrs) { double(Object, :[]= => :output_of_setting_val) }
120
120
  before(:each) do
121
121
  klass.stub(:attributes) { mock_attrs }
122
122
  klass.stub(:guid_name) { guid_name }
@@ -140,7 +140,7 @@ describe Helix::Media do
140
140
  before(:each) do Helix::Config.stub(:instance) { mock_config } end
141
141
  context "and given a guid" do
142
142
  let(:guid_name) { :the_guid_name }
143
- let(:mock_attrs) { mock(Object, :[]= => :output_of_setting_val) }
143
+ let(:mock_attrs) { double(Object, :[]= => :output_of_setting_val) }
144
144
  before(:each) do
145
145
  klass.stub(:attributes) { mock_attrs }
146
146
  klass.stub(:guid_name) { guid_name }
@@ -185,7 +185,7 @@ describe Helix::Media do
185
185
 
186
186
  describe "#destroy" do
187
187
  let(:meth) { :destroy }
188
- let(:mock_config) { mock(Helix::Config, build_url: :the_built_url, signature: :some_sig) }
188
+ let(:mock_config) { double(Helix::Config, build_url: :the_built_url, signature: :some_sig) }
189
189
  subject { obj.method(meth) }
190
190
  let(:params) { { params: {signature: :some_sig } } }
191
191
  before do
@@ -212,7 +212,7 @@ describe Helix::Media do
212
212
  describe "#update" do
213
213
  next if child_class == Helix::Album
214
214
  let(:meth) { :update }
215
- let(:mock_config) { mock(Helix::Config) }
215
+ let(:mock_config) { double(Helix::Config) }
216
216
  subject { obj.method(meth) }
217
217
  its(:arity) { should eq(-1) }
218
218
  before(:each) do
@@ -38,7 +38,7 @@ describe Helix::Statistics do
38
38
 
39
39
  describe ".#{resource_label}_#{stats_type}" do
40
40
  let(:meth) { "#{resource_label}_#{stats_type}" }
41
- let(:mock_config) { mock(Helix::Config, build_url: :built_url, get_response: :raw_response) }
41
+ let(:mock_config) { double(Helix::Config, build_url: :built_url, get_response: :raw_response) }
42
42
  before(:each) do
43
43
  Helix::Config.stub(:instance) { mock_config }
44
44
  mod.stub(:standardize_raw_stats).with(:raw_response) { :response }
@@ -16,7 +16,7 @@ describe Helix::Tag do
16
16
  describe ".get_data_sets" do
17
17
  let(:meth) { :get_data_sets }
18
18
  let(:raw_response) { {"tags" => :expected} }
19
- let(:mock_config) { mock(Helix::Config, build_url: :the_url, get_response: raw_response) }
19
+ let(:mock_config) { double(Helix::Config, build_url: :the_url, get_response: raw_response) }
20
20
  let(:opts) { {} }
21
21
  before(:each) { klass.stub(:config) { mock_config }}
22
22
  bu_opts = {content_type: :xml, resource_label: "tags"}
@@ -29,9 +29,40 @@ describe Helix::Track do
29
29
 
30
30
  ### CLASS METHODS
31
31
 
32
+ describe ".ingest_opts" do
33
+ let(:meth) { :ingest_opts }
34
+ let(:mock_config) { double(Helix::Config, credentials: {}) }
35
+ subject { klass.method(meth) }
36
+ its(:arity) { should eq(0) }
37
+ it "should be private" do expect(klass.private_methods).to include(meth) end
38
+ context "when called" do
39
+ subject { klass.send(meth) }
40
+ before(:each) do klass.stub(:config) { mock_config } end
41
+ it "should be a Hash" do expect(klass.send(meth)).to be_a(Hash) end
42
+ its(:keys) { should match_array([:contributor, :company_id, :library_id]) }
43
+ context "the value for :contributor" do
44
+ it "should be config.credentials[:contributor]" do
45
+ mock_config.should_receive(:credentials) { {contributor: :expected_contributor} }
46
+ expect(klass.send(meth)[:contributor]).to be(:expected_contributor)
47
+ end
48
+ end
49
+ context "the value for :company_id" do
50
+ it "should be config.credentials[:company]" do
51
+ mock_config.should_receive(:credentials) { {company: :expected_company} }
52
+ expect(klass.send(meth)[:company_id]).to be(:expected_company)
53
+ end
54
+ end
55
+ context "the value for :library_id" do
56
+ it "should be config.credentials[:library]" do
57
+ mock_config.should_receive(:credentials) { {library: :expected_library} }
58
+ expect(klass.send(meth)[:library_id]).to be(:expected_library)
59
+ end
60
+ end
61
+ end
62
+ end
32
63
  describe ".upload" do
33
64
  let(:meth) { :upload }
34
- let(:mock_config) { mock(Helix::Config) }
65
+ let(:mock_config) { double(Helix::Config) }
35
66
  subject { klass.method(meth) }
36
67
  its(:arity) { should eq(1) }
37
68
  let(:file_hash) { { file: :some_file } }
@@ -49,7 +80,7 @@ describe Helix::Track do
49
80
 
50
81
  describe ".upload_server_name" do
51
82
  let(:meth) { :upload_server_name }
52
- let(:mock_config) { mock(Helix::Config) }
83
+ let(:mock_config) { double(Helix::Config) }
53
84
  subject { klass.method(meth) }
54
85
  its(:arity) { should eq(0) }
55
86
  let(:url_opts) { { resource_label: "upload_sessions",
@@ -58,8 +89,9 @@ describe Helix::Track do
58
89
  content_type: "" } }
59
90
  before { Helix::Config.stub(:instance) { mock_config } }
60
91
  it "should call RestClient.get with correct url building" do
92
+ klass.should_receive(:ingest_opts) { :ingest_opts }
61
93
  mock_config.should_receive(:build_url).with(url_opts) { :url }
62
- mock_config.should_receive(:signature).with(:ingest) { :some_sig }
94
+ mock_config.should_receive(:signature).with(:ingest, :ingest_opts) { :some_sig }
63
95
  RestClient.should_receive(:get).with(:url)
64
96
  klass.send(meth)
65
97
  end
@@ -67,7 +99,7 @@ describe Helix::Track do
67
99
 
68
100
  describe ".http_close" do
69
101
  let(:meth) { :http_close }
70
- let(:mock_config) { mock(Helix::Config) }
102
+ let(:mock_config) { double(Helix::Config) }
71
103
  subject { klass.method(meth) }
72
104
  its(:arity) { should eq(0) }
73
105
  let(:url_opts) { { resource_label: "upload_sessions",
@@ -77,7 +109,7 @@ describe Helix::Track do
77
109
  before { Helix::Config.stub(:instance) { mock_config } }
78
110
  it "should call RestClient.get with correct url building" do
79
111
  mock_config.should_receive(:build_url).with(url_opts) { :url }
80
- mock_config.should_receive(:signature).with(:ingest) { :some_sig }
112
+ mock_config.should_receive(:signature).with(:ingest, {}) { :some_sig }
81
113
  RestClient.should_receive(:get).with(:url)
82
114
  klass.send(meth)
83
115
  end
@@ -85,9 +117,9 @@ describe Helix::Track do
85
117
 
86
118
  describe ".upload_get" do
87
119
  let(:meth) { :upload_get }
88
- let(:mock_config) { mock(Helix::Config) }
120
+ let(:mock_config) { double(Helix::Config) }
89
121
  subject { klass.method(meth) }
90
- its(:arity) { should eq(1) }
122
+ its(:arity) { should eq(-2) }
91
123
  let(:url_opts) { { resource_label: "upload_sessions",
92
124
  guid: :some_sig,
93
125
  action: :upload_get,
@@ -95,7 +127,7 @@ describe Helix::Track do
95
127
  before { Helix::Config.stub(:instance) { mock_config } }
96
128
  it "should call RestClient.get with correct url building" do
97
129
  mock_config.should_receive(:build_url).with(url_opts) { :url }
98
- mock_config.should_receive(:signature).with(:ingest) { :some_sig }
130
+ mock_config.should_receive(:signature).with(:ingest, {}) { :some_sig }
99
131
  RestClient.should_receive(:get).with(:url)
100
132
  klass.send(meth, :upload_get)
101
133
  end
@@ -103,7 +135,7 @@ describe Helix::Track do
103
135
 
104
136
  describe ".http_open" do
105
137
  let(:meth) { :http_open }
106
- let(:mock_config) { mock(Helix::Config) }
138
+ let(:mock_config) { double(Helix::Config) }
107
139
  subject { klass.method(meth) }
108
140
  its(:arity) { should eq(0) }
109
141
  it "should call upload_server_name" do
@@ -114,7 +146,7 @@ describe Helix::Track do
114
146
 
115
147
  describe ".upload_open" do
116
148
  let(:meth) { :upload_open }
117
- let(:mock_config) { mock(Helix::Config) }
149
+ let(:mock_config) { double(Helix::Config) }
118
150
  subject { klass.method(meth) }
119
151
  its(:arity) { should eq(0) }
120
152
  it "should call upload_server_name" do
@@ -125,7 +157,7 @@ describe Helix::Track do
125
157
 
126
158
  describe ".upload_close" do
127
159
  let(:meth) { :upload_close }
128
- let(:mock_config) { mock(Helix::Config) }
160
+ let(:mock_config) { double(Helix::Config) }
129
161
  subject { klass.method(meth) }
130
162
  its(:arity) { should eq(0) }
131
163
  it "should call upload_server_name" do
@@ -29,7 +29,7 @@ describe Helix::Video do
29
29
 
30
30
  describe "#download" do
31
31
  let(:meth) { :download }
32
- let(:mock_config) { mock(Helix::Config, build_url: :the_built_url, signature: :some_sig) }
32
+ let(:mock_config) { double(Helix::Config, build_url: :the_built_url, signature: :some_sig) }
33
33
  subject { obj.method(meth) }
34
34
  let(:params) { { params: {signature: :some_sig } } }
35
35
  before do
@@ -60,7 +60,7 @@ describe Helix::Video do
60
60
 
61
61
  describe "#play" do
62
62
  let(:meth) { :play }
63
- let(:mock_config) { mock(Helix::Config, build_url: :the_built_url, signature: :some_sig) }
63
+ let(:mock_config) { double(Helix::Config, build_url: :the_built_url, signature: :some_sig) }
64
64
  subject { obj.method(meth) }
65
65
  let(:params) { { params: {signature: :some_sig } } }
66
66
  before do
@@ -91,7 +91,7 @@ describe Helix::Video do
91
91
 
92
92
  describe "#stillframe" do
93
93
  let(:meth) { :stillframe }
94
- let(:mock_config) { mock(Helix::Config) }
94
+ let(:mock_config) { double(Helix::Config) }
95
95
  subject { obj.method(meth) }
96
96
  its(:arity) { should eq(-1) }
97
97
  it "should call self.class.get_stillframe" do
@@ -182,9 +182,40 @@ describe Helix::Video do
182
182
 
183
183
  ### CLASS METHODS
184
184
 
185
+ describe ".ingest_opts" do
186
+ let(:meth) { :ingest_opts }
187
+ let(:mock_config) { double(Helix::Config, credentials: {}) }
188
+ subject { klass.method(meth) }
189
+ its(:arity) { should eq(0) }
190
+ it "should be private" do expect(klass.private_methods).to include(meth) end
191
+ context "when called" do
192
+ subject { klass.send(meth) }
193
+ before(:each) do klass.stub(:config) { mock_config } end
194
+ it "should be a Hash" do expect(klass.send(meth)).to be_a(Hash) end
195
+ its(:keys) { should match_array([:contributor, :company_id, :library_id]) }
196
+ context "the value for :contributor" do
197
+ it "should be config.credentials[:contributor]" do
198
+ mock_config.should_receive(:credentials) { {contributor: :expected_contributor} }
199
+ expect(klass.send(meth)[:contributor]).to be(:expected_contributor)
200
+ end
201
+ end
202
+ context "the value for :company_id" do
203
+ it "should be config.credentials[:company]" do
204
+ mock_config.should_receive(:credentials) { {company: :expected_company} }
205
+ expect(klass.send(meth)[:company_id]).to be(:expected_company)
206
+ end
207
+ end
208
+ context "the value for :library_id" do
209
+ it "should be config.credentials[:library]" do
210
+ mock_config.should_receive(:credentials) { {library: :expected_library} }
211
+ expect(klass.send(meth)[:library_id]).to be(:expected_library)
212
+ end
213
+ end
214
+ end
215
+ end
185
216
  describe ".upload" do
186
217
  let(:meth) { :upload }
187
- let(:mock_config) { mock(Helix::Config) }
218
+ let(:mock_config) { double(Helix::Config) }
188
219
  subject { klass.method(meth) }
189
220
  its(:arity) { should eq(1) }
190
221
  let(:file_hash) { { file: :some_file } }
@@ -202,7 +233,7 @@ describe Helix::Video do
202
233
 
203
234
  describe ".upload_server_name" do
204
235
  let(:meth) { :upload_server_name }
205
- let(:mock_config) { mock(Helix::Config) }
236
+ let(:mock_config) { double(Helix::Config) }
206
237
  subject { klass.method(meth) }
207
238
  its(:arity) { should eq(0) }
208
239
  let(:url_opts) { { resource_label: "upload_sessions",
@@ -211,8 +242,9 @@ describe Helix::Video do
211
242
  content_type: "" } }
212
243
  before { Helix::Config.stub(:instance) { mock_config } }
213
244
  it "should call RestClient.get with correct url building" do
245
+ klass.should_receive(:ingest_opts) { :ingest_opts }
214
246
  mock_config.should_receive(:build_url).with(url_opts) { :url }
215
- mock_config.should_receive(:signature).with(:ingest) { :some_sig }
247
+ mock_config.should_receive(:signature).with(:ingest, :ingest_opts) { :some_sig }
216
248
  RestClient.should_receive(:get).with(:url)
217
249
  klass.send(meth)
218
250
  end
@@ -220,7 +252,7 @@ describe Helix::Video do
220
252
 
221
253
  describe ".http_close" do
222
254
  let(:meth) { :http_close }
223
- let(:mock_config) { mock(Helix::Config) }
255
+ let(:mock_config) { double(Helix::Config) }
224
256
  subject { klass.method(meth) }
225
257
  its(:arity) { should eq(0) }
226
258
  let(:url_opts) { { resource_label: "upload_sessions",
@@ -230,7 +262,7 @@ describe Helix::Video do
230
262
  before { Helix::Config.stub(:instance) { mock_config } }
231
263
  it "should call RestClient.get with correct url building" do
232
264
  mock_config.should_receive(:build_url).with(url_opts) { :url }
233
- mock_config.should_receive(:signature).with(:ingest) { :some_sig }
265
+ mock_config.should_receive(:signature).with(:ingest, {}) { :some_sig }
234
266
  RestClient.should_receive(:get).with(:url)
235
267
  klass.send(meth)
236
268
  end
@@ -238,9 +270,9 @@ describe Helix::Video do
238
270
 
239
271
  describe ".upload_get" do
240
272
  let(:meth) { :upload_get }
241
- let(:mock_config) { mock(Helix::Config) }
273
+ let(:mock_config) { double(Helix::Config) }
242
274
  subject { klass.method(meth) }
243
- its(:arity) { should eq(1) }
275
+ its(:arity) { should eq(-2) }
244
276
  let(:url_opts) { { resource_label: "upload_sessions",
245
277
  guid: :some_sig,
246
278
  action: :upload_get,
@@ -248,7 +280,7 @@ describe Helix::Video do
248
280
  before { Helix::Config.stub(:instance) { mock_config } }
249
281
  it "should call RestClient.get with correct url building" do
250
282
  mock_config.should_receive(:build_url).with(url_opts) { :url }
251
- mock_config.should_receive(:signature).with(:ingest) { :some_sig }
283
+ mock_config.should_receive(:signature).with(:ingest, {}) { :some_sig }
252
284
  RestClient.should_receive(:get).with(:url)
253
285
  klass.send(meth, :upload_get)
254
286
  end
@@ -256,7 +288,7 @@ describe Helix::Video do
256
288
 
257
289
  describe ".http_open" do
258
290
  let(:meth) { :http_open }
259
- let(:mock_config) { mock(Helix::Config) }
291
+ let(:mock_config) { double(Helix::Config) }
260
292
  subject { klass.method(meth) }
261
293
  its(:arity) { should eq(0) }
262
294
  it "should call upload_server_name" do
@@ -267,7 +299,7 @@ describe Helix::Video do
267
299
 
268
300
  describe ".upload_open" do
269
301
  let(:meth) { :upload_open }
270
- let(:mock_config) { mock(Helix::Config) }
302
+ let(:mock_config) { double(Helix::Config) }
271
303
  subject { klass.method(meth) }
272
304
  its(:arity) { should eq(0) }
273
305
  it "should call upload_server_name" do
@@ -278,7 +310,7 @@ describe Helix::Video do
278
310
 
279
311
  describe ".upload_close" do
280
312
  let(:meth) { :upload_close }
281
- let(:mock_config) { mock(Helix::Config) }
313
+ let(:mock_config) { double(Helix::Config) }
282
314
  subject { klass.method(meth) }
283
315
  its(:arity) { should eq(0) }
284
316
  it "should call upload_server_name" do
@@ -289,7 +321,7 @@ describe Helix::Video do
289
321
 
290
322
  describe ".slice" do
291
323
  let(:meth) { :slice }
292
- let(:mock_config) { mock(Helix::Config) }
324
+ let(:mock_config) { double(Helix::Config) }
293
325
  subject { klass.method(meth) }
294
326
  its(:arity) { should eq(-1) }
295
327
  let(:params) { { params: { signature: :some_sig },
@@ -313,7 +345,7 @@ describe Helix::Video do
313
345
 
314
346
  describe ".stillframe_for" do
315
347
  let(:meth) { :stillframe_for }
316
- let(:mock_config) { mock(Helix::Config) }
348
+ let(:mock_config) { double(Helix::Config) }
317
349
  subject { klass.method(meth) }
318
350
  its(:arity) { should eq(-2) }
319
351
  let(:image_data) { :some_image_data }
metadata CHANGED
@@ -1,128 +1,136 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: helix
3
- version: !ruby/object:Gem::Version
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.4.0.pre
4
5
  prerelease: 8
5
- version: 0.0.3.9.pre
6
6
  platform: ruby
7
- authors:
7
+ authors:
8
8
  - Twistage, Inc
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
-
13
- date: 2013-07-03 00:00:00 Z
14
- dependencies:
15
- - !ruby/object:Gem::Dependency
12
+ date: 2013-08-01 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
16
15
  name: json
17
- prerelease: false
18
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
19
17
  none: false
20
- requirements:
21
- - - ">="
22
- - !ruby/object:Gem::Version
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
23
21
  version: 1.5.4
24
22
  type: :runtime
25
- version_requirements: *id001
26
- - !ruby/object:Gem::Dependency
27
- name: rest-client
28
23
  prerelease: false
29
- requirement: &id002 !ruby/object:Gem::Requirement
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: 1.5.4
30
+ - !ruby/object:Gem::Dependency
31
+ name: rest-client
32
+ requirement: !ruby/object:Gem::Requirement
30
33
  none: false
31
- requirements:
32
- - - "="
33
- - !ruby/object:Gem::Version
34
+ requirements:
35
+ - - '='
36
+ - !ruby/object:Gem::Version
34
37
  version: 1.6.7
35
38
  type: :runtime
36
- version_requirements: *id002
37
- - !ruby/object:Gem::Dependency
38
- name: nori
39
39
  prerelease: false
40
- requirement: &id003 !ruby/object:Gem::Requirement
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - '='
44
+ - !ruby/object:Gem::Version
45
+ version: 1.6.7
46
+ - !ruby/object:Gem::Dependency
47
+ name: nori
48
+ requirement: !ruby/object:Gem::Requirement
41
49
  none: false
42
- requirements:
43
- - - "="
44
- - !ruby/object:Gem::Version
50
+ requirements:
51
+ - - '='
52
+ - !ruby/object:Gem::Version
45
53
  version: 1.1.3
46
54
  type: :runtime
47
- version_requirements: *id003
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - '='
60
+ - !ruby/object:Gem::Version
61
+ version: 1.1.3
48
62
  description: Provides helper libraries for Ruby access to the Twistage API
49
63
  email: kevin.baird@perceptivesoftware.com, michael.wood@perceptivesoftware.com
50
64
  executables: []
51
-
52
65
  extensions: []
53
-
54
66
  extra_rdoc_files: []
55
-
56
- files:
67
+ files:
57
68
  - lib/helix.rb
58
- - lib/helix/user.rb
59
- - lib/helix/document.rb
60
- - lib/helix/tag.rb
61
- - lib/helix/media.rb
62
- - lib/helix/statistics.rb
63
- - lib/helix/object_ext.rb
64
- - lib/helix/library.rb
69
+ - lib/helix/base.rb
65
70
  - lib/helix/audio_playlist.rb
71
+ - lib/helix/image.rb
72
+ - lib/helix/restful.rb
73
+ - lib/helix/hash_ext.rb
74
+ - lib/helix/library.rb
75
+ - lib/helix/user.rb
66
76
  - lib/helix/uploadable.rb
77
+ - lib/helix/statistics.rb
78
+ - lib/helix/document.rb
67
79
  - lib/helix/durationed.rb
68
- - lib/helix/playlist.rb
69
- - lib/helix/restful.rb
80
+ - lib/helix/object_ext.rb
70
81
  - lib/helix/video_playlist.rb
71
- - lib/helix/config.rb
82
+ - lib/helix/media.rb
72
83
  - lib/helix/video.rb
73
- - lib/helix/track.rb
74
- - lib/helix/base.rb
75
- - lib/helix/image.rb
76
84
  - lib/helix/album.rb
85
+ - lib/helix/tag.rb
86
+ - lib/helix/playlist.rb
87
+ - lib/helix/track.rb
77
88
  - lib/helix/exceptions.rb
78
- - lib/helix/hash_ext.rb
79
- - spec/spec_helper.rb
89
+ - lib/helix/config.rb
90
+ - spec/durationed_spec.rb
91
+ - spec/document_spec.rb
80
92
  - spec/audio_playlist_spec.rb
93
+ - spec/library_spec.rb
94
+ - spec/spec_helper.rb
81
95
  - spec/config_spec.rb
96
+ - spec/base_spec.rb
97
+ - spec/playlist_spec.rb
98
+ - spec/video_spec.rb
99
+ - spec/tag_spec.rb
100
+ - spec/user_spec.rb
101
+ - spec/_integration_spec.rb
102
+ - spec/album_spec.rb
82
103
  - spec/image_spec.rb
83
- - spec/media_spec.rb
84
- - spec/durationed_spec.rb
85
104
  - spec/helix_spec.rb
86
- - spec/document_spec.rb
87
- - spec/album_spec.rb
88
105
  - spec/statistics_spec.rb
89
- - spec/_integration_spec.rb
90
- - spec/tag_spec.rb
91
106
  - spec/video_playlist_spec.rb
107
+ - spec/media_spec.rb
92
108
  - spec/track_spec.rb
93
- - spec/user_spec.rb
94
- - spec/video_spec.rb
95
- - spec/playlist_spec.rb
96
- - spec/library_spec.rb
97
- - spec/base_spec.rb
98
109
  - LICENSE
99
110
  - README.md
100
111
  homepage: https://github.com/Twistage/helix/
101
- licenses:
112
+ licenses:
102
113
  - 3-Clause BSD
103
114
  post_install_message:
104
115
  rdoc_options: []
105
-
106
- require_paths:
116
+ require_paths:
107
117
  - lib
108
- required_ruby_version: !ruby/object:Gem::Requirement
118
+ required_ruby_version: !ruby/object:Gem::Requirement
109
119
  none: false
110
- requirements:
111
- - - ">="
112
- - !ruby/object:Gem::Version
113
- version: "0"
114
- required_rubygems_version: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - ! '>='
122
+ - !ruby/object:Gem::Version
123
+ version: '0'
124
+ required_rubygems_version: !ruby/object:Gem::Requirement
115
125
  none: false
116
- requirements:
117
- - - ">"
118
- - !ruby/object:Gem::Version
126
+ requirements:
127
+ - - ! '>'
128
+ - !ruby/object:Gem::Version
119
129
  version: 1.3.1
120
130
  requirements: []
121
-
122
131
  rubyforge_project:
123
- rubygems_version: 1.8.11
132
+ rubygems_version: 1.8.23
124
133
  signing_key:
125
134
  specification_version: 3
126
135
  summary: Wrapper library for the video API
127
136
  test_files: []
128
-