Skip to content

Commit c39957f

Browse files
committed
Fix errors
1 parent ef3beb8 commit c39957f

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

lib/optimizely/cmab/cmab_client.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ def status_code
208208
def json
209209
JSON.parse(@response.body)
210210
rescue JSON::ParserError
211-
raise Optimizely::CmabInvalidResponseError, 'Invalid JSON response from CMAB service.'
211+
raise Optimizely::CmabInvalidResponseError, Optimizely::Helpers::Constants::INVALID_CMAB_FETCH_RESPONSE
212212
end
213213

214214
def body

spec/cmab_client_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
end
5656

5757
context 'when client is configured without retries' do
58-
let(:client) { described_class.new(nil, nil, spy_logger) }
58+
let(:client) { described_class.new(nil, Optimizely::CmabRetryConfig.new(max_retries: 0), spy_logger) }
5959

6060
it 'should return the variation id on success' do
6161
WebMock.stub_request(:post, expected_url)
@@ -158,7 +158,7 @@
158158

159159
expect(result).to eq('xyz456')
160160
expect(WebMock).to have_requested(:post, expected_url)
161-
.with(body: expected_body_for_webmock, headers: expected_headers).exactly(3).times
161+
.with(body: expected_body_for_webmock, headers: expected_headers).times(3)
162162

163163
expect(spy_logger).to have_received(:log).with(Logger::INFO, 'Retrying CMAB request (attempt 1) after 0.01 seconds...').once
164164
expect(spy_logger).to have_received(:log).with(Logger::INFO, 'Retrying CMAB request (attempt 2) after 0.02 seconds...').once
@@ -182,7 +182,7 @@
182182
end.to raise_error(Optimizely::CmabFetchError)
183183

184184
expect(WebMock).to have_requested(:post, expected_url)
185-
.with(body: expected_body_for_webmock, headers: expected_headers).exactly(4).times
185+
.with(body: expected_body_for_webmock, headers: expected_headers).times(4)
186186

187187
expect(spy_logger).to have_received(:log).with(Logger::INFO, 'Retrying CMAB request (attempt 1) after 0.01 seconds...').once
188188
expect(spy_logger).to have_received(:log).with(Logger::INFO, 'Retrying CMAB request (attempt 2) after 0.02 seconds...').once

0 commit comments

Comments
 (0)