|
1 | 1 | # frozen_string_literal: true
|
2 | 2 |
|
3 | 3 | RSpec.describe Mailtrap::Client do
|
4 |
| - subject(:client) { described_class.new(api_key: api_key) } |
| 4 | + subject(:client) { described_class.new(api_key:) } |
5 | 5 |
|
6 | 6 | let(:api_key) { 'correct-api-key' }
|
7 | 7 |
|
|
65 | 65 |
|
66 | 66 | context 'with an alternative host' do
|
67 | 67 | let(:client) do
|
68 |
| - described_class.new(api_key: api_key, api_host: 'alternative.host.mailtrap.io', api_port: 8080) |
| 68 | + described_class.new(api_key:, api_host: 'alternative.host.mailtrap.io', api_port: 8080) |
69 | 69 | end
|
70 | 70 |
|
71 | 71 | it 'sending is successful' do
|
|
75 | 75 |
|
76 | 76 | context 'with bulk flag' do
|
77 | 77 | let(:client) do
|
78 |
| - described_class.new(api_key: api_key, bulk: true) |
| 78 | + described_class.new(api_key:, bulk: true) |
79 | 79 | end
|
80 | 80 |
|
81 | 81 | it 'chooses host for bulk sending' do
|
|
85 | 85 |
|
86 | 86 | context 'with bulk flag and alternative host' do
|
87 | 87 | let(:client) do
|
88 |
| - described_class.new(api_key: api_key, bulk: true, api_host: 'alternative.host.mailtrap.io', api_port: 8080) |
| 88 | + described_class.new(api_key:, bulk: true, api_host: 'alternative.host.mailtrap.io', api_port: 8080) |
89 | 89 | end
|
90 | 90 |
|
91 | 91 | it 'chooses alternative host' do
|
|
95 | 95 |
|
96 | 96 | context 'with sandbox flag' do
|
97 | 97 | let(:client) do
|
98 |
| - described_class.new(api_key: api_key, sandbox: true, inbox_id: 12) |
| 98 | + described_class.new(api_key:, sandbox: true, inbox_id: 12) |
99 | 99 | end
|
100 | 100 |
|
101 | 101 | it 'chooses host for sandbox sending' do
|
|
105 | 105 |
|
106 | 106 | context 'with sandbox flag without inbox id' do
|
107 | 107 | let(:client) do
|
108 |
| - described_class.new(api_key: api_key, sandbox: true) |
| 108 | + described_class.new(api_key:, sandbox: true) |
109 | 109 | end
|
110 | 110 |
|
111 | 111 | it { expect { send }.to raise_error(ArgumentError, 'inbox_id is required for sandbox API') }
|
112 | 112 | end
|
113 | 113 |
|
114 | 114 | context 'with bulk and sandbox flag' do
|
115 | 115 | let(:client) do
|
116 |
| - described_class.new(api_key: api_key, bulk: true, sandbox: true) |
| 116 | + described_class.new(api_key:, bulk: true, sandbox: true) |
117 | 117 | end
|
118 | 118 |
|
119 | 119 | it { expect { send }.to raise_error(ArgumentError, 'bulk mode is not applicable for sandbox API') }
|
|
155 | 155 |
|
156 | 156 | context 'when using sandbox' do
|
157 | 157 | let(:client) do
|
158 |
| - described_class.new(api_key: api_key, sandbox: true, inbox_id: 13) |
| 158 | + described_class.new(api_key:, sandbox: true, inbox_id: 13) |
159 | 159 | end
|
160 | 160 |
|
161 | 161 | it 'sending is successful' do
|
|
178 | 178 | end
|
179 | 179 |
|
180 | 180 | def stub_api_send(status, body = nil)
|
181 |
| - stub = stub_request(:post, %r{/api/send}).to_return(status: status, body: body) |
| 181 | + stub = stub_request(:post, %r{/api/send}).to_return(status:, body:) |
182 | 182 | yield
|
183 | 183 | expect(stub).to have_been_requested
|
184 | 184 | end
|
|
0 commit comments