deepl-rb 3.0.1 → 3.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -14,7 +14,7 @@ http_interactions:
14
14
  Accept:
15
15
  - "*/*"
16
16
  User-Agent:
17
- - deepl-ruby/2.5.3 (darwin23) ruby/3.3.3
17
+ - deepl-ruby/3.0.2 (darwin23) ruby/3.3.3
18
18
  Content-Type:
19
19
  - application/x-www-form-urlencoded
20
20
  response:
@@ -53,7 +53,7 @@ http_interactions:
53
53
  Accept:
54
54
  - "*/*"
55
55
  User-Agent:
56
- - deepl-ruby/2.5.3 (darwin23) ruby/3.3.3
56
+ - deepl-ruby/3.0.2 (darwin23) ruby/3.3.3
57
57
  Content-Type:
58
58
  - application/x-www-form-urlencoded
59
59
  response:
@@ -91,7 +91,7 @@ http_interactions:
91
91
  Accept:
92
92
  - "*/*"
93
93
  User-Agent:
94
- - deepl-ruby/2.5.3 (darwin23) ruby/3.3.3
94
+ - deepl-ruby/3.0.2 (darwin23) ruby/3.3.3
95
95
  Content-Type:
96
96
  - application/x-www-form-urlencoded
97
97
  response:
@@ -130,7 +130,7 @@ http_interactions:
130
130
  Accept:
131
131
  - "*/*"
132
132
  User-Agent:
133
- - deepl-ruby/2.5.3 (darwin23) ruby/3.3.3
133
+ - deepl-ruby/3.0.2 (darwin23) ruby/3.3.3
134
134
  Content-Type:
135
135
  - application/x-www-form-urlencoded
136
136
  response:
@@ -166,7 +166,7 @@ http_interactions:
166
166
  Accept:
167
167
  - "*/*"
168
168
  User-Agent:
169
- - deepl-ruby/2.5.3 (darwin23) ruby/3.3.3
169
+ - deepl-ruby/3.0.2 (darwin23) ruby/3.3.3
170
170
  Content-Type:
171
171
  - application/x-www-form-urlencoded
172
172
  response:
@@ -202,7 +202,7 @@ http_interactions:
202
202
  Accept:
203
203
  - "*/*"
204
204
  User-Agent:
205
- - deepl-ruby/2.5.3 (darwin23) ruby/3.3.3
205
+ - deepl-ruby/3.0.2 (darwin23) ruby/3.3.3
206
206
  Content-Type:
207
207
  - application/x-www-form-urlencoded
208
208
  response:
@@ -236,7 +236,7 @@ http_interactions:
236
236
  Accept:
237
237
  - "*/*"
238
238
  User-Agent:
239
- - deepl-ruby/2.5.3 (darwin23) ruby/3.3.3
239
+ - deepl-ruby/3.0.2 (darwin23) ruby/3.3.3
240
240
  Content-Type:
241
241
  - application/x-www-form-urlencoded
242
242
  response:
@@ -273,7 +273,7 @@ http_interactions:
273
273
  Accept:
274
274
  - "*/*"
275
275
  User-Agent:
276
- - deepl-ruby/2.5.3 (darwin23) ruby/3.3.3
276
+ - deepl-ruby/3.0.2 (darwin23) ruby/3.3.3
277
277
  Content-Type:
278
278
  - application/x-www-form-urlencoded
279
279
  response:
@@ -311,7 +311,7 @@ http_interactions:
311
311
  Accept:
312
312
  - "*/*"
313
313
  User-Agent:
314
- - deepl-ruby/2.5.3 (darwin23) ruby/3.3.3
314
+ - deepl-ruby/3.0.2 (darwin23) ruby/3.3.3
315
315
  Content-Type:
316
316
  - application/x-www-form-urlencoded
317
317
  response:
@@ -352,7 +352,7 @@ http_interactions:
352
352
  Accept:
353
353
  - "*/*"
354
354
  User-Agent:
355
- - deepl-ruby/2.5.3 (darwin23) ruby/3.3.3
355
+ - deepl-ruby/3.0.2 (darwin23) ruby/3.3.3
356
356
  Content-Type:
