helix 0.0.2.8.pre → 0.0.2.9.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/lib/helix.rb +1 -0
- data/lib/helix/album.rb +1 -1
- data/lib/helix/base.rb +25 -6
- data/lib/helix/config.rb +6 -3
- data/lib/helix/durationed_media.rb +1 -1
- data/lib/helix/image.rb +1 -1
- data/lib/helix/library.rb +1 -1
- data/lib/helix/statistics.rb +12 -2
- data/lib/helix/tag.rb +20 -1
- data/lib/helix/track.rb +1 -1
- data/lib/helix/video.rb +1 -2
- data/spec/base_spec.rb +231 -110
- data/spec/config_spec.rb +6 -5
- data/spec/media_spec.rb +185 -165
- data/spec/statistics_spec.rb +52 -17
- data/spec/tag_spec.rb +21 -0
- data/spec/video_spec.rb +2 -2
- metadata +106 -65
data/spec/config_spec.rb
CHANGED
@@ -53,7 +53,8 @@ describe Helix::Config do
|
|
53
53
|
let(:meth) { :load }
|
54
54
|
let(:mock_obj) { mock(klass, proxy: :stubbed_proxy) }
|
55
55
|
let(:mock_file) { mock(File) }
|
56
|
-
let(:mock_cred) {
|
56
|
+
let(:mock_cred) { {key1: 'value1', 'key2' => 'value2'} }
|
57
|
+
let(:symbolized_cred) { {key1: 'value1', key2: 'value2'} }
|
57
58
|
before(:each) do
|
58
59
|
klass.stub(:instance) { mock_obj }
|
59
60
|
File.stub(:open) { mock_file }
|
@@ -78,10 +79,10 @@ describe Helix::Config do
|
|
78
79
|
YAML.should_receive(:load).with(mock_file) { mock_cred }
|
79
80
|
klass.send(meth)
|
80
81
|
end
|
81
|
-
it "should set @credentials to cred
|
82
|
+
it "should set @credentials to cred with symbol keys" do
|
82
83
|
File.stub(:open).with(klass::DEFAULT_FILENAME) { mock_file }
|
83
84
|
YAML.stub(:load).with(mock_file) { mock_cred }
|
84
|
-
mock_obj.should_receive(:instance_variable_set).with(:@credentials,
|
85
|
+
mock_obj.should_receive(:instance_variable_set).with(:@credentials, symbolized_cred)
|
85
86
|
klass.send(meth)
|
86
87
|
end
|
87
88
|
it "should set the proxy" do
|
@@ -111,10 +112,10 @@ describe Helix::Config do
|
|
111
112
|
YAML.should_receive(:load).with(mock_file) { mock_cred }
|
112
113
|
klass.send(meth, yaml_arg)
|
113
114
|
end
|
114
|
-
it "should set @credentials to cred
|
115
|
+
it "should set @credentials to cred with symbol keys" do
|
115
116
|
File.stub(:open).with(klass::DEFAULT_FILENAME) { mock_file }
|
116
117
|
YAML.stub(:load).with(mock_file) { mock_cred }
|
117
|
-
mock_obj.should_receive(:instance_variable_set).with(:@credentials,
|
118
|
+
mock_obj.should_receive(:instance_variable_set).with(:@credentials, symbolized_cred)
|
118
119
|
klass.send(meth, yaml_arg)
|
119
120
|
end
|
120
121
|
it "should return the instance" do
|
data/spec/media_spec.rb
CHANGED
@@ -3,191 +3,211 @@ require 'helix'
|
|
3
3
|
|
4
4
|
describe Helix::Media do
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
mods.each { |mod| its(:ancestors) { should include(mod) } }
|
12
|
-
|
13
|
-
describe ".create" do
|
14
|
-
let(:meth) { :create }
|
15
|
-
let(:mock_config) { mock(Helix::Config) }
|
16
|
-
subject { klass.method(meth) }
|
17
|
-
its(:arity) { should eq(-1) }
|
18
|
-
let(:klass_sym) { :klass }
|
19
|
-
let(:resp_value) { { klass_sym.to_s => { attribute: :value } } }
|
20
|
-
let(:resp_json) { "JSON" }
|
21
|
-
let(:params) { { signature: "some_sig" } }
|
22
|
-
let(:expected) { { attributes: { attribute: :value }, config: mock_config } }
|
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
|
6
|
+
shared_examples_for "builds URL for update" do
|
7
|
+
it "should build_url(content_type: :xml, guid: guid, resource_label: plural_resource_label)" do
|
8
|
+
mock_config.should_receive(:build_url).with(content_type: :xml, guid: :the_guid, resource_label: :the_resource_label)
|
9
|
+
RestClient.stub(:put)
|
10
|
+
obj.send(meth)
|
28
11
|
end
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
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
|
12
|
+
it "should get an update signature" do
|
13
|
+
mock_config.stub(:build_url)
|
14
|
+
RestClient.stub(:put)
|
15
|
+
mock_config.should_receive(:signature).with(:update) { 'some_sig' }
|
16
|
+
obj.send(meth)
|
54
17
|
end
|
55
18
|
end
|
56
19
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
20
|
+
klasses = [ Helix::Album, Helix::Image, Helix::Track, Helix::Video ]
|
21
|
+
klasses.each do |klass|
|
22
|
+
|
23
|
+
subject { klass }
|
24
|
+
|
25
|
+
mods = [ Helix::RESTful, Helix::Uploadable ]
|
26
|
+
mods.each { |mod| its(:ancestors) { should include(mod) } }
|
27
|
+
|
28
|
+
describe ".create" do
|
29
|
+
let(:meth) { :create }
|
30
|
+
let(:mock_config) { mock(Helix::Config) }
|
31
|
+
subject { klass.method(meth) }
|
32
|
+
its(:arity) { should eq(-1) }
|
33
|
+
let(:klass_sym) { :klass }
|
34
|
+
let(:resp_value) { { klass_sym.to_s => { attribute: :value } } }
|
35
|
+
let(:resp_json) { "JSON" }
|
36
|
+
let(:params) { { signature: "some_sig" } }
|
37
|
+
let(:expected) { { attributes: { attribute: :value }, config: mock_config } }
|
38
|
+
context "when a Helix:Config instance is absent" do
|
39
|
+
before(:each) do Helix::Config.stub(:instance) { nil } end
|
40
|
+
it "should raise a NoConfigurationLoaded exception" do
|
41
|
+
lambda { klass.send(meth) }.should raise_error(Helix::NoConfigurationLoaded)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
context "when a Helix:Config instance is present" do
|
68
45
|
before(:each) do
|
69
|
-
klass.stub(:
|
70
|
-
klass.stub(:
|
71
|
-
|
46
|
+
klass.stub(:plural_resource_label) { :klasses }
|
47
|
+
klass.stub(:resource_label_sym) { klass_sym }
|
48
|
+
mock_config.stub(:build_url).with(content_type: :xml, resource_label: :klasses) { :url }
|
49
|
+
mock_config.stub(:signature).with(:update) { "some_sig" }
|
50
|
+
Helix::Config.stub(:instance) { mock_config }
|
72
51
|
end
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
52
|
+
it "should get an ingest signature" do
|
53
|
+
mock_config.should_receive(:build_url).with(resource_label: :klasses,
|
54
|
+
content_type: :xml)
|
55
|
+
RestClient.stub(:post).with(:url, params) { resp_json }
|
56
|
+
Hash.should_receive(:from_xml).with(resp_json) { resp_value }
|
57
|
+
klass.stub(:new).with(expected)
|
58
|
+
mock_config.should_receive(:signature).with(:update) { "some_sig" }
|
59
|
+
klass.send(meth)
|
78
60
|
end
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
61
|
+
it "should do an HTTP post call, parse response and call new" do
|
62
|
+
mock_config.should_receive(:build_url).with(resource_label: :klasses,
|
63
|
+
content_type: :xml)
|
64
|
+
RestClient.should_receive(:post).with(:url, params) { resp_json }
|
65
|
+
Hash.should_receive(:from_xml).with(resp_json) { resp_value }
|
66
|
+
klass.should_receive(:new).with(expected)
|
67
|
+
klass.send(meth)
|
84
68
|
end
|
85
69
|
end
|
86
70
|
end
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
71
|
+
|
72
|
+
describe ".find" do
|
73
|
+
let(:meth) { :find }
|
74
|
+
let(:mock_config) { mock(Helix::Config) }
|
75
|
+
let(:mock_obj) { mock(klass, :load => :output_of_load) }
|
76
|
+
subject { klass.method(meth) }
|
77
|
+
its(:arity) { should eq(1) }
|
78
|
+
context "when a Helix:Config instance is absent" do
|
79
|
+
before(:each) do Helix::Config.stub(:instance) { nil } end
|
80
|
+
context "and given a guid" do
|
81
|
+
let(:guid_name) { :the_guid_name }
|
82
|
+
let(:mock_attrs) { mock(Object, :[]= => :output_of_setting_val) }
|
83
|
+
before(:each) do
|
84
|
+
klass.stub(:attributes) { mock_attrs }
|
85
|
+
klass.stub(:guid_name) { guid_name }
|
86
|
+
klass.stub(:new) { mock_obj }
|
87
|
+
end
|
88
|
+
context "and the guid is nil" do
|
89
|
+
it "should raise an ArgumentError complaining about a nil guid" do
|
90
|
+
msg = 'find requires a non-nil guid argument - received a nil argument.'
|
91
|
+
lambda { klass.send(meth, nil) }.should raise_error(ArgumentError, msg)
|
92
|
+
end
|
93
|
+
end
|
94
|
+
context "and the guid is non-nil" do
|
95
|
+
let(:guid) { :a_guid }
|
96
|
+
it "should raise a NoConfigurationLoaded exception" do
|
97
|
+
lambda { klass.send(meth, guid) }.should raise_error(Helix::NoConfigurationLoaded)
|
98
|
+
end
|
101
99
|
end
|
102
100
|
end
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
101
|
+
end
|
102
|
+
context "when a Helix::Config instance is present" do
|
103
|
+
before(:each) do Helix::Config.stub(:instance) { mock_config } end
|
104
|
+
context "and given a guid" do
|
105
|
+
let(:guid_name) { :the_guid_name }
|
106
|
+
let(:mock_attrs) { mock(Object, :[]= => :output_of_setting_val) }
|
107
|
+
before(:each) do
|
108
|
+
klass.stub(:attributes) { mock_attrs }
|
109
|
+
klass.stub(:guid_name) { guid_name }
|
110
|
+
klass.stub(:new) { mock_obj }
|
111
|
+
end
|
112
|
+
context "and the guid is nil" do
|
113
|
+
it "should raise an ArgumentError complaining about a nil guid" do
|
114
|
+
msg = 'find requires a non-nil guid argument - received a nil argument.'
|
115
|
+
lambda { klass.send(meth, nil) }.should raise_error(ArgumentError, msg)
|
116
|
+
end
|
108
117
|
end
|
109
|
-
|
110
|
-
|
111
|
-
|
118
|
+
context "and the guid is non-nil" do
|
119
|
+
let(:guid) { :a_guid }
|
120
|
+
it "should instantiate with {attributes: guid_name => the_guid, config: config}" do
|
121
|
+
klass.should_receive(:new).with({attributes: {guid_name => guid}, config: mock_config})
|
122
|
+
klass.send(meth, guid)
|
123
|
+
end
|
124
|
+
it "should load" do
|
125
|
+
mock_obj.should_receive(:load)
|
126
|
+
klass.send(meth, guid)
|
127
|
+
end
|
112
128
|
end
|
113
129
|
end
|
114
130
|
end
|
115
131
|
end
|
116
|
-
end
|
117
132
|
|
118
|
-
|
119
|
-
|
133
|
+
child_classes = [ Helix::Album, Helix::Image, Helix::Track, Helix::Video ]
|
134
|
+
child_classes.each do |child_class|
|
135
|
+
describe "an instance of #{child_class.to_s}" do
|
136
|
+
let(:obj) { child_class.new({}) }
|
120
137
|
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
end
|
147
|
-
describe "#update" do
|
148
|
-
let(:meth) { :update }
|
149
|
-
let(:mock_config) { mock(Helix::Config) }
|
150
|
-
subject { obj.method(meth) }
|
151
|
-
its(:arity) { should eq(-1) }
|
152
|
-
before(:each) do
|
153
|
-
obj.stub(:config) { mock_config }
|
154
|
-
obj.stub(:guid) { :the_guid }
|
155
|
-
obj.stub(:resource_label_sym) { :video }
|
156
|
-
obj.stub(:plural_resource_label) { :the_resource_label }
|
157
|
-
mock_config.stub(:signature).with(:update) { 'some_sig' }
|
158
|
-
mock_config.stub(:build_url) { :expected_url }
|
159
|
-
end
|
160
|
-
shared_examples_for "builds URL for update" do
|
161
|
-
it "should build_url(content_type: :xml, guid: guid, resource_label: plural_resource_label)" do
|
162
|
-
mock_config.should_receive(:build_url).with(content_type: :xml, guid: :the_guid, resource_label: :the_resource_label)
|
163
|
-
RestClient.stub(:put)
|
164
|
-
obj.send(meth)
|
165
|
-
end
|
166
|
-
it "should get an update signature" do
|
167
|
-
mock_config.stub(:build_url)
|
168
|
-
RestClient.stub(:put)
|
169
|
-
mock_config.should_receive(:signature).with(:update) { 'some_sig' }
|
170
|
-
obj.send(meth)
|
171
|
-
end
|
172
|
-
end
|
173
|
-
context "when given no argument" do
|
174
|
-
it_behaves_like "builds URL for update"
|
175
|
-
it "should call RestClient.put(output_of_build_url, {signature: the_sig, video: {}}) and return instance of klass" do
|
176
|
-
RestClient.should_receive(:put).with(:expected_url, {signature: 'some_sig', video: {}})
|
177
|
-
expect(obj.send(meth)).to be_an_instance_of(klass)
|
178
|
-
end
|
179
|
-
end
|
180
|
-
context "when given an opts argument of {key1: :value1}" do
|
181
|
-
let(:opts) { {key1: :value1} }
|
182
|
-
it_behaves_like "builds URL for update"
|
183
|
-
it "clones the opts arg" do
|
184
|
-
RestClient.stub(:put).with(:expected_url, {signature: 'some_sig', video: opts})
|
185
|
-
opts.should_receive(:clone) { opts }
|
186
|
-
obj.send(meth, opts)
|
138
|
+
describe "#destroy" do
|
139
|
+
let(:meth) { :destroy }
|
140
|
+
let(:mock_config) { mock(Helix::Config, build_url: :the_built_url, signature: :some_sig) }
|
141
|
+
subject { obj.method(meth) }
|
142
|
+
let(:params) { { params: {signature: :some_sig } } }
|
143
|
+
before do
|
144
|
+
obj.stub(:config) { mock_config }
|
145
|
+
obj.stub(:guid) { :some_guid }
|
146
|
+
obj.stub(:plural_resource_label) { :resource_label }
|
147
|
+
end
|
148
|
+
it "should get an update signature" do
|
149
|
+
url = mock_config.build_url(resource_label: :resource_label,
|
150
|
+
guid: :some_guid,
|
151
|
+
content_type: :xml)
|
152
|
+
RestClient.stub(:delete).with(url, params)
|
153
|
+
mock_config.should_receive(:signature).with(:update) { :some_sig }
|
154
|
+
obj.send(meth)
|
155
|
+
end
|
156
|
+
it "should call for an HTTP delete and return nil" do
|
157
|
+
url = mock_config.build_url(resource_label: :resource_label,
|
158
|
+
guid: :some_guid,
|
159
|
+
content_type: :xml)
|
160
|
+
RestClient.should_receive(:delete).with(url, params)
|
161
|
+
expect(obj.send(meth)).to be_nil
|
162
|
+
end
|
187
163
|
end
|
188
|
-
|
189
|
-
|
190
|
-
|
164
|
+
describe "#update" do
|
165
|
+
next if child_class == Helix::Album
|
166
|
+
let(:meth) { :update }
|
167
|
+
let(:mock_config) { mock(Helix::Config) }
|
168
|
+
subject { obj.method(meth) }
|
169
|
+
its(:arity) { should eq(-1) }
|
170
|
+
before(:each) do
|
171
|
+
obj.stub(:config) { mock_config }
|
172
|
+
obj.stub(:guid) { :the_guid }
|
173
|
+
obj.stub(:resource_label_sym) { :video }
|
174
|
+
obj.stub(:plural_resource_label) { :the_resource_label }
|
175
|
+
mock_config.stub(:signature).with(:update) { 'some_sig' }
|
176
|
+
mock_config.stub(:build_url) { :expected_url }
|
177
|
+
end
|
178
|
+
shared_examples_for "builds URL for update" do
|
179
|
+
it "should build_url(content_type: :xml, guid: guid, resource_label: plural_resource_label)" do
|
180
|
+
mock_config.should_receive(:build_url).with(content_type: :xml, guid: :the_guid, resource_label: :the_resource_label)
|
181
|
+
RestClient.stub(:put)
|
182
|
+
obj.send(meth)
|
183
|
+
end
|
184
|
+
it "should get an update signature" do
|
185
|
+
mock_config.stub(:build_url)
|
186
|
+
RestClient.stub(:put)
|
187
|
+
mock_config.should_receive(:signature).with(:update) { 'some_sig' }
|
188
|
+
obj.send(meth)
|
189
|
+
end
|
190
|
+
end
|
191
|
+
context "when given no argument" do
|
192
|
+
it_behaves_like "builds URL for update"
|
193
|
+
it "should call RestClient.put(output_of_build_url, {signature: the_sig, video: {}}) and return instance of klass" do
|
194
|
+
RestClient.should_receive(:put).with(:expected_url, {signature: 'some_sig', video: {}})
|
195
|
+
expect(obj.send(meth)).to be_an_instance_of(child_class)
|
196
|
+
end
|
197
|
+
end
|
198
|
+
context "when given an opts argument of {key1: :value1}" do
|
199
|
+
let(:opts) { {key1: :value1} }
|
200
|
+
it_behaves_like "builds URL for update"
|
201
|
+
it "clones the opts arg" do
|
202
|
+
RestClient.stub(:put).with(:expected_url, {signature: 'some_sig', video: opts})
|
203
|
+
opts.should_receive(:clone) { opts }
|
204
|
+
obj.send(meth, opts)
|
205
|
+
end
|
206
|
+
it "should call RestClient.put(output_of_build_url, {signature: the_sig, video: opts}) and return instance of klass" do
|
207
|
+
RestClient.should_receive(:put).with(:expected_url, {signature: 'some_sig', video: opts})
|
208
|
+
expect(obj.send(meth, opts)).to be_an_instance_of(child_class)
|
209
|
+
end
|
210
|
+
end
|
191
211
|
end
|
192
212
|
end
|
193
213
|
end
|
data/spec/statistics_spec.rb
CHANGED
@@ -24,6 +24,13 @@ describe Helix::Statistics do
|
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
|
+
shared_examples_for "standardizes raw stats" do
|
28
|
+
it "should return standardize_raw_stats(raw)" do
|
29
|
+
mod.should_receive(:standardize_raw_stats).with(:raw_response) { :response }
|
30
|
+
expect(mod.send(meth, opts)).to eq(:response)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
27
34
|
STATS_TYPES.each do |stats_type|
|
28
35
|
STATS_MEDIA_TYPES.each do |resource_label|
|
29
36
|
|
@@ -31,8 +38,11 @@ describe Helix::Statistics do
|
|
31
38
|
|
32
39
|
describe ".#{resource_label}_#{stats_type}" do
|
33
40
|
let(:meth) { "#{resource_label}_#{stats_type}" }
|
34
|
-
let(:mock_config) { mock(Helix::Config, build_url: :built_url, get_response: :
|
35
|
-
before(:each) do
|
41
|
+
let(:mock_config) { mock(Helix::Config, build_url: :built_url, get_response: :raw_response) }
|
42
|
+
before(:each) do
|
43
|
+
Helix::Config.stub(:instance) { mock_config }
|
44
|
+
mod.stub(:standardize_raw_stats).with(:raw_response) { :response }
|
45
|
+
end
|
36
46
|
|
37
47
|
subject { mod.method(meth) }
|
38
48
|
its(:arity) { should eq(-1) }
|
@@ -76,10 +86,11 @@ describe Helix::Statistics do
|
|
76
86
|
mod.send(meth, opts)
|
77
87
|
end
|
78
88
|
end
|
79
|
-
it "should
|
80
|
-
mock_config.should_receive(:get_response).with(:built_url, {group: :daily, sig_type: :view}) { :
|
81
|
-
|
89
|
+
it "should assign config.get_response(built_url, opts.merge(sig_type: :view) => raw" do
|
90
|
+
mock_config.should_receive(:get_response).with(:built_url, {group: :daily, sig_type: :view}) { :raw_response }
|
91
|
+
mod.send(meth, opts)
|
82
92
|
end
|
93
|
+
it_behaves_like "standardizes raw stats"
|
83
94
|
end
|
84
95
|
context "when given opts NOT containing a :#{media_name}_id" do
|
85
96
|
let(:opts) { {group: :daily} }
|
@@ -112,10 +123,11 @@ describe Helix::Statistics do
|
|
112
123
|
mod.send(meth, opts)
|
113
124
|
end
|
114
125
|
end
|
115
|
-
it "should
|
116
|
-
mock_config.should_receive(:get_response).with(:built_url, {group: :daily, sig_type: :view}) { :
|
117
|
-
|
126
|
+
it "should assign config.get_response(built_url, opts.merge(sig_type: :view) => raw" do
|
127
|
+
mock_config.should_receive(:get_response).with(:built_url, {group: :daily, sig_type: :view}) { :raw_response }
|
128
|
+
mod.send(meth, opts)
|
118
129
|
end
|
130
|
+
it_behaves_like "standardizes raw stats"
|
119
131
|
end
|
120
132
|
when 'ingest'
|
121
133
|
media_name = MEDIA_NAME_OF[resource_label] || resource_label
|
@@ -132,10 +144,11 @@ describe Helix::Statistics do
|
|
132
144
|
mock_config.should_receive(:build_url).with({resource_label: :statistics, action: "#{media_name}_#{publish_name}/breakdown".to_sym}) { :built_url }
|
133
145
|
mod.send(meth, opts)
|
134
146
|
end
|
135
|
-
it "should
|
136
|
-
mock_config.should_receive(:get_response).with(:built_url, {group: :daily, sig_type: :view}) { :
|
137
|
-
|
147
|
+
it "should assign config.get_response(built_url, opts.merge(sig_type: :view) => raw" do
|
148
|
+
mock_config.should_receive(:get_response).with(:built_url, {group: :daily, sig_type: :view}) { :raw_response }
|
149
|
+
mod.send(meth, opts)
|
138
150
|
end
|
151
|
+
it_behaves_like "standardizes raw stats"
|
139
152
|
end
|
140
153
|
[ :encode, :source, :breakdown ].each do |act|
|
141
154
|
context "and opts has an :action value of :#{act}" do
|
@@ -149,10 +162,11 @@ describe Helix::Statistics do
|
|
149
162
|
mock_config.should_receive(:build_url).with({resource_label: :statistics, action: "#{media_name}_#{publish_name}/#{act}".to_sym}) { :built_url }
|
150
163
|
mod.send(meth, opts)
|
151
164
|
end
|
152
|
-
it "should
|
153
|
-
mock_config.should_receive(:get_response).with(:built_url, {group: :daily, sig_type: :view}) { :
|
154
|
-
|
165
|
+
it "should assign config.get_response(built_url, opts.merge(sig_type: :view) => raw" do
|
166
|
+
mock_config.should_receive(:get_response).with(:built_url, {group: :daily, sig_type: :view}) { :raw_response }
|
167
|
+
mod.send(meth, opts)
|
155
168
|
end
|
169
|
+
it_behaves_like "standardizes raw stats"
|
156
170
|
end
|
157
171
|
end
|
158
172
|
end
|
@@ -170,10 +184,11 @@ describe Helix::Statistics do
|
|
170
184
|
mock_config.should_receive(:build_url).with({resource_label: :statistics, action: "#{media_name}_#{publish_name}/disk_usage".to_sym}) { :built_url }
|
171
185
|
mod.send(meth, opts)
|
172
186
|
end
|
173
|
-
it "should
|
174
|
-
mock_config.should_receive(:get_response).with(:built_url, {group: :daily, sig_type: :view}) { :
|
175
|
-
|
187
|
+
it "should assign config.get_response(built_url, opts.merge(sig_type: :view) => raw" do
|
188
|
+
mock_config.should_receive(:get_response).with(:built_url, {group: :daily, sig_type: :view}) { :raw_response }
|
189
|
+
mod.send(meth, opts)
|
176
190
|
end
|
191
|
+
it_behaves_like "standardizes raw stats"
|
177
192
|
end
|
178
193
|
# nested in for case
|
179
194
|
end
|
@@ -242,4 +257,24 @@ describe Helix::Statistics do
|
|
242
257
|
|
243
258
|
end
|
244
259
|
|
260
|
+
describe "#standardize_raw_stats" do
|
261
|
+
let(:meth) { :standardize_raw_stats }
|
262
|
+
describe "arity" do
|
263
|
+
subject { mod.method(meth) }
|
264
|
+
its(:arity) { should eq(1) }
|
265
|
+
end
|
266
|
+
args = [ [], {}, { some_key: :some_value } ]
|
267
|
+
args.each do |arg|
|
268
|
+
context "when given #{arg.inspect}" do
|
269
|
+
it "should eq #{arg.inspect}" do
|
270
|
+
expect(mod.send(meth, arg)).to eq(arg)
|
271
|
+
end
|
272
|
+
end
|
273
|
+
end
|
274
|
+
context "when given {'statistics_reports' => :expected}" do
|
275
|
+
subject { mod.send(meth, {'statistics_reports' => :expected}) }
|
276
|
+
it { should eq(:expected) }
|
277
|
+
end
|
278
|
+
end
|
279
|
+
|
245
280
|
end
|