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.
@@ -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) { mock(Hash, symbolize_keys: :symbolized_creds) }
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.symbolize_keys" do
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, mock_cred.symbolize_keys)
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.symbolize_keys" do
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, mock_cred.symbolize_keys)
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
@@ -3,191 +3,211 @@ require 'helix'
3
3
 
4
4
  describe Helix::Media do
5
5
 
6
- let(:klass) { Helix::Media }
7
-
8
- subject { klass }
9
-
10
- mods = [ Helix::RESTful, Helix::Uploadable ]
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
- 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
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
- describe ".find" do
58
- let(:meth) { :find }
59
- let(:mock_config) { mock(Helix::Config) }
60
- let(:mock_obj) { mock(klass, :load => :output_of_load) }
61
- subject { klass.method(meth) }
62
- its(:arity) { should eq(1) }
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) }
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(:attributes) { mock_attrs }
70
- klass.stub(:guid_name) { guid_name }
71
- klass.stub(:new) { mock_obj }
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
- 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
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
- 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
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
- 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)
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
- 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)
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
- it "should load" do
110
- mock_obj.should_receive(:load)
111
- klass.send(meth, guid)
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
- describe "an instance" do
119
- let(:obj) { klass.new({}) }
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
- describe "#destroy" do
122
- let(:meth) { :destroy }
123
- let(:mock_config) { mock(Helix::Config, build_url: :the_built_url, signature: :some_sig) }
124
- subject { obj.method(meth) }
125
- let(:params) { { params: {signature: :some_sig } } }
126
- before do
127
- obj.stub(:config) { mock_config }
128
- obj.stub(:guid) { :some_guid }
129
- obj.stub(:plural_resource_label) { :resource_label }
130
- end
131
- it "should get an update signature" do
132
- url = mock_config.build_url(resource_label: :resource_label,
133
- guid: :some_guid,
134
- content_type: :xml)
135
- RestClient.stub(:delete).with(url, params)
136
- mock_config.should_receive(:signature).with(:update) { :some_sig }
137
- obj.send(meth)
138
- end
139
- it "should call for an HTTP delete and return nil" do
140
- url = mock_config.build_url(resource_label: :resource_label,
141
- guid: :some_guid,
142
- content_type: :xml)
143
- RestClient.should_receive(:delete).with(url, params)
144
- expect(obj.send(meth)).to be_nil
145
- end
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
- it "should call RestClient.put(output_of_build_url, {signature: the_sig, video: opts}) and return instance of klass" do
189
- RestClient.should_receive(:put).with(:expected_url, {signature: 'some_sig', video: opts})
190
- expect(obj.send(meth, opts)).to be_an_instance_of(klass)
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
@@ -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: :response) }
35
- before(:each) do Helix::Config.stub(:instance) { mock_config } end
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 return config.get_response(built_url, opts.merge(sig_type: :view)" do
80
- mock_config.should_receive(:get_response).with(:built_url, {group: :daily, sig_type: :view}) { :response }
81
- expect(mod.send(meth, opts)).to eq(:response)
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 return config.get_response(built_url, opts.merge(sig_type: :view)" do
116
- mock_config.should_receive(:get_response).with(:built_url, {group: :daily, sig_type: :view}) { :response }
117
- expect(mod.send(meth, opts)).to eq(:response)
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 return config.get_response(built_url, opts.merge(sig_type: :view)" do
136
- mock_config.should_receive(:get_response).with(:built_url, {group: :daily, sig_type: :view}) { :response }
137
- expect(mod.send(meth, opts)).to eq(:response)
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 return config.get_response(built_url, opts.merge(sig_type: :view)" do
153
- mock_config.should_receive(:get_response).with(:built_url, {group: :daily, sig_type: :view}) { :response }
154
- expect(mod.send(meth, opts)).to eq(:response)
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 return config.get_response(built_url, opts.merge(sig_type: :view)" do
174
- mock_config.should_receive(:get_response).with(:built_url, {group: :daily, sig_type: :view}) { :response }
175
- expect(mod.send(meth, opts)).to eq(:response)
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