357
357
  - application/x-www-form-urlencoded
358
358
  response:
@@ -393,7 +393,7 @@ http_interactions:
393
393
  Accept:
394
394
  - "*/*"
395
395
  User-Agent:
396
- - deepl-ruby/2.5.3 (darwin23) ruby/3.3.3
396
+ - deepl-ruby/3.0.2 (darwin23) ruby/3.3.3
397
397
  Content-Type:
398
398
  - application/x-www-form-urlencoded
399
399
  response:
@@ -4866,7 +4866,7 @@ http_interactions:
4866
4866
  Authorization:
4867
4867
  - DeepL-Auth-Key VALID_TOKEN
4868
4868
  User-Agent:
4869
- - deepl-ruby/2.5.3(darwin23) ruby/3.3.3
4869
+ - deepl-ruby/3.0.2 (darwin23) ruby/3.3.3
4870
4870
  Content-Type:
4871
4871
  - application/json
4872
4872
  Accept-Encoding:
@@ -4907,7 +4907,7 @@ http_interactions:
4907
4907
  Authorization:
4908
4908
  - DeepL-Auth-Key invalid
4909
4909
  User-Agent:
4910
- - deepl-ruby/2.5.3(darwin23) ruby/3.3.3
4910
+ - deepl-ruby/3.0.2 (darwin23) ruby/3.3.3
4911
4911
  Content-Type:
4912
4912
  - application/json
4913
4913
  Accept-Encoding:
@@ -4947,7 +4947,7 @@ http_interactions:
4947
4947
  Authorization:
4948
4948
  - DeepL-Auth-Key VALID_TOKEN
4949
4949
  User-Agent:
4950
- - deepl-ruby/2.5.3 (darwin23) ruby/3.3.3
4950
+ - deepl-ruby/3.0.2 (darwin23) ruby/3.3.3
4951
4951
  Content-Type:
4952
4952
  - application/json
4953
4953
  Accept-Encoding:
@@ -4991,7 +4991,7 @@ http_interactions:
4991
4991
  Authorization:
4992
4992
  - DeepL-Auth-Key invalid
4993
4993
  User-Agent:
4994
- - deepl-ruby/2.5.3 (darwin23) ruby/3.3.3
4994
+ - deepl-ruby/3.0.2 (darwin23) ruby/3.3.3
4995
4995
  Content-Type:
4996
4996
  - application/json
4997
4997
  Accept-Encoding:
@@ -5031,7 +5031,7 @@ http_interactions:
5031
5031
  Authorization:
5032
5032
  - DeepL-Auth-Key VALID_TOKEN
5033
5033
  User-Agent:
5034
- - deepl-ruby/2.5.3 (darwin23) ruby/3.3.3
5034
+ - deepl-ruby/3.0.2 (darwin23) ruby/3.3.3
5035
5035
  Content-Type:
5036
5036
  - application/json
5037
5037
  Accept-Encoding:
@@ -9513,7 +9513,7 @@ http_interactions:
9513
9513
  Authorization:
9514
9514
  - DeepL-Auth-Key VALID_TOKEN
9515
9515
  User-Agent:
9516
- - deepl-ruby/2.5.3 (darwin23) ruby/3.3.3
9516
+ - deepl-ruby/3.0.2 (darwin23) ruby/3.3.3
9517
9517
  Content-Type:
9518
9518
  - application/json
9519
9519
  Accept-Encoding:
@@ -9597,7 +9597,7 @@ http_interactions:
9597
9597
  Authorization:
9598
9598
  - DeepL-Auth-Key VALID_TOKEN
9599
9599
  User-Agent:
9600
- - deepl-ruby/2.5.3 (darwin23) ruby/3.3.3
9600
+ - deepl-ruby/3.0.2 (darwin23) ruby/3.3.3
9601
9601
  Content-Type:
9602
9602
  - application/json
9603
9603
  Accept-Encoding:
@@ -9642,7 +9642,7 @@ http_interactions:
9642
9642
  Authorization:
