Skip to content

Commit

Permalink
add specs, update version and changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
mitosch committed May 7, 2024
1 parent 3332c44 commit f6eb2eb
Show file tree
Hide file tree
Showing 8 changed files with 104 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

* no changes

### 0.5.3 - 2024-05-07

* Fix bug where currency could not be set to EUR. Thanks to @franco.

### 0.5.2 - 2022-08-25

* Add additional information (unstructured_message, bill_information). Thanks to @noefroidevaux.
Expand Down
2 changes: 2 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ PATH
specs:
prawn-swiss_qr_bill (0.5.2)
i18n (~> 1.8)
matrix (~> 0.4)
prawn (~> 2.0)
rqrcode (~> 2.0)

Expand All @@ -19,6 +20,7 @@ GEM
hashery (2.1.2)
i18n (1.12.0)
concurrent-ruby (~> 1.0)
matrix (0.4.2)
parallel (1.21.0)
parser (3.1.0.0)
ast (~> 2.4.1)
Expand Down
2 changes: 1 addition & 1 deletion lib/prawn/swiss_qr_bill/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

module Prawn
module SwissQRBill
VERSION = '0.5.2'
VERSION = '0.5.3'
end
end
2 changes: 2 additions & 0 deletions prawn-swiss_qr_bill.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Gem::Specification.new do |spec|

spec.add_dependency 'i18n', '~> 1.8'
spec.add_dependency 'prawn', '~> 2.0'
spec.add_dependency 'matrix', '~> 0.4'
spec.add_dependency 'rqrcode', '~> 2.0'

spec.add_development_dependency 'pdf-reader', '~> 2.3'
Expand All @@ -34,6 +35,7 @@ Gem::Specification.new do |spec|
spec.add_development_dependency 'simplecov', '~> 0.16'
spec.add_development_dependency 'simplecov-cobertura', '~> 2.0'


spec.metadata = {
'rubygems_mfa_required' => 'true'
}
Expand Down
20 changes: 18 additions & 2 deletions spec/features/pdf_generation_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,24 @@
end
end

context 'when currency EUR' do
let(:bill_data) { DataManager.build_bill(:default).merge(currency: 'EUR') }
context 'when currency is CHF' do
let(:bill_data) { DataManager.build_bill }

it 'generates a correct pdf' do
expect(reader_for_bill.pages[0].text).to include('CHF').twice
end
end

context 'when no currency' do
let(:bill_data) { DataManager.build_bill(:no_currency) }

it 'generates a correct pdf' do
expect(reader_for_bill.pages[0].text).to include('CHF').twice
end
end

context 'when currency is EUR' do
let(:bill_data) { DataManager.build_bill(:currency_eur) }

it 'generates a correct pdf' do
expect(reader_for_bill.pages[0].text).to include('EUR').twice
Expand Down
29 changes: 29 additions & 0 deletions spec/prawn/swiss_qr_bill/qr/data_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

describe Prawn::SwissQRBill::QR::Data do
let(:bill_data) { DataManager.build_bill(:default, flat: true) }
let(:bill_data_no_currency) { DataManager.build_bill(:no_currency, flat: true) }
let(:bill_data_currency_eur) { DataManager.build_bill(:currency_eur, flat: true) }

describe '.new' do
it 'initializes the qr data with defaults' do
Expand Down Expand Up @@ -119,5 +121,32 @@
expect(qr_data.reference).to eq('000000000000022022020299991')
end
end

context 'with currency CHF' do
it 'generates data with CHF' do
qr_data = described_class.new(bill_data)
qr_data_string = qr_data.generate
qr_data_array = qr_data_string.split("\r\n")
expect(qr_data_array[19]).to eq('CHF')
end
end

context 'without currency' do
it 'generates data with CHF' do
qr_data = described_class.new(bill_data_no_currency)
qr_data_string = qr_data.generate
qr_data_array = qr_data_string.split("\r\n")
expect(qr_data_array[19]).to eq('CHF')
end
end

context 'with currency EUR' do
it 'generates data with EUR' do
qr_data = described_class.new(bill_data_currency_eur)
qr_data_string = qr_data.generate
qr_data_array = qr_data_string.split("\r\n")
expect(qr_data_array[19]).to eq('EUR')
end
end
end
end
7 changes: 7 additions & 0 deletions spec/prawn/swiss_qr_bill/sections/payment_amount_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
let(:document) { Prawn::Document.new }
let(:bill_data) { DataManager.build_bill }
let(:bill_data_no_amount) { DataManager.build_bill(:no_amount) }
let(:bill_data_no_currency) { DataManager.build_bill(:no_currency) }

describe '.new' do
it 'initializes the section' do
Expand All @@ -24,5 +25,11 @@
described_class.new(document, bill_data_no_amount).draw
end
end

context 'when currency is not given' do
it 'draws currency as CHF and a corner box for amount' do
described_class.new(document, bill_data_no_currency).draw
end
end
end
end
41 changes: 41 additions & 0 deletions spec/support/bill_data.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,47 @@ bill_data:
reference_type: QRR
unstructured_message: Auftrag vom 15.06.2020
bill_information: //S1/10/10201409/11/170309/20/14000000/30/106017086
no_currency:
creditor:
iban: CH08 3080 8004 1110 4136 9
address:
name: Mischa Schindowski
line1: Schybenächerweg 553
postal_code: 5324
city: Full-Reuenthal
country: CH
debtor:
address:
name: Simon Muster
line1: Musterstrasse 1
postal_code: 8000
city: Zürich
country: CH
reference: 00 00000 00000 02202 20202 99991
reference_type: QRR
unstructured_message: Auftrag vom 15.06.2020
bill_information: //S1/10/10201409/11/170309/20/14000000/30/106017086
currency_eur:
creditor:
iban: CH08 3080 8004 1110 4136 9
address:
name: Mischa Schindowski
line1: Schybenächerweg 553
postal_code: 5324
city: Full-Reuenthal
country: CH
debtor:
address:
name: Simon Muster
line1: Musterstrasse 1
postal_code: 8000
city: Zürich
country: CH
currency: EUR
reference: 00 00000 00000 02202 20202 99991
reference_type: QRR
unstructured_message: Auftrag vom 15.06.2020
bill_information: //S1/10/10201409/11/170309/20/14000000/30/106017086
no_reference:
creditor:
iban: CH08 3080 8004 1110 4136 9
Expand Down

0 comments on commit f6eb2eb

Please sign in to comment.