Skip to content

Commit 26e7204

Browse files
committed
Refactor specs after code review
1 parent 51fd369 commit 26e7204

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

spec/unit/outputs/elasticsearch_spec.rb

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1499,9 +1499,9 @@
14991499
end
15001500
end
15011501

1502-
context 'drop_error_types config option' do
1502+
describe 'drop_error_types' do
15031503

1504-
let(:error_type) { 'role_restriction_exception' }
1504+
let(:error_type) { 'index_closed_exception' }
15051505

15061506
let(:options) { super().merge('drop_error_types' => [error_type]) }
15071507

@@ -1511,6 +1511,8 @@
15111511

15121512
let(:error_code) { 403 }
15131513

1514+
let(:event_action_tuples) { subject.map_events(events) }
1515+
15141516
let(:bulk_response) do
15151517
{
15161518
"took"=>1, "ingest_took"=>11, "errors"=>true, "items"=>
@@ -1528,22 +1530,24 @@
15281530

15291531
context 'DLQ is enabled' do
15301532

1531-
it 'does not write the event to the DLQ' do
1533+
before(:each) do
15321534
allow(subject).to receive(:dlq_enabled?).and_return(true)
1533-
expect(dlq_writer).not_to receive(:write)
1535+
end
15341536

1535-
event_action_tuples = subject.map_events(events)
1537+
it 'does not write the event to the DLQ' do
1538+
expect(dlq_writer).not_to receive(:write)
15361539
subject.send(:submit, event_action_tuples)
15371540
end
15381541
end
15391542

15401543
context 'DLQ is not enabled' do
15411544

1542-
it 'does not write the event to the DLQ' do
1545+
before(:each) do
15431546
allow(subject).to receive(:dlq_enabled?).and_return(false)
1544-
expect(dlq_writer).not_to receive(:write)
1547+
end
15451548

1546-
event_action_tuples = subject.map_events(events)
1549+
it 'does not write the event to the DLQ' do
1550+
expect(dlq_writer).not_to receive(:write)
15471551
subject.send(:submit, event_action_tuples)
15481552
end
15491553
end

0 commit comments

Comments
 (0)