9643
9643
  - DeepL-Auth-Key VALID_TOKEN
9644
9644
  User-Agent:
9645
- - deepl-ruby/2.5.3 (darwin23) ruby/3.3.3
9645
+ - deepl-ruby/3.0.2 (darwin23) ruby/3.3.3
9646
9646
  Content-Type:
9647
9647
  - application/json
9648
9648
  Accept-Encoding:
@@ -9687,7 +9687,7 @@ http_interactions:
9687
9687
  Authorization:
9688
9688
  - DeepL-Auth-Key VALID_TOKEN
9689
9689
  User-Agent:
9690
- - deepl-ruby/2.5.3 (darwin23) ruby/3.3.3
9690
+ - deepl-ruby/3.0.2 (darwin23) ruby/3.3.3
9691
9691
  Content-Type:
9692
9692
  - application/json
9693
9693
  Accept-Encoding:
@@ -9768,7 +9768,7 @@ http_interactions:
9768
9768
  Authorization:
9769
9769
  - DeepL-Auth-Key VALID_TOKEN
9770
9770
  User-Agent:
9771
- - deepl-ruby/2.5.3 (darwin23) ruby/3.3.3
9771
+ - deepl-ruby/3.0.2 (darwin23) ruby/3.3.3
9772
9772
  Content-Type:
9773
9773
  - application/json
9774
9774
  Accept-Encoding:
@@ -9811,7 +9811,7 @@ http_interactions:
9811
9811
  Authorization:
9812
9812
  - DeepL-Auth-Key VALID_TOKEN
9813
9813
  User-Agent:
9814
- - deepl-ruby/2.5.3 (darwin23) ruby/3.3.3
9814
+ - deepl-ruby/3.0.2 (darwin23) ruby/3.3.3
9815
9815
  Content-Type:
9816
9816
  - application/json
9817
9817
  Accept-Encoding:
@@ -9853,7 +9853,7 @@ http_interactions:
9853
9853
  Authorization:
9854
9854
  - DeepL-Auth-Key VALID_TOKEN
9855
9855
  User-Agent:
9856
- - deepl-ruby/2.5.3 (darwin23) ruby/3.3.3
9856
+ - deepl-ruby/3.0.2 (darwin23) ruby/3.3.3
9857
9857
  Content-Type:
9858
9858
  - application/json
9859
9859
  Accept-Encoding:
@@ -9900,7 +9900,7 @@ http_interactions:
9900
9900
  Authorization:
9901
9901
  - DeepL-Auth-Key VALID_TOKEN
9902
9902
  User-Agent:
9903
- - deepl-ruby/2.5.3 (darwin23) ruby/3.3.3
9903
+ - deepl-ruby/3.0.2 (darwin23) ruby/3.3.3
9904
9904
  Content-Type:
9905
9905
  - application/json
9906
9906
  Accept-Encoding:
@@ -9945,7 +9945,7 @@ http_interactions:
9945
9945
  Authorization:
9946
9946
  - DeepL-Auth-Key VALID_TOKEN
9947
9947
  User-Agent:
9948
- - deepl-ruby/2.5.3 (darwin23) ruby/3.3.3
9948
+ - deepl-ruby/3.0.2 (darwin23) ruby/3.3.3
9949
9949
  Content-Type:
9950
9950
  - application/json
9951
9951
  Accept-Encoding:
@@ -10071,7 +10071,7 @@ http_interactions:
10071
10071
  Authorization:
10072
10072
  - DeepL-Auth-Key VALID_TOKEN
10073
10073
  User-Agent:
10074
- - deepl-ruby/2.5.3 (darwin23) ruby/3.3.3
10074
+ - deepl-ruby/3.0.2 (darwin23) ruby/3.3.3
10075
10075
  Content-Type:
10076
10076
  - application/json
10077
10077
  Accept-Encoding:
@@ -10116,7 +10116,7 @@ http_interactions:
10116
10116
  Authorization:
10117
10117
  - DeepL-Auth-Key invalid
10118
10118
  User-Agent:
