mirror of
https://git.kescher.at/CatCatNya/catstodon.git
synced 2024-11-25 20:11:37 +01:00
Ignore block result of send
method and remove rubocop:disable
in deepl spec (#27741)
This commit is contained in:
parent
c73d5a6075
commit
4329616c53
1 changed files with 21 additions and 22 deletions
|
@ -8,12 +8,14 @@ RSpec.describe TranslationService::DeepL do
|
|||
let(:plan) { 'advanced' }
|
||||
|
||||
before do
|
||||
stub_request(:get, 'https://api.deepl.com/v2/languages?type=source').to_return(
|
||||
body: '[{"language":"EN","name":"English"},{"language":"UK","name":"Ukrainian"}]'
|
||||
)
|
||||
stub_request(:get, 'https://api.deepl.com/v2/languages?type=target').to_return(
|
||||
body: '[{"language":"EN-GB","name":"English (British)"},{"language":"ZH","name":"Chinese"}]'
|
||||
)
|
||||
%w(api-free.deepl.com api.deepl.com).each do |host|
|
||||
stub_request(:get, "https://#{host}/v2/languages?type=source").to_return(
|
||||
body: '[{"language":"EN","name":"English"},{"language":"UK","name":"Ukrainian"}]'
|
||||
)
|
||||
stub_request(:get, "https://#{host}/v2/languages?type=target").to_return(
|
||||
body: '[{"language":"EN-GB","name":"English (British)"},{"language":"ZH","name":"Chinese"}]'
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
describe '#translate' do
|
||||
|
@ -73,28 +75,25 @@ RSpec.describe TranslationService::DeepL do
|
|||
end
|
||||
end
|
||||
|
||||
describe '#request' do
|
||||
describe 'the paid and free plan api hostnames' do
|
||||
before do
|
||||
stub_request(:any, //)
|
||||
# rubocop:disable Lint/EmptyBlock
|
||||
service.send(:request, :get, '/v2/languages') { |res| }
|
||||
# rubocop:enable Lint/EmptyBlock
|
||||
service.languages
|
||||
end
|
||||
|
||||
it 'uses paid plan base URL' do
|
||||
expect(a_request(:get, 'https://api.deepl.com/v2/languages')).to have_been_made.once
|
||||
end
|
||||
|
||||
context 'with free plan' do
|
||||
let(:plan) { 'free' }
|
||||
|
||||
it 'uses free plan base URL' do
|
||||
expect(a_request(:get, 'https://api-free.deepl.com/v2/languages')).to have_been_made.once
|
||||
context 'without a plan set' do
|
||||
it 'uses paid plan base URL and sends an API key' do
|
||||
expect(a_request(:get, 'https://api.deepl.com/v2/languages?type=source').with(headers: { Authorization: 'DeepL-Auth-Key my-api-key' })).to have_been_made.once
|
||||
expect(a_request(:get, 'https://api.deepl.com/v2/languages?type=target').with(headers: { Authorization: 'DeepL-Auth-Key my-api-key' })).to have_been_made.once
|
||||
end
|
||||
end
|
||||
|
||||
it 'sends API key' do
|
||||
expect(a_request(:get, 'https://api.deepl.com/v2/languages').with(headers: { Authorization: 'DeepL-Auth-Key my-api-key' })).to have_been_made.once
|
||||
context 'with the free plan' do
|
||||
let(:plan) { 'free' }
|
||||
|
||||
it 'uses free plan base URL and sends an API key' do
|
||||
expect(a_request(:get, 'https://api-free.deepl.com/v2/languages?type=source').with(headers: { Authorization: 'DeepL-Auth-Key my-api-key' })).to have_been_made.once
|
||||
expect(a_request(:get, 'https://api-free.deepl.com/v2/languages?type=target').with(headers: { Authorization: 'DeepL-Auth-Key my-api-key' })).to have_been_made.once
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue