|
1 | 1 | # frozen_string_literal: true |
2 | 2 |
|
3 | 3 | RSpec.describe Truemail::RSpec::ValidatorHelper, type: :helper do |
| 4 | + describe 'defined constants' do |
| 5 | + it { expect(described_class).to be_const_defined(:VALIDATION_LIST_TYPE_REGEX_PATTERN) } |
| 6 | + end |
| 7 | + |
4 | 8 | describe '#create_servers_list' do |
5 | 9 | context 'without size' do |
6 | 10 | subject(:servers_list) { create_servers_list } |
|
36 | 40 | let(:validator_instance_result) { validator_instance.result } |
37 | 41 | let(:validator_instance_result_configuration) { validator_instance_result.configuration } |
38 | 42 | let(:success_status) { true } |
| 43 | + let(:expected_vlidation_type) { validation_type } |
39 | 44 |
|
40 | 45 | shared_examples 'successful validator instance' do |
41 | 46 | it 'creates successful validator instance' do |
|
44 | 49 | expect(validator_instance_result.errors).to be_empty |
45 | 50 | expect(validator_instance_result.smtp_debug).to be_nil |
46 | 51 | expect(validator_instance_result_configuration).to be_an_instance_of(Truemail::Configuration) |
47 | | - expect(validator_instance.validation_type).to eq(validation_type) |
| 52 | + expect(validator_instance.validation_type).to eq(expected_vlidation_type) |
48 | 53 | end |
49 | 54 | end |
50 | 55 |
|
51 | | - context 'with whitelist validation type' do |
52 | | - let(:validation_type) { :whitelist } |
| 56 | + context 'with list match validation type' do |
| 57 | + let(:expected_vlidation_type) { :whitelist } |
53 | 58 |
|
54 | | - include_examples 'successful validator instance' |
| 59 | + context 'with emails list validation type' do |
| 60 | + let(:validation_type) { :emails_list } |
55 | 61 |
|
56 | | - it 'has necessary validator instance result attributes' do |
57 | | - expect(validator_instance_result.domain).not_to be_nil |
58 | | - expect(validator_instance_result.mail_servers).to be_empty |
59 | | - expect(validator_instance_result_configuration.whitelisted_domains).not_to be_empty |
| 62 | + include_examples 'successful validator instance' |
| 63 | + |
| 64 | + it 'has necessary validator instance result attributes' do |
| 65 | + expect(validator_instance_result.domain).to be_nil |
| 66 | + expect(validator_instance_result.mail_servers).to be_empty |
| 67 | + expect(validator_instance_result_configuration.whitelisted_emails).not_to be_empty |
| 68 | + end |
| 69 | + end |
| 70 | + |
| 71 | + context 'with domains list validation type' do |
| 72 | + let(:validation_type) { :domains_list } |
| 73 | + |
| 74 | + include_examples 'successful validator instance' |
| 75 | + |
| 76 | + it 'has necessary validator instance result attributes' do |
| 77 | + expect(validator_instance_result.domain).not_to be_nil |
| 78 | + expect(validator_instance_result.mail_servers).to be_empty |
| 79 | + expect(validator_instance_result_configuration.whitelisted_domains).not_to be_empty |
| 80 | + end |
60 | 81 | end |
61 | 82 | end |
62 | 83 |
|
|
131 | 152 | end |
132 | 153 | end |
133 | 154 |
|
134 | | - context 'with whitelist validation type' do |
135 | | - let(:validation_type) { :whitelist } |
| 155 | + context 'with list match validation type' do |
| 156 | + let(:expected_vlidation_type) { :whitelist } |
136 | 157 |
|
137 | | - include_examples 'fail validator instance' |
| 158 | + shared_examples 'has necessary validator instance result attributes' do |
| 159 | + it 'has necessary validator instance result attributes' do |
| 160 | + expect(validator_instance_result.domain).not_to be_nil |
| 161 | + expect(validator_instance_result.errors).to include(:list_match) |
| 162 | + expect(validator_instance_result.mail_servers).to be_empty |
| 163 | + expect(validator_instance_result.smtp_debug).to be_nil |
| 164 | + expect(target_blacklist).not_to be_empty |
| 165 | + expect(validator_instance.validation_type).to eq(:blacklist) |
| 166 | + end |
| 167 | + end |
138 | 168 |
|
139 | | - it 'has necessary validator instance result attributes' do |
140 | | - expect(validator_instance_result.domain).not_to be_nil |
141 | | - expect(validator_instance_result.errors).to include(:domain_list_match) |
142 | | - expect(validator_instance_result.mail_servers).to be_empty |
143 | | - expect(validator_instance_result.smtp_debug).to be_nil |
144 | | - expect(validator_instance_result_configuration.blacklisted_domains).not_to be_empty |
145 | | - expect(validator_instance.validation_type).to eq(:blacklist) |
| 169 | + context 'with emails list validation type' do |
| 170 | + let(:validation_type) { :emails_list } |
| 171 | + let(:target_blacklist) { validator_instance_result_configuration.blacklisted_emails } |
| 172 | + |
| 173 | + include_examples 'fail validator instance' |
| 174 | + include_examples 'has necessary validator instance result attributes' |
| 175 | + end |
| 176 | + |
| 177 | + context 'with domains list validation type' do |
| 178 | + let(:validation_type) { :domains_list } |
| 179 | + let(:target_blacklist) { validator_instance_result_configuration.blacklisted_domains } |
| 180 | + |
| 181 | + include_examples 'fail validator instance' |
| 182 | + include_examples 'has necessary validator instance result attributes' |
146 | 183 | end |
147 | 184 | end |
148 | 185 |
|
|
0 commit comments