10119
- - deepl-ruby/2.5.3 (darwin23) ruby/3.3.3
10119
+ - deepl-ruby/3.0.2 (darwin23) ruby/3.3.3
10120
10120
  Content-Type:
10121
10121
  - application/json
10122
10122
  Accept-Encoding:
@@ -10146,4 +10146,227 @@ http_interactions:
10146
10146
  encoding: UTF-8
10147
10147
  string: ''
10148
10148
  recorded_at: Tue, 09 Jul 2024 10:04:32 GMT
10149
+ - request:
10150
+ method: post
10151
+ uri: https://api.deepl.com/v2/translate
10152
+ body:
10153
+ encoding: UTF-8
10154
+ string: '{"text":["That is hot!"],"source_lang":"EN","target_lang":"ES","context":""}'
10155
+ headers:
10156
+ Authorization:
10157
+ - DeepL-Auth-Key VALID_TOKEN
10158
+ User-Agent:
10159
+ - deepl-ruby/3.0.2 (darwin22) ruby/3.2.1
10160
+ Content-Type:
10161
+ - application/json
10162
+ Accept-Encoding:
10163
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
10164
+ Accept:
10165
+ - "*/*"
10166
+ response:
10167
+ status:
10168
+ code: 200
10169
+ message: OK
10170
+ headers:
10171
+ Date:
10172
+ - Wed, 25 Sep 2024 16:07:59 GMT
10173
+ Content-Type:
10174
+ - application/json
10175
+ Transfer-Encoding:
10176
+ - chunked
10177
+ Vary:
10178
+ - Accept-Encoding
10179
+ Access-Control-Allow-Origin:
10180
+ - "*"
10181
+ Strict-Transport-Security:
10182
+ - max-age=63072000; includeSubDomains; preload
10183
+ Server-Timing:
10184
+ - l7_lb_tls;dur=88, l7_lb_idle;dur=0, l7_lb_receive;dur=0, l7_lb_total;dur=126
10185
+ Access-Control-Expose-Headers:
10186
+ - Server-Timing, X-Trace-ID
10187
+ X-Trace-Id:
10188
+ - 53712edb2fc24c7f9d59e341bd80977a
10189
+ body:
10190
+ encoding: ASCII-8BIT
10191
+ string: !binary |-
10192
+ eyJ0cmFuc2xhdGlvbnMiOlt7ImRldGVjdGVkX3NvdXJjZV9sYW5ndWFnZSI6IkVOIiwidGV4dCI6IsKhRXNvIGVzdMOhIGNhbGllbnRlISJ9XX0=
10193
+ recorded_at: Wed, 25 Sep 2024 16:07:59 GMT
10194
+ - request:
10195
+ method: post
10196
+ uri: https://api.deepl.com/v2/translate
10197
+ body:
10198
+ encoding: UTF-8
10199
+ string: '{"text":["That is hot!"],"source_lang":"EN","target_lang":"ES","context":"He
10200
+ did not like the jalapenos in his meal."}'
10201
+ headers:
10202
+ Authorization:
10203
+ - DeepL-Auth-Key VALID_TOKEN
10204
+ User-Agent:
10205
+ - deepl-ruby/3.0.2 (darwin22) ruby/3.2.1
10206
+ Content-Type:
10207
+ - application/json
10208
+ Accept-Encoding:
10209
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
10210
+ Accept:
10211
+ - "*/*"
10212
+ response:
10213
+ status:
10214
+ code: 200
10215
+ message: OK
10216
+ headers:
10217
+ Date:
10218
+ - Wed, 25 Sep 2024 16:08:00 GMT
10219
+ Content-Type:
10220
+ - application/json
10221
+ Transfer-Encoding:
10222
+ - chunked
10223
+ Vary:
10224
+ - Accept-Encoding
10225
+ Access-Control-Allow-Origin:
10226
+ - "*"
10227
+ Strict-Transport-Security:
10228
+ - max-age=63072000; includeSubDomains; preload
10229
+ Server-Timing:
10230
+ - l7_lb_tls;dur=67, l7_lb_idle;dur=0, l7_lb_receive;dur=0, l7_lb_total;dur=124
10231
+ Access-Control-Expose-Headers:
10232
+ - Server-Timing, X-Trace-ID
10233
+ X-Trace-Id:
10234
+ - 1704af9968bf4570b155c12cc0ae0665
10235
+ body:
10236
+ encoding: ASCII-8BIT
10237
+ string: !binary |-
10238
+ eyJ0cmFuc2xhdGlvbnMiOlt7ImRldGVjdGVkX3NvdXJjZV9sYW5ndWFnZSI6IkVOIiwidGV4dCI6IsKhRXNvIGVzIHBpY2FudGUhIn1dfQ==
10239
+ recorded_at: Wed, 25 Sep 2024 16:08:00 GMT
10240
+ - request:
10241
+ method: post
10242
+ uri: https://api.deepl.com/v2/translate
10243
+ body:
10244
+ encoding: UTF-8
10245
+ string: '{"text":["Sample text"],"source_lang":"EN","target_lang":"DE","model_type":"quality_optimized"}'
10246
+ headers:
10247
+ Authorization:
10248
+ - DeepL-Auth-Key VALID_TOKEN
10249
+ User-Agent:
10250
+ - deepl-ruby/3.0.2 (darwin22) ruby/3.2.1
10251
+ Content-Type:
10252
+ - application/json
10253
+ Accept-Encoding:
10254
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
10255
+ Accept:
10256
+ - "*/*"
10257
+ response:
10258
+ status:
10259
+ code: 200
10260
+ message: OK
10261
+ headers:
10262
+ Date:
10263
+ - Fri, 08 Nov 2024 15:57:39 GMT
10264
+ Content-Type:
10265
+ - application/json
10266
+ Transfer-Encoding:
10267
+ - chunked
10268
+ Vary:
10269
+ - Accept-Encoding
10270
+ Access-Control-Allow-Origin:
10271
+ - "*"
10272
+ Strict-Transport-Security:
10273
+ - max-age=63072000; includeSubDomains; preload
10274
+ Server-Timing:
10275
+ - l7_lb_tls;dur=89, l7_lb_idle;dur=0, l7_lb_receive;dur=0, l7_lb_total;dur=165
10276
+ Access-Control-Expose-Headers:
10277
+ - Server-Timing, X-Trace-ID
10278
+ X-Trace-Id:
10279
+ - 7d71b768eebc41da8c5b820c33e7cdc1
10280
+ body:
10281
+ encoding: ASCII-8BIT
10282
+ string: '{"translations":[{"detected_source_language":"EN","text":"Mustertext","model_type_used":"quality_optimized"}]}'
10283
+ recorded_at: Fri, 08 Nov 2024 15:57:39 GMT
10284
+ - request:
10285
+ method: post
10286
+ uri: https://api.deepl.com/v2/translate
10287
+ body:
10288
+ encoding: UTF-8
10289
+ string: '{"text":["Sample text"],"source_lang":"EN","target_lang":"DE","model_type":"prefer_quality_optimized"}'
10290
+ headers:
10291
+ Authorization:
10292
+ - DeepL-Auth-Key VALID_TOKEN
10293
+ User-Agent:
10294
+ - deepl-ruby/3.0.2 (darwin22) ruby/3.2.1
10295
+ Content-Type:
10296
+ - application/json
10297
+ Accept-Encoding:
10298
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
10299
+ Accept:
10300
+ - "*/*"
10301
+ response:
10302
+ status:
10303
+ code: 200
10304
+ message: OK
10305
+ headers:
10306
+ Date:
10307
+ - Mon, 11 Nov 2024 10:58:59 GMT
10308
+ Content-Type:
10309
+ - application/json
10310
+ Transfer-Encoding:
10311
+ - chunked
10312
+ Vary:
10313
+ - Accept-Encoding
10314
+ Access-Control-Allow-Origin:
10315
+ - "*"
10316
+ Strict-Transport-Security:
10317
+ - max-age=63072000; includeSubDomains; preload
10318
+ Server-Timing:
10319
+ - l7_lb_tls;dur=98, l7_lb_idle;dur=1, l7_lb_receive;dur=0, l7_lb_total;dur=320
10320
+ Access-Control-Expose-Headers:
10321
+ - Server-Timing, X-Trace-ID
10322
+ X-Trace-Id:
10323
+ - 0fa07be47b3b458ebf50268ca2efe7fe
10324
+ body:
10325
+ encoding: ASCII-8BIT
10326
+ string: '{"translations":[{"detected_source_language":"EN","text":"Mustertext","model_type_used":"quality_optimized"}]}'
10327
+ recorded_at: Mon, 11 Nov 2024 10:58:59 GMT
10328
+ - request:
10329
+ method: post
10330
+ uri: https://api.deepl.com/v2/translate
10331
+ body:
10332
+ encoding: UTF-8
10333
+ string: '{"text":["Sample text"],"source_lang":"EN","target_lang":"DE","model_type":"latency_optimized"}'
10334
+ headers:
10335
+ Authorization:
10336
+ - DeepL-Auth-Key VALID_TOKEN
10337
+ User-Agent:
10338
+ - deepl-ruby/3.0.2 (darwin22) ruby/3.2.1
10339
+ Content-Type:
10340
+ - application/json
10341
+ Accept-Encoding:
10342
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
10343
+ Accept:
10344
+ - "*/*"
10345
+ response:
10346
+ status:
10347
+ code: 200
10348
+ message: OK
10349
+ headers:
10350
+ Date:
10351
+ - Fri, 15 Nov 2024 11:35:22 GMT
10352
+ Content-Type:
10353
+ - application/json
10354
+ Transfer-Encoding:
10355
+ - chunked
10356
+ Vary:
10357
+ - Accept-Encoding
10358
+ Access-Control-Allow-Origin:
10359
+ - "*"
10360
+ Strict-Transport-Security:
10361
+ - max-age=63072000; includeSubDomains; preload
10362
+ Server-Timing:
10363
+ - l7_lb_tls;dur=136, l7_lb_idle;dur=2, l7_lb_receive;dur=0, l7_lb_total;dur=156
10364
+ Access-Control-Expose-Headers:
10365
+ - Server-Timing, X-Trace-ID
10366
+ X-Trace-Id:
10367
+ - de2645cb65c3418db54e3bdefd35fe52
10368
+ body:
10369
+ encoding: ASCII-8BIT
10370
+ string: '{"translations":[{"detected_source_language":"EN","text":"Beispieltext","model_type_used":"latency_optimized"}]}'
10371
+ recorded_at: Fri, 15 Nov 2024 11:35:22 GMT
10149
10372
  recorded_with: VCR 6.2.0
