Skip to content

Commit

Permalink
Add empty case in operation_spec.rb
Browse files Browse the repository at this point in the history
  • Loading branch information
lauragilgz committed Dec 20, 2024
1 parent 7ffc787 commit 2c3762a
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions spec/cfonb/operation_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -276,23 +276,34 @@
context 'with an unknown detail' do
let(:detail) do
OpenStruct.new(
body: '0530004411001871EUR2 0001016255614090823 AAAEUR200000000000740',
detail_code: 'AAA',
body: '0530004411001871EUR2 0001016255614090823 A AEUR200000000000740',
detail_code: 'A A',
detail: 'EUR200000000000740',
)
end

it 'adds the detail to the unknown details hash' do
operation.merge_detail(detail)

expect(operation.details.unknown).to eq({ 'AAA' => 'EUR200000000000740' })
expect(operation.details.unknown).to eq({ 'A_A' => 'EUR200000000000740' })
end

it 'updates the current details in case of duplicated codes' do
operation.merge_detail(detail)
operation.merge_detail(detail)

expect(operation.details.unknown).to eq({ 'AAA' => "EUR200000000000740\nEUR200000000000740" })
expect(operation.details.unknown).to eq({ 'A_A' => "EUR200000000000740\nEUR200000000000740" })
end

it 'does not add any detail if they are empty' do
detail = OpenStruct.new(
body: '0530004411001871EUR2 0001016255614090823',
detail_code: '',
detail: 'EUR200000000000740',
)
operation.merge_detail(detail)

expect(operation.details.unknown).to be_nil
end
end
end
Expand Down

0 comments on commit 2c3762a

Please sign in to comment.