spec/requests/usage_spec.rb in deepl-rb-2.5.3 vs spec/requests/usage_spec.rb in deepl-rb-3.0.0
- old
+ new
@@ -1,29 +1,39 @@
+# Copyright 2018 Daniel Herzog
+# Use of this source code is governed by an MIT
+# license that can be found in the LICENSE.md file.
# frozen_string_literal: true
require 'spec_helper'
describe DeepL::Requests::Usage do
+ subject(:usage_req) { described_class.new(api, options) }
+
+ around do |tests|
+ tmp_env = replace_env_preserving_deepl_vars_except_mock_server
+ tests.call
+ ENV.replace(tmp_env)
+ end
+
let(:api) { build_deepl_api }
let(:options) { {} }
- subject { DeepL::Requests::Usage.new(api, options) }
describe '#initialize' do
- context 'When building a request' do
- it 'should create a request object' do
- expect(subject).to be_a(DeepL::Requests::Usage)
+ context 'when building a request' do
+ it 'creates a request object' do
+ expect(usage_req).to be_a(described_class)
end
end
end
describe '#request' do
around do |example|
VCR.use_cassette('usage') { example.call }
end
- context 'When performing a valid request' do
- it 'should return an usage object' do
- usage = subject.request
+ context 'when performing a valid request' do
+ it 'returns an usage object' do
+ usage = usage_req.request
expect(usage).to be_a(DeepL::Resources::Usage)
expect(usage.character_count).to be_a(Numeric)
expect(usage.character_limit).to be_a(Numeric)
end