@@ -14,7 +14,7 @@ http_interactions:
14
14
  Accept:
15
15
  - "*/*"
16
16
  User-Agent:
17
- - deepl-ruby/2.5.3 (darwin23) ruby/3.3.3
17
+ - deepl-ruby/3.0.2 (darwin23) ruby/3.3.3
18
18
  response:
19
19
  status:
20
20
  code: 200
@@ -46,7 +46,7 @@ http_interactions:
46
46
  Authorization:
47
47
  - DeepL-Auth-Key VALID_TOKEN
48
48
  User-Agent:
49
- - deepl-ruby/2.5.3(darwin23) ruby/3.3.3
49
+ - deepl-ruby/3.0.2 (darwin23) ruby/3.3.3
50
50
  Accept-Encoding:
51
51
  - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
52
52
  Accept:
@@ -88,7 +88,7 @@ http_interactions:
88
88
  Authorization:
89
89
  - DeepL-Auth-Key VALID_TOKEN
90
90
  User-Agent:
91
- - deepl-ruby/2.5.3 (darwin23) ruby/3.3.3
91
+ - deepl-ruby/3.0.2 (darwin23) ruby/3.3.3
92
92
  Accept-Encoding:
93
93
  - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
94
94
  Accept:
@@ -132,7 +132,7 @@ http_interactions:
132
132
  Authorization:
