Skip to content

Commit

Permalink
full spec coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
yosefserkez committed Oct 5, 2023
1 parent b34eb33 commit 969b4bd
Showing 1 changed file with 35 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,16 @@
end

context '#determine_eligibilities' do
let(:event_key) { 'magi_medicaid.mitc.eligibilities.determined_mixed_determination' }
let(:eligibilities) do
MagiMedicaid::GenerateAndPublishEligibilityDocuments.new
.determine_eligibilities(application_entity, event_key)
end
shared_examples 'eligibility determination' do |event_key, expected_result|
let(:eligibilities) do
MagiMedicaid::GenerateAndPublishEligibilityDocuments.new
.determine_eligibilities(application_entity, event_key)
end

it 'should return eligibilities' do
expect(eligibilities.success).to eq ['magi_medicaid.mitc.eligibilities.determined_aptc_eligible']
expected_result = expected_result.present? ? [expected_result] : []
it "should return #{expected_result}" do
expect(eligibilities.success).to eq expected_result
end
end

context 'when there is no eligibility' do
Expand All @@ -119,42 +121,36 @@
application_hash
end

let(:entity) { ::AcaEntities::MagiMedicaid::Application.new(modified_application_hash) }
let(:eligibilities) do
MagiMedicaid::GenerateAndPublishEligibilityDocuments.new
.determine_eligibilities(application_entity, event_key)
end
let(:application_entity) { ::AcaEntities::MagiMedicaid::Application.new(modified_application_hash) }
it_behaves_like 'eligibility determination',
'magi_medicaid.mitc.eligibilities.determined_mixed_determination',
nil
end

it 'should return nil' do
expect(eligibilities.success).to eq []
end
context 'when event key is determined_mixed_determination' do
it_behaves_like 'eligibility determination',
'magi_medicaid.mitc.eligibilities.determined_mixed_determination',
'magi_medicaid.mitc.eligibilities.determined_aptc_eligible'
end

context 'when event key is medicaid_chip_eligible' do
event_keys = ['magi_medicaid.applications.aptc_csr_credits.renewals.determined_medicaid_chip_eligible', 'enroll.applications.aptc_csr_credits.renewals.notice.determined_medicaid_chip_eligible']
event_keys.each do |event_key|
let(:event_key) { event_key }
let(:eligibilities) do
MagiMedicaid::GenerateAndPublishEligibilityDocuments.new
.determine_eligibilities(application_entity, event_key)
end
it 'should return magi_medicaid_eligible' do
prefix = event_key.split('.')[0..-2].join('.') # drop the last element
expect(eligibilities.success).to eq ["#{prefix}.determined_magi_medicaid_eligible"]
end
end

context 'when event key is determined_medicaid_chip_eligible' do
it_behaves_like 'eligibility determination',
'magi_medicaid.applications.aptc_csr_credits.renewals.determined_medicaid_chip_eligible',
'magi_medicaid.applications.aptc_csr_credits.renewals.determined_magi_medicaid_eligible'
it_behaves_like 'eligibility determination',
'enroll.applications.aptc_csr_credits.renewals.notice.determined_medicaid_chip_eligible',
'enroll.applications.aptc_csr_credits.renewals.notice.determined_magi_medicaid_eligible'
end

context 'when event key is determined_aptc_eligible' do
let(:event_key) { 'magi_medicaid.applications.aptc_csr_credits.renewals.determined_aptc_eligible' }
let(:eligibilities) do
MagiMedicaid::GenerateAndPublishEligibilityDocuments.new
.determine_eligibilities(application_entity, event_key)
end
it 'should return determined_aptc_eligible as is' do
expect(eligibilities.success).to eq [event_key]
end
it_behaves_like 'eligibility determination',
'magi_medicaid.applications.aptc_csr_credits.renewals.determined_aptc_eligible',
'magi_medicaid.applications.aptc_csr_credits.renewals.determined_aptc_eligible'
it_behaves_like 'eligibility determination',
'enroll.applications.aptc_csr_credits.renewals.notice.determined_aptc_eligible',
'enroll.applications.aptc_csr_credits.renewals.notice.determined_aptc_eligible'
end

end

context '#publish_documents' do
Expand Down Expand Up @@ -192,4 +188,4 @@
end
end
end
end
end

0 comments on commit 969b4bd

Please sign in to comment.