spec/api/deepl_spec.rb in deepl-rb-2.2.4 vs spec/api/deepl_spec.rb in deepl-rb-2.3.0
- old
+ new
@@ -45,10 +45,11 @@
let(:source_lang) { 'EN' }
let(:target_lang) { 'ES' }
let(:options) { { param: 'fake' } }
around do |example|
+ subject.configure { |config| config.host = 'https://api-free.deepl.com' }
VCR.use_cassette('deepl_translate') { example.call }
end
context 'When translating a text' do
it 'should create and call a request object' do
@@ -63,19 +64,40 @@
describe '#usage' do
let(:options) { {} }
around do |example|
+ subject.configure { |config| config.host = 'https://api-free.deepl.com' }
VCR.use_cassette('deepl_usage') { example.call }
end
context 'When checking usage' do
it 'should create and call a request object' do
expect(DeepL::Requests::Usage).to receive(:new)
.with(subject.api, options).and_call_original
usage = subject.usage(options)
expect(usage).to be_a(DeepL::Resources::Usage)
+ end
+ end
+ end
+
+ describe '#languages' do
+ let(:options) { { type: :target } }
+
+ around do |example|
+ subject.configure { |config| config.host = 'https://api-free.deepl.com' }
+ VCR.use_cassette('deepl_languages') { example.call }
+ end
+
+ context 'When checking languages' do
+ it 'should create and call a request object' do
+ expect(DeepL::Requests::Languages).to receive(:new)
+ .with(subject.api, options).and_call_original
+
+ languages = subject.languages(options)
+ expect(languages).to be_an(Array)
+ expect(languages.all? { |l| l.is_a?(DeepL::Resources::Language) }).to be_truthy
end
end
end
end