133
133
  - DeepL-Auth-Key VALID_TOKEN
134
134
  User-Agent:
135
- - deepl-ruby/2.5.3 (darwin23) ruby/3.3.3
135
+ - deepl-ruby/3.0.2 (darwin23) ruby/3.3.3
136
136
  Content-Type:
137
137
  - application/json
138
138
  Accept-Encoding:
@@ -190,6 +190,18 @@ describe DeepL::Requests::Translate do
190
190
  expect(request.options[:formality]).to eq('more')
191
191
  end
192
192
  end
193
+
194
+ context 'when using `model_type` options' do
195
+ it 'works with a nil value' do
196
+ request = described_class.new(api, nil, nil, nil, model_type: nil)
197
+ expect(request.options[:model_type]).to be_nil
198
+ end
199
+
200
+ it 'works with a string' do
201
+ request = described_class.new(api, nil, nil, nil, model_type: 'latency_optimized')
202
+ expect(request.options[:model_type]).to eq('latency_optimized')
203
+ end
204
+ end
193
205
  end
194
206
 
195
207
  describe '#request' do
@@ -292,6 +304,45 @@ describe DeepL::Requests::Translate do
292
304
  end
293
305
  end
294
306
 
307
+ context 'when performing a valid request with context' do
308
+ let(:text) { 'That is hot!' }
309
+
310
+ context 'when context is empty' do
311
+ let(:options) { { context: '' } }
312
+
313
+ it 'translates correctly with empty context' do
314
+ res = translate.request
315
+ expect(res).to be_a(DeepL::Resources::Text)
316
+ expect(res.text).to eq('¡Eso está caliente!')
317
+ end
318
+ end
319
+
320
+ context 'when context is set' do
321
+ let(:options) { { context: 'He did not like the jalapenos in his meal.' } }
322
+
323
+ it 'translates correctly with context taken into account' do
324
+ res = translate.request
325
+ expect(res).to be_a(DeepL::Resources::Text)
326
+ expect(res.text).to eq('¡Eso es picante!')
327
+ end
328
+ end
329
+ end
330
+
331
+ context 'when performing a request with a model type' do
332
+ let(:target_lang) { 'DE' }
333
+
334
+ %w[quality_optimized latency_optimized prefer_quality_optimized].each do |model_type_str|
335
+ it "translates correctly with #{model_type_str} models" do
336
+ options = { model_type: model_type_str }
337
+ translate = described_class.new(api, text, source_lang, target_lang, options)
338
+ res = translate.request
339
+ expect(res).to be_a(DeepL::Resources::Text)
340
+ expected_model_type = model_type_str.sub(/^prefer_/, '')
341
+ expect(res.model_type_used).to eq(expected_model_type)
342
+ end
343
+ end
344
+ end
345
+
295
346
  context 'when performing a bad request' do
296
347
  context 'when using an invalid token' do
297
348
  let(:api) do
@@ -6,7 +6,7 @@
6
6
  require 'spec_helper'
7
7
 
8
8
  describe DeepL::Resources::Text do
9
- subject(:text) { described_class.new('Target', 'es', nil, nil) }
9
+ subject(:text) { described_class.new('Target', 'es', nil, nil, nil) }
10
10
 
11
11
  describe '#initialize' do
12
12
  context 'when building a basic object' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: deepl-rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.1
4
+ version: 3.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - DeepL SE
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-09-23 00:00:00.000000000 Z
11
+ date: 2024-11-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: juwelier
@@ -137,7 +137,11 @@ files:
137
137
  homepage: https://github.com/DeepLcom/deepl-rb
138
138
  licenses:
139
139
  - MIT
140
- metadata: {}
140
+ metadata:
141
+ bug_tracker_uri: https://github.com/DeepLcom/deepl-rb/issues
142
+ changelog_uri: https://github.com/DeepLcom/deepl-rb/blob/main/CHANGELOG.md
143
+ documentation_uri: https://github.com/DeepLcom/deepl-rb/blob/main/README.md
144
+ homepage_uri: https://github.com/DeepLcom/deepl-rb
141
145
  post_install_message:
142
146
  rdoc_options: []
143
147
  require_paths: