From bdfc0519d8c2b7b0d10ce0ecb5853031693bff8b Mon Sep 17 00:00:00 2001 From: Georg Ledermann Date: Mon, 9 Jun 2014 10:08:33 +0200 Subject: [PATCH] Convert specs to RSpec 3.0.0 syntax with Transpec --- sepa_king.gemspec | 4 +- spec/account_spec.rb | 12 +-- spec/converter_spec.rb | 26 +++--- spec/credit_transfer_spec.rb | 86 +++++++++--------- spec/credit_transfer_transaction_spec.rb | 12 +-- spec/creditor_account_spec.rb | 4 +- spec/direct_debit_spec.rb | 110 +++++++++++------------ spec/direct_debit_transaction_spec.rb | 16 ++-- spec/message_spec.rb | 16 ++-- spec/spec_helper.rb | 1 - spec/support/custom_matcher.rb | 22 ++--- spec/transaction_spec.rb | 30 +++---- spec/validation_spec.rb | 16 ++-- spec/validator_spec.rb | 16 ++-- 14 files changed, 185 insertions(+), 186 deletions(-) diff --git a/sepa_king.gemspec b/sepa_king.gemspec index 7686870..6518507 100644 --- a/sepa_king.gemspec +++ b/sepa_king.gemspec @@ -25,8 +25,8 @@ Gem::Specification.new do |s| s.add_runtime_dependency 'builder' s.add_runtime_dependency 'iban-tools' - s.add_development_dependency 'bundler', '~> 1.3' - s.add_development_dependency 'rspec', '>=2.14' + s.add_development_dependency 'bundler' + s.add_development_dependency 'rspec', '~> 3.0' s.add_development_dependency 'coveralls' s.add_development_dependency 'simplecov' s.add_development_dependency 'rake' diff --git a/spec/account_spec.rb b/spec/account_spec.rb index a55a2f5..d5017e3 100644 --- a/spec/account_spec.rb +++ b/spec/account_spec.rb @@ -12,31 +12,31 @@ describe :name do it 'should accept valid value' do - SEPA::Account.should accept('Gläubiger GmbH', 'Zahlemann & Söhne GbR', 'X' * 70, for: :name) + expect(SEPA::Account).to accept('Gläubiger GmbH', 'Zahlemann & Söhne GbR', 'X' * 70, for: :name) end it 'should not accept invalid value' do - SEPA::Account.should_not accept(nil, '', 'X' * 71, for: :name) + expect(SEPA::Account).not_to accept(nil, '', 'X' * 71, for: :name) end end describe :iban do it 'should accept valid value' do - SEPA::Account.should accept('DE21500500009876543210', 'PL61109010140000071219812874', for: :iban) + expect(SEPA::Account).to accept('DE21500500009876543210', 'PL61109010140000071219812874', for: :iban) end it 'should not accept invalid value' do - SEPA::Account.should_not accept(nil, '', 'invalid', for: :iban) + expect(SEPA::Account).not_to accept(nil, '', 'invalid', for: :iban) end end describe :bic do it 'should accept valid value' do - SEPA::Account.should accept('DEUTDEFF', 'DEUTDEFF500', 'SPUEDE2UXXX', for: :bic) + expect(SEPA::Account).to accept('DEUTDEFF', 'DEUTDEFF500', 'SPUEDE2UXXX', for: :bic) end it 'should not accept invalid value' do - SEPA::Account.should_not accept('', 'invalid', for: :bic) + expect(SEPA::Account).not_to accept('', 'invalid', for: :bic) end end end diff --git a/spec/converter_spec.rb b/spec/converter_spec.rb index 7d47443..2f35ee5 100644 --- a/spec/converter_spec.rb +++ b/spec/converter_spec.rb @@ -6,48 +6,48 @@ describe :convert_text do it 'should remove invalid chars' do - convert_text('&@"=<>!').should == '' + expect(convert_text('&@"=<>!')).to eq('') end it 'should not touch valid chars' do - convert_text("abc-ABC-0123- ':?,-(+.)/").should == "abc-ABC-0123- ':?,-(+.)/" + expect(convert_text("abc-ABC-0123- ':?,-(+.)/")).to eq("abc-ABC-0123- ':?,-(+.)/") end it 'should convert umlaute' do - convert_text('üöäÜÖÄß').should == 'uoaUOAss' + expect(convert_text('üöäÜÖÄß')).to eq('uoaUOAss') end it 'should convert line breaks' do - convert_text("one\ntwo") .should == 'one two' - convert_text("one\ntwo\n") .should == 'one two' - convert_text("\none\ntwo\n").should == 'one two' - convert_text("one\n\ntwo") .should == 'one two' + expect(convert_text("one\ntwo")) .to eq('one two') + expect(convert_text("one\ntwo\n")) .to eq('one two') + expect(convert_text("\none\ntwo\n")).to eq('one two') + expect(convert_text("one\n\ntwo")) .to eq('one two') end it 'should convert number' do - convert_text(1234).should == '1234' + expect(convert_text(1234)).to eq('1234') end it 'should not touch nil' do - convert_text(nil).should == nil + expect(convert_text(nil)).to eq(nil) end end describe :convert_decimal do it "should convert Integer to BigDecimal" do - convert_decimal(42).should == BigDecimal('42.00') + expect(convert_decimal(42)).to eq(BigDecimal('42.00')) end it "should convert Float to BigDecimal" do - convert_decimal(42.12).should == BigDecimal('42.12') + expect(convert_decimal(42.12)).to eq(BigDecimal('42.12')) end it 'should round' do - convert_decimal(1.345).should == BigDecimal('1.35') + expect(convert_decimal(1.345)).to eq(BigDecimal('1.35')) end it 'should not touch nil' do - convert_decimal(nil).should == nil + expect(convert_decimal(nil)).to eq(nil) end end end diff --git a/spec/credit_transfer_spec.rb b/spec/credit_transfer_spec.rb index 95a4ee1..645e840 100644 --- a/spec/credit_transfer_spec.rb +++ b/spec/credit_transfer_spec.rb @@ -22,7 +22,7 @@ credit_transfer.add_transaction(credit_transfer_transaction) end - expect(credit_transfer).to have(3).transactions + expect(credit_transfer.transactions.size).to eq(3) end it 'should fail for invalid transaction' do @@ -120,73 +120,73 @@ end it 'should have message_identification' do - subject.should have_xml('//Document/CstmrCdtTrfInitn/GrpHdr/MsgId', /SEPA-KING\/[0-9]+/) + expect(subject).to have_xml('//Document/CstmrCdtTrfInitn/GrpHdr/MsgId', /SEPA-KING\/[0-9]+/) end it 'should contain ' do - subject.should have_xml('//Document/CstmrCdtTrfInitn/PmtInf/PmtInfId', /SEPA-KING\/[0-9]+\/1/) + expect(subject).to have_xml('//Document/CstmrCdtTrfInitn/PmtInf/PmtInfId', /SEPA-KING\/[0-9]+\/1/) end it 'should contain ' do - subject.should have_xml('//Document/CstmrCdtTrfInitn/PmtInf/ReqdExctnDt', Date.today.next.iso8601) + expect(subject).to have_xml('//Document/CstmrCdtTrfInitn/PmtInf/ReqdExctnDt', Date.today.next.iso8601) end it 'should contain ' do - subject.should have_xml('//Document/CstmrCdtTrfInitn/PmtInf/PmtMtd', 'TRF') + expect(subject).to have_xml('//Document/CstmrCdtTrfInitn/PmtInf/PmtMtd', 'TRF') end it 'should contain ' do - subject.should have_xml('//Document/CstmrCdtTrfInitn/PmtInf/BtchBookg', 'true') + expect(subject).to have_xml('//Document/CstmrCdtTrfInitn/PmtInf/BtchBookg', 'true') end it 'should contain ' do - subject.should have_xml('//Document/CstmrCdtTrfInitn/PmtInf/NbOfTxs', '2') + expect(subject).to have_xml('//Document/CstmrCdtTrfInitn/PmtInf/NbOfTxs', '2') end it 'should contain ' do - subject.should have_xml('//Document/CstmrCdtTrfInitn/PmtInf/CtrlSum', '161.50') + expect(subject).to have_xml('//Document/CstmrCdtTrfInitn/PmtInf/CtrlSum', '161.50') end it 'should contain ' do - subject.should have_xml('//Document/CstmrCdtTrfInitn/PmtInf/Dbtr/Nm', 'Schuldner GmbH') + expect(subject).to have_xml('//Document/CstmrCdtTrfInitn/PmtInf/Dbtr/Nm', 'Schuldner GmbH') end it 'should contain ' do - subject.should have_xml('//Document/CstmrCdtTrfInitn/PmtInf/DbtrAcct/Id/IBAN', 'DE87200500001234567890') + expect(subject).to have_xml('//Document/CstmrCdtTrfInitn/PmtInf/DbtrAcct/Id/IBAN', 'DE87200500001234567890') end it 'should contain ' do - subject.should have_xml('//Document/CstmrCdtTrfInitn/PmtInf/DbtrAgt/FinInstnId/BIC', 'BANKDEFFXXX') + expect(subject).to have_xml('//Document/CstmrCdtTrfInitn/PmtInf/DbtrAgt/FinInstnId/BIC', 'BANKDEFFXXX') end it 'should contain ' do - subject.should have_xml('//Document/CstmrCdtTrfInitn/PmtInf/CdtTrfTxInf[1]/PmtId/EndToEndId', 'XYZ-1234/123') - subject.should have_xml('//Document/CstmrCdtTrfInitn/PmtInf/CdtTrfTxInf[2]/PmtId/EndToEndId', 'XYZ-5678/456') + expect(subject).to have_xml('//Document/CstmrCdtTrfInitn/PmtInf/CdtTrfTxInf[1]/PmtId/EndToEndId', 'XYZ-1234/123') + expect(subject).to have_xml('//Document/CstmrCdtTrfInitn/PmtInf/CdtTrfTxInf[2]/PmtId/EndToEndId', 'XYZ-5678/456') end it 'should contain ' do - subject.should have_xml('//Document/CstmrCdtTrfInitn/PmtInf/CdtTrfTxInf[1]/Amt/InstdAmt', '102.50') - subject.should have_xml('//Document/CstmrCdtTrfInitn/PmtInf/CdtTrfTxInf[2]/Amt/InstdAmt', '59.00') + expect(subject).to have_xml('//Document/CstmrCdtTrfInitn/PmtInf/CdtTrfTxInf[1]/Amt/InstdAmt', '102.50') + expect(subject).to have_xml('//Document/CstmrCdtTrfInitn/PmtInf/CdtTrfTxInf[2]/Amt/InstdAmt', '59.00') end it 'should contain for every BIC given' do - subject.should have_xml('//Document/CstmrCdtTrfInitn/PmtInf/CdtTrfTxInf[1]/CdtrAgt/FinInstnId/BIC', 'PBNKDEFF370') - subject.should_not have_xml('//Document/CstmrCdtTrfInitn/PmtInf/CdtTrfTxInf[2]/CdtrAgt') + expect(subject).to have_xml('//Document/CstmrCdtTrfInitn/PmtInf/CdtTrfTxInf[1]/CdtrAgt/FinInstnId/BIC', 'PBNKDEFF370') + expect(subject).not_to have_xml('//Document/CstmrCdtTrfInitn/PmtInf/CdtTrfTxInf[2]/CdtrAgt') end it 'should contain ' do - subject.should have_xml('//Document/CstmrCdtTrfInitn/PmtInf/CdtTrfTxInf[1]/Cdtr/Nm', 'Telekomiker AG') - subject.should have_xml('//Document/CstmrCdtTrfInitn/PmtInf/CdtTrfTxInf[2]/Cdtr/Nm', 'Amazonas GmbH') + expect(subject).to have_xml('//Document/CstmrCdtTrfInitn/PmtInf/CdtTrfTxInf[1]/Cdtr/Nm', 'Telekomiker AG') + expect(subject).to have_xml('//Document/CstmrCdtTrfInitn/PmtInf/CdtTrfTxInf[2]/Cdtr/Nm', 'Amazonas GmbH') end it 'should contain ' do - subject.should have_xml('//Document/CstmrCdtTrfInitn/PmtInf/CdtTrfTxInf[1]/CdtrAcct/Id/IBAN', 'DE37112589611964645802') - subject.should have_xml('//Document/CstmrCdtTrfInitn/PmtInf/CdtTrfTxInf[2]/CdtrAcct/Id/IBAN', 'DE27793589132923472195') + expect(subject).to have_xml('//Document/CstmrCdtTrfInitn/PmtInf/CdtTrfTxInf[1]/CdtrAcct/Id/IBAN', 'DE37112589611964645802') + expect(subject).to have_xml('//Document/CstmrCdtTrfInitn/PmtInf/CdtTrfTxInf[2]/CdtrAcct/Id/IBAN', 'DE27793589132923472195') end it 'should contain ' do - subject.should have_xml('//Document/CstmrCdtTrfInitn/PmtInf/CdtTrfTxInf[1]/RmtInf/Ustrd', 'Rechnung vom 22.08.2013') - subject.should have_xml('//Document/CstmrCdtTrfInitn/PmtInf/CdtTrfTxInf[2]/RmtInf/Ustrd', 'Rechnung vom 21.08.2013') + expect(subject).to have_xml('//Document/CstmrCdtTrfInitn/PmtInf/CdtTrfTxInf[1]/RmtInf/Ustrd', 'Rechnung vom 22.08.2013') + expect(subject).to have_xml('//Document/CstmrCdtTrfInitn/PmtInf/CdtTrfTxInf[2]/RmtInf/Ustrd', 'Rechnung vom 21.08.2013') end end @@ -202,15 +202,15 @@ end it 'should contain two payment_informations with ' do - subject.should have_xml('//Document/CstmrCdtTrfInitn/PmtInf[1]/ReqdExctnDt', (Date.today + 1).iso8601) - subject.should have_xml('//Document/CstmrCdtTrfInitn/PmtInf[2]/ReqdExctnDt', (Date.today + 2).iso8601) + expect(subject).to have_xml('//Document/CstmrCdtTrfInitn/PmtInf[1]/ReqdExctnDt', (Date.today + 1).iso8601) + expect(subject).to have_xml('//Document/CstmrCdtTrfInitn/PmtInf[2]/ReqdExctnDt', (Date.today + 2).iso8601) - subject.should_not have_xml('//Document/CstmrCdtTrfInitn/PmtInf[3]') + expect(subject).not_to have_xml('//Document/CstmrCdtTrfInitn/PmtInf[3]') end it 'should contain two payment_informations with different ' do - subject.should have_xml('//Document/CstmrCdtTrfInitn/PmtInf[1]/PmtInfId', /SEPA-KING\/[0-9]+\/1/) - subject.should have_xml('//Document/CstmrCdtTrfInitn/PmtInf[2]/PmtInfId', /SEPA-KING\/[0-9]+\/2/) + expect(subject).to have_xml('//Document/CstmrCdtTrfInitn/PmtInf[1]/PmtInfId', /SEPA-KING\/[0-9]+\/1/) + expect(subject).to have_xml('//Document/CstmrCdtTrfInitn/PmtInf[2]/PmtInfId', /SEPA-KING\/[0-9]+\/2/) end end @@ -226,10 +226,10 @@ end it 'should contain two payment_informations with ' do - subject.should have_xml('//Document/CstmrCdtTrfInitn/PmtInf[1]/BtchBookg', 'false') - subject.should have_xml('//Document/CstmrCdtTrfInitn/PmtInf[2]/BtchBookg', 'true') + expect(subject).to have_xml('//Document/CstmrCdtTrfInitn/PmtInf[1]/BtchBookg', 'false') + expect(subject).to have_xml('//Document/CstmrCdtTrfInitn/PmtInf[2]/BtchBookg', 'true') - subject.should_not have_xml('//Document/CstmrCdtTrfInitn/PmtInf[3]') + expect(subject).not_to have_xml('//Document/CstmrCdtTrfInitn/PmtInf[3]') end end @@ -246,24 +246,24 @@ end it 'should contain multiple payment_informations' do - subject.should have_xml('//Document/CstmrCdtTrfInitn/PmtInf[1]/ReqdExctnDt', (Date.today + 1).iso8601) - subject.should have_xml('//Document/CstmrCdtTrfInitn/PmtInf[1]/BtchBookg', 'false') + expect(subject).to have_xml('//Document/CstmrCdtTrfInitn/PmtInf[1]/ReqdExctnDt', (Date.today + 1).iso8601) + expect(subject).to have_xml('//Document/CstmrCdtTrfInitn/PmtInf[1]/BtchBookg', 'false') - subject.should have_xml('//Document/CstmrCdtTrfInitn/PmtInf[2]/ReqdExctnDt', (Date.today + 1).iso8601) - subject.should have_xml('//Document/CstmrCdtTrfInitn/PmtInf[2]/BtchBookg', 'true') + expect(subject).to have_xml('//Document/CstmrCdtTrfInitn/PmtInf[2]/ReqdExctnDt', (Date.today + 1).iso8601) + expect(subject).to have_xml('//Document/CstmrCdtTrfInitn/PmtInf[2]/BtchBookg', 'true') - subject.should have_xml('//Document/CstmrCdtTrfInitn/PmtInf[3]/ReqdExctnDt', (Date.today + 2).iso8601) - subject.should have_xml('//Document/CstmrCdtTrfInitn/PmtInf[3]/BtchBookg', 'false') + expect(subject).to have_xml('//Document/CstmrCdtTrfInitn/PmtInf[3]/ReqdExctnDt', (Date.today + 2).iso8601) + expect(subject).to have_xml('//Document/CstmrCdtTrfInitn/PmtInf[3]/BtchBookg', 'false') - subject.should have_xml('//Document/CstmrCdtTrfInitn/PmtInf[4]/ReqdExctnDt', (Date.today + 2).iso8601) - subject.should have_xml('//Document/CstmrCdtTrfInitn/PmtInf[4]/BtchBookg', 'true') + expect(subject).to have_xml('//Document/CstmrCdtTrfInitn/PmtInf[4]/ReqdExctnDt', (Date.today + 2).iso8601) + expect(subject).to have_xml('//Document/CstmrCdtTrfInitn/PmtInf[4]/BtchBookg', 'true') end it 'should have multiple control sums' do - subject.should have_xml('//Document/CstmrCdtTrfInitn/PmtInf[1]/CtrlSum', '1.00') - subject.should have_xml('//Document/CstmrCdtTrfInitn/PmtInf[2]/CtrlSum', '2.00') - subject.should have_xml('//Document/CstmrCdtTrfInitn/PmtInf[3]/CtrlSum', '4.00') - subject.should have_xml('//Document/CstmrCdtTrfInitn/PmtInf[4]/CtrlSum', '8.00') + expect(subject).to have_xml('//Document/CstmrCdtTrfInitn/PmtInf[1]/CtrlSum', '1.00') + expect(subject).to have_xml('//Document/CstmrCdtTrfInitn/PmtInf[2]/CtrlSum', '2.00') + expect(subject).to have_xml('//Document/CstmrCdtTrfInitn/PmtInf[3]/CtrlSum', '4.00') + expect(subject).to have_xml('//Document/CstmrCdtTrfInitn/PmtInf[4]/CtrlSum', '8.00') end end end diff --git a/spec/credit_transfer_transaction_spec.rb b/spec/credit_transfer_transaction_spec.rb index bc77df0..5e2538e 100644 --- a/spec/credit_transfer_transaction_spec.rb +++ b/spec/credit_transfer_transaction_spec.rb @@ -18,29 +18,29 @@ describe :schema_compatible? do context 'for pain.001.003.03' do it 'should success' do - SEPA::CreditTransferTransaction.new({}).should be_schema_compatible('pain.001.003.03') + expect(SEPA::CreditTransferTransaction.new({})).to be_schema_compatible('pain.001.003.03') end end context 'pain.001.002.03' do it 'should success for valid attributes' do - SEPA::CreditTransferTransaction.new(:bic => 'SPUEDE2UXXX', :service_level => 'SEPA').should be_schema_compatible('pain.001.002.03') + expect(SEPA::CreditTransferTransaction.new(:bic => 'SPUEDE2UXXX', :service_level => 'SEPA')).to be_schema_compatible('pain.001.002.03') end it 'should fail for invalid attributes' do - SEPA::CreditTransferTransaction.new(:bic => nil).should_not be_schema_compatible('pain.001.002.03') - SEPA::CreditTransferTransaction.new(:bic => 'SPUEDE2UXXX', :service_level => 'URGP').should_not be_schema_compatible('pain.001.002.03') + expect(SEPA::CreditTransferTransaction.new(:bic => nil)).not_to be_schema_compatible('pain.001.002.03') + expect(SEPA::CreditTransferTransaction.new(:bic => 'SPUEDE2UXXX', :service_level => 'URGP')).not_to be_schema_compatible('pain.001.002.03') end end end context 'Requested date' do it 'should allow valid value' do - SEPA::CreditTransferTransaction.should accept(nil, Date.today, Date.today.next, Date.today + 2, for: :requested_date) + expect(SEPA::CreditTransferTransaction).to accept(nil, Date.today, Date.today.next, Date.today + 2, for: :requested_date) end it 'should not allow invalid value' do - SEPA::CreditTransferTransaction.should_not accept(Date.new(1995,12,21), Date.today - 1, for: :requested_date) + expect(SEPA::CreditTransferTransaction).not_to accept(Date.new(1995,12,21), Date.today - 1, for: :requested_date) end end end diff --git a/spec/creditor_account_spec.rb b/spec/creditor_account_spec.rb index 89442cb..b9c48ce 100644 --- a/spec/creditor_account_spec.rb +++ b/spec/creditor_account_spec.rb @@ -13,11 +13,11 @@ describe :creditor_identifier do it 'should accept valid value' do - SEPA::CreditorAccount.should accept('DE98ZZZ09999999999', 'AT12ZZZ00000000001', 'IT97ZZZA1B2C3D4E5F6G7H8', 'NL97ZZZ123456780001', 'FR12ZZZ123456', for: :creditor_identifier) + expect(SEPA::CreditorAccount).to accept('DE98ZZZ09999999999', 'AT12ZZZ00000000001', 'IT97ZZZA1B2C3D4E5F6G7H8', 'NL97ZZZ123456780001', 'FR12ZZZ123456', for: :creditor_identifier) end it 'should not accept invalid value' do - SEPA::CreditorAccount.should_not accept('', 'invalid', 'DE98ZZZ099999999990', 'DEAAAAAAAAAAAAAAAA', for: :creditor_identifier) + expect(SEPA::CreditorAccount).not_to accept('', 'invalid', 'DE98ZZZ099999999990', 'DEAAAAAAAAAAAAAAAA', for: :creditor_identifier) end end end diff --git a/spec/direct_debit_spec.rb b/spec/direct_debit_spec.rb index f6835f7..94d209d 100644 --- a/spec/direct_debit_spec.rb +++ b/spec/direct_debit_spec.rb @@ -23,7 +23,7 @@ direct_debit.add_transaction(direct_debt_transaction) end - expect(direct_debit).to have(3).transactions + expect(direct_debit.transactions.size).to eq(3) end it 'should fail for invalid transaction' do @@ -57,7 +57,7 @@ direct_debit.add_transaction(direct_debt_transaction(reference: "EXAMPLE REFERENCE 2", requested_date: Date.today.next.next)) direct_debit.add_transaction(direct_debt_transaction(reference: "EXAMPLE REFERENCE 3")) - expect(direct_debit.batches).to have(2).items + expect(direct_debit.batches.size).to eq(2) expect(direct_debit.batches[0]).to match(/SEPA-KING\/[0-9]+/) expect(direct_debit.batches[1]).to match(/SEPA-KING\/[0-9]+/) end @@ -164,87 +164,87 @@ end it 'should have message_identification' do - subject.should have_xml('//Document/CstmrDrctDbtInitn/GrpHdr/MsgId', /SEPA-KING\/[0-9]+/) + expect(subject).to have_xml('//Document/CstmrDrctDbtInitn/GrpHdr/MsgId', /SEPA-KING\/[0-9]+/) end it 'should contain ' do - subject.should have_xml('//Document/CstmrDrctDbtInitn/PmtInf/PmtInfId', /SEPA-KING\/[0-9]+\/1/) + expect(subject).to have_xml('//Document/CstmrDrctDbtInitn/PmtInf/PmtInfId', /SEPA-KING\/[0-9]+\/1/) end it 'should contain ' do - subject.should have_xml('//Document/CstmrDrctDbtInitn/PmtInf/ReqdColltnDt', Date.today.next.iso8601) + expect(subject).to have_xml('//Document/CstmrDrctDbtInitn/PmtInf/ReqdColltnDt', Date.today.next.iso8601) end it 'should contain ' do - subject.should have_xml('//Document/CstmrDrctDbtInitn/PmtInf/PmtMtd', 'DD') + expect(subject).to have_xml('//Document/CstmrDrctDbtInitn/PmtInf/PmtMtd', 'DD') end it 'should contain ' do - subject.should have_xml('//Document/CstmrDrctDbtInitn/PmtInf/BtchBookg', 'true') + expect(subject).to have_xml('//Document/CstmrDrctDbtInitn/PmtInf/BtchBookg', 'true') end it 'should contain ' do - subject.should have_xml('//Document/CstmrDrctDbtInitn/PmtInf/NbOfTxs', '2') + expect(subject).to have_xml('//Document/CstmrDrctDbtInitn/PmtInf/NbOfTxs', '2') end it 'should contain ' do - subject.should have_xml('//Document/CstmrDrctDbtInitn/PmtInf/CtrlSum', '789.99') + expect(subject).to have_xml('//Document/CstmrDrctDbtInitn/PmtInf/CtrlSum', '789.99') end it 'should contain ' do - subject.should have_xml('//Document/CstmrDrctDbtInitn/PmtInf/Cdtr/Nm', 'Glaubiger GmbH') + expect(subject).to have_xml('//Document/CstmrDrctDbtInitn/PmtInf/Cdtr/Nm', 'Glaubiger GmbH') end it 'should contain ' do - subject.should have_xml('//Document/CstmrDrctDbtInitn/PmtInf/CdtrAcct/Id/IBAN', 'DE87200500001234567890') + expect(subject).to have_xml('//Document/CstmrDrctDbtInitn/PmtInf/CdtrAcct/Id/IBAN', 'DE87200500001234567890') end it 'should contain ' do - subject.should have_xml('//Document/CstmrDrctDbtInitn/PmtInf/CdtrAgt/FinInstnId/BIC', 'BANKDEFFXXX') + expect(subject).to have_xml('//Document/CstmrDrctDbtInitn/PmtInf/CdtrAgt/FinInstnId/BIC', 'BANKDEFFXXX') end it 'should contain ' do - subject.should have_xml('//Document/CstmrDrctDbtInitn/PmtInf/CdtrSchmeId/Id/PrvtId/Othr/Id', 'DE98ZZZ09999999999') + expect(subject).to have_xml('//Document/CstmrDrctDbtInitn/PmtInf/CdtrSchmeId/Id/PrvtId/Othr/Id', 'DE98ZZZ09999999999') end it 'should contain ' do - subject.should have_xml('//Document/CstmrDrctDbtInitn/PmtInf/DrctDbtTxInf[1]/PmtId/EndToEndId', 'XYZ/2013-08-ABO/12345') - subject.should have_xml('//Document/CstmrDrctDbtInitn/PmtInf/DrctDbtTxInf[2]/PmtId/EndToEndId', 'XYZ/2013-08-ABO/6789') + expect(subject).to have_xml('//Document/CstmrDrctDbtInitn/PmtInf/DrctDbtTxInf[1]/PmtId/EndToEndId', 'XYZ/2013-08-ABO/12345') + expect(subject).to have_xml('//Document/CstmrDrctDbtInitn/PmtInf/DrctDbtTxInf[2]/PmtId/EndToEndId', 'XYZ/2013-08-ABO/6789') end it 'should contain ' do - subject.should have_xml('//Document/CstmrDrctDbtInitn/PmtInf/DrctDbtTxInf[1]/InstdAmt', '39.99') - subject.should have_xml('//Document/CstmrDrctDbtInitn/PmtInf/DrctDbtTxInf[2]/InstdAmt', '750.00') + expect(subject).to have_xml('//Document/CstmrDrctDbtInitn/PmtInf/DrctDbtTxInf[1]/InstdAmt', '39.99') + expect(subject).to have_xml('//Document/CstmrDrctDbtInitn/PmtInf/DrctDbtTxInf[2]/InstdAmt', '750.00') end it 'should contain ' do - subject.should have_xml('//Document/CstmrDrctDbtInitn/PmtInf/DrctDbtTxInf[1]/DrctDbtTx/MndtRltdInf/MndtId', 'K-02-2011-12345') - subject.should have_xml('//Document/CstmrDrctDbtInitn/PmtInf/DrctDbtTxInf[2]/DrctDbtTx/MndtRltdInf/MndtId', 'K-08-2010-42123') + expect(subject).to have_xml('//Document/CstmrDrctDbtInitn/PmtInf/DrctDbtTxInf[1]/DrctDbtTx/MndtRltdInf/MndtId', 'K-02-2011-12345') + expect(subject).to have_xml('//Document/CstmrDrctDbtInitn/PmtInf/DrctDbtTxInf[2]/DrctDbtTx/MndtRltdInf/MndtId', 'K-08-2010-42123') end it 'should contain ' do - subject.should have_xml('//Document/CstmrDrctDbtInitn/PmtInf/DrctDbtTxInf[1]/DrctDbtTx/MndtRltdInf/DtOfSgntr', '2011-01-25') - subject.should have_xml('//Document/CstmrDrctDbtInitn/PmtInf/DrctDbtTxInf[2]/DrctDbtTx/MndtRltdInf/DtOfSgntr', '2010-07-25') + expect(subject).to have_xml('//Document/CstmrDrctDbtInitn/PmtInf/DrctDbtTxInf[1]/DrctDbtTx/MndtRltdInf/DtOfSgntr', '2011-01-25') + expect(subject).to have_xml('//Document/CstmrDrctDbtInitn/PmtInf/DrctDbtTxInf[2]/DrctDbtTx/MndtRltdInf/DtOfSgntr', '2010-07-25') end it 'should contain ' do - subject.should have_xml('//Document/CstmrDrctDbtInitn/PmtInf/DrctDbtTxInf[1]/DbtrAgt/FinInstnId/BIC', 'SPUEDE2UXXX') - subject.should have_xml('//Document/CstmrDrctDbtInitn/PmtInf/DrctDbtTxInf[2]/DbtrAgt/FinInstnId/Othr/Id', 'NOTPROVIDED') + expect(subject).to have_xml('//Document/CstmrDrctDbtInitn/PmtInf/DrctDbtTxInf[1]/DbtrAgt/FinInstnId/BIC', 'SPUEDE2UXXX') + expect(subject).to have_xml('//Document/CstmrDrctDbtInitn/PmtInf/DrctDbtTxInf[2]/DbtrAgt/FinInstnId/Othr/Id', 'NOTPROVIDED') end it 'should contain ' do - subject.should have_xml('//Document/CstmrDrctDbtInitn/PmtInf/DrctDbtTxInf[1]/Dbtr/Nm', 'Zahlemann Sohne GbR') - subject.should have_xml('//Document/CstmrDrctDbtInitn/PmtInf/DrctDbtTxInf[2]/Dbtr/Nm', 'Meier Schulze oHG') + expect(subject).to have_xml('//Document/CstmrDrctDbtInitn/PmtInf/DrctDbtTxInf[1]/Dbtr/Nm', 'Zahlemann Sohne GbR') + expect(subject).to have_xml('//Document/CstmrDrctDbtInitn/PmtInf/DrctDbtTxInf[2]/Dbtr/Nm', 'Meier Schulze oHG') end it 'should contain ' do - subject.should have_xml('//Document/CstmrDrctDbtInitn/PmtInf/DrctDbtTxInf[1]/DbtrAcct/Id/IBAN', 'DE21500500009876543210') - subject.should have_xml('//Document/CstmrDrctDbtInitn/PmtInf/DrctDbtTxInf[2]/DbtrAcct/Id/IBAN', 'DE68210501700012345678') + expect(subject).to have_xml('//Document/CstmrDrctDbtInitn/PmtInf/DrctDbtTxInf[1]/DbtrAcct/Id/IBAN', 'DE21500500009876543210') + expect(subject).to have_xml('//Document/CstmrDrctDbtInitn/PmtInf/DrctDbtTxInf[2]/DbtrAcct/Id/IBAN', 'DE68210501700012345678') end it 'should contain ' do - subject.should have_xml('//Document/CstmrDrctDbtInitn/PmtInf/DrctDbtTxInf[1]/RmtInf/Ustrd', 'Unsere Rechnung vom 10.08.2013') - subject.should have_xml('//Document/CstmrDrctDbtInitn/PmtInf/DrctDbtTxInf[2]/RmtInf/Ustrd', 'Vielen Dank fur Ihren Einkauf') + expect(subject).to have_xml('//Document/CstmrDrctDbtInitn/PmtInf/DrctDbtTxInf[1]/RmtInf/Ustrd', 'Unsere Rechnung vom 10.08.2013') + expect(subject).to have_xml('//Document/CstmrDrctDbtInitn/PmtInf/DrctDbtTxInf[2]/RmtInf/Ustrd', 'Vielen Dank fur Ihren Einkauf') end end @@ -260,15 +260,15 @@ end it 'should contain two payment_informations with ' do - subject.should have_xml('//Document/CstmrDrctDbtInitn/PmtInf[1]/ReqdColltnDt', (Date.today + 1).iso8601) - subject.should have_xml('//Document/CstmrDrctDbtInitn/PmtInf[2]/ReqdColltnDt', (Date.today + 2).iso8601) + expect(subject).to have_xml('//Document/CstmrDrctDbtInitn/PmtInf[1]/ReqdColltnDt', (Date.today + 1).iso8601) + expect(subject).to have_xml('//Document/CstmrDrctDbtInitn/PmtInf[2]/ReqdColltnDt', (Date.today + 2).iso8601) - subject.should_not have_xml('//Document/CstmrDrctDbtInitn/PmtInf[3]') + expect(subject).not_to have_xml('//Document/CstmrDrctDbtInitn/PmtInf[3]') end it 'should contain two payment_informations with different ' do - subject.should have_xml('//Document/CstmrDrctDbtInitn/PmtInf[1]/PmtInfId', /SEPA-KING\/[0-9]+\/1/) - subject.should have_xml('//Document/CstmrDrctDbtInitn/PmtInf[2]/PmtInfId', /SEPA-KING\/[0-9]+\/2/) + expect(subject).to have_xml('//Document/CstmrDrctDbtInitn/PmtInf[1]/PmtInfId', /SEPA-KING\/[0-9]+\/1/) + expect(subject).to have_xml('//Document/CstmrDrctDbtInitn/PmtInf[2]/PmtInfId', /SEPA-KING\/[0-9]+\/2/) end end @@ -283,7 +283,7 @@ end it 'should have errors' do - subject.should have(1).error_on(:base) + expect(subject.errors_on(:base).size).to eq(1) end it 'should raise error on XML generation' do @@ -305,10 +305,10 @@ end it 'should contain two payment_informations with ' do - subject.should have_xml('//Document/CstmrDrctDbtInitn/PmtInf[1]/PmtTpInf/SeqTp', 'OOFF') - subject.should have_xml('//Document/CstmrDrctDbtInitn/PmtInf[2]/PmtTpInf/SeqTp', 'FRST') + expect(subject).to have_xml('//Document/CstmrDrctDbtInitn/PmtInf[1]/PmtTpInf/SeqTp', 'OOFF') + expect(subject).to have_xml('//Document/CstmrDrctDbtInitn/PmtInf[2]/PmtTpInf/SeqTp', 'FRST') - subject.should_not have_xml('//Document/CstmrDrctDbtInitn/PmtInf[3]') + expect(subject).not_to have_xml('//Document/CstmrDrctDbtInitn/PmtInf[3]') end end @@ -324,10 +324,10 @@ end it 'should contain two payment_informations with ' do - subject.should have_xml('//Document/CstmrDrctDbtInitn/PmtInf[1]/BtchBookg', 'false') - subject.should have_xml('//Document/CstmrDrctDbtInitn/PmtInf[2]/BtchBookg', 'true') + expect(subject).to have_xml('//Document/CstmrDrctDbtInitn/PmtInf[1]/BtchBookg', 'false') + expect(subject).to have_xml('//Document/CstmrDrctDbtInitn/PmtInf[2]/BtchBookg', 'true') - subject.should_not have_xml('//Document/CstmrDrctDbtInitn/PmtInf[3]') + expect(subject).not_to have_xml('//Document/CstmrDrctDbtInitn/PmtInf[3]') end end @@ -344,24 +344,24 @@ end it 'should contain multiple payment_informations' do - subject.should have_xml('//Document/CstmrDrctDbtInitn/PmtInf[1]/ReqdColltnDt', (Date.today + 1).iso8601) - subject.should have_xml('//Document/CstmrDrctDbtInitn/PmtInf[1]/PmtTpInf/SeqTp', 'OOFF') + expect(subject).to have_xml('//Document/CstmrDrctDbtInitn/PmtInf[1]/ReqdColltnDt', (Date.today + 1).iso8601) + expect(subject).to have_xml('//Document/CstmrDrctDbtInitn/PmtInf[1]/PmtTpInf/SeqTp', 'OOFF') - subject.should have_xml('//Document/CstmrDrctDbtInitn/PmtInf[2]/ReqdColltnDt', (Date.today + 1).iso8601) - subject.should have_xml('//Document/CstmrDrctDbtInitn/PmtInf[2]/PmtTpInf/SeqTp', 'FNAL') + expect(subject).to have_xml('//Document/CstmrDrctDbtInitn/PmtInf[2]/ReqdColltnDt', (Date.today + 1).iso8601) + expect(subject).to have_xml('//Document/CstmrDrctDbtInitn/PmtInf[2]/PmtTpInf/SeqTp', 'FNAL') - subject.should have_xml('//Document/CstmrDrctDbtInitn/PmtInf[3]/ReqdColltnDt', (Date.today + 2).iso8601) - subject.should have_xml('//Document/CstmrDrctDbtInitn/PmtInf[3]/PmtTpInf/SeqTp', 'OOFF') + expect(subject).to have_xml('//Document/CstmrDrctDbtInitn/PmtInf[3]/ReqdColltnDt', (Date.today + 2).iso8601) + expect(subject).to have_xml('//Document/CstmrDrctDbtInitn/PmtInf[3]/PmtTpInf/SeqTp', 'OOFF') - subject.should have_xml('//Document/CstmrDrctDbtInitn/PmtInf[4]/ReqdColltnDt', (Date.today + 2).iso8601) - subject.should have_xml('//Document/CstmrDrctDbtInitn/PmtInf[4]/PmtTpInf/SeqTp', 'FNAL') + expect(subject).to have_xml('//Document/CstmrDrctDbtInitn/PmtInf[4]/ReqdColltnDt', (Date.today + 2).iso8601) + expect(subject).to have_xml('//Document/CstmrDrctDbtInitn/PmtInf[4]/PmtTpInf/SeqTp', 'FNAL') end it 'should have multiple control sums' do - subject.should have_xml('//Document/CstmrDrctDbtInitn/PmtInf[1]/CtrlSum', '1.00') - subject.should have_xml('//Document/CstmrDrctDbtInitn/PmtInf[2]/CtrlSum', '2.00') - subject.should have_xml('//Document/CstmrDrctDbtInitn/PmtInf[3]/CtrlSum', '4.00') - subject.should have_xml('//Document/CstmrDrctDbtInitn/PmtInf[4]/CtrlSum', '8.00') + expect(subject).to have_xml('//Document/CstmrDrctDbtInitn/PmtInf[1]/CtrlSum', '1.00') + expect(subject).to have_xml('//Document/CstmrDrctDbtInitn/PmtInf[2]/CtrlSum', '2.00') + expect(subject).to have_xml('//Document/CstmrDrctDbtInitn/PmtInf[3]/CtrlSum', '4.00') + expect(subject).to have_xml('//Document/CstmrDrctDbtInitn/PmtInf[4]/CtrlSum', '8.00') end end @@ -381,8 +381,8 @@ end it 'should contain two payment_informations with ' do - subject.should have_xml('//Document/CstmrDrctDbtInitn/PmtInf[1]/Cdtr/Nm', 'Glaubiger GmbH') - subject.should have_xml('//Document/CstmrDrctDbtInitn/PmtInf[2]/Cdtr/Nm', 'Creditor Inc.') + expect(subject).to have_xml('//Document/CstmrDrctDbtInitn/PmtInf[1]/Cdtr/Nm', 'Glaubiger GmbH') + expect(subject).to have_xml('//Document/CstmrDrctDbtInitn/PmtInf[2]/Cdtr/Nm', 'Creditor Inc.') end end end diff --git a/spec/direct_debit_transaction_spec.rb b/spec/direct_debit_transaction_spec.rb index 2899f36..71144c3 100644 --- a/spec/direct_debit_transaction_spec.rb +++ b/spec/direct_debit_transaction_spec.rb @@ -20,39 +20,39 @@ describe :schema_compatible? do context 'for pain.008.003.02' do it 'should success' do - SEPA::DirectDebitTransaction.new({}).should be_schema_compatible('pain.008.003.02') + expect(SEPA::DirectDebitTransaction.new({})).to be_schema_compatible('pain.008.003.02') end end context 'for pain.008.002.02' do it 'should success for valid attributes' do - SEPA::DirectDebitTransaction.new(:bic => 'SPUEDE2UXXX', :local_instrument => 'CORE').should be_schema_compatible('pain.008.002.02') + expect(SEPA::DirectDebitTransaction.new(:bic => 'SPUEDE2UXXX', :local_instrument => 'CORE')).to be_schema_compatible('pain.008.002.02') end it 'should fail for invalid attributes' do - SEPA::DirectDebitTransaction.new(:bic => nil).should_not be_schema_compatible('pain.008.002.02') - SEPA::DirectDebitTransaction.new(:bic => 'SPUEDE2UXXX', :local_instrument => 'COR1').should_not be_schema_compatible('pain.008.002.02') + expect(SEPA::DirectDebitTransaction.new(:bic => nil)).not_to be_schema_compatible('pain.008.002.02') + expect(SEPA::DirectDebitTransaction.new(:bic => 'SPUEDE2UXXX', :local_instrument => 'COR1')).not_to be_schema_compatible('pain.008.002.02') end end end context 'Mandate Date of Signature' do it 'should accept valid value' do - SEPA::DirectDebitTransaction.should accept(Date.today, Date.today - 1, for: :mandate_date_of_signature) + expect(SEPA::DirectDebitTransaction).to accept(Date.today, Date.today - 1, for: :mandate_date_of_signature) end it 'should not accept invalid value' do - SEPA::DirectDebitTransaction.should_not accept(nil, '2010-12-01', Date.today + 1, for: :mandate_date_of_signature) + expect(SEPA::DirectDebitTransaction).not_to accept(nil, '2010-12-01', Date.today + 1, for: :mandate_date_of_signature) end end context 'Requested date' do it 'should allow valid value' do - SEPA::DirectDebitTransaction.should accept(nil, Date.today.next, Date.today + 2, for: :requested_date) + expect(SEPA::DirectDebitTransaction).to accept(nil, Date.today.next, Date.today + 2, for: :requested_date) end it 'should not allow invalid value' do - SEPA::DirectDebitTransaction.should_not accept(Date.new(1995,12,21), Date.today - 1, Date.today, for: :requested_date) + expect(SEPA::DirectDebitTransaction).not_to accept(Date.new(1995,12,21), Date.today - 1, Date.today, for: :requested_date) end end end diff --git a/spec/message_spec.rb b/spec/message_spec.rb index f748b77..1ec8ff6 100644 --- a/spec/message_spec.rb +++ b/spec/message_spec.rb @@ -20,11 +20,11 @@ class DummyMessage < SEPA::Message end it 'should sum up all transactions' do - subject.amount_total.should == 3.3 + expect(subject.amount_total).to eq(3.3) end it 'should sum up selected transactions' do - subject.amount_total([subject.transactions[0]]).should == 1.1 + expect(subject.amount_total([subject.transactions[0]])).to eq(1.1) end end @@ -32,13 +32,13 @@ class DummyMessage < SEPA::Message subject { DummyMessage.new } it 'should fail with invalid account' do - subject.should_not be_valid - subject.should have(2).error_on(:account) + expect(subject).not_to be_valid + expect(subject.errors_on(:account).size).to eq(2) end it 'should fail without transactions' do - subject.should_not be_valid - subject.should have(1).error_on(:transactions) + expect(subject).not_to be_valid + expect(subject.errors_on(:transactions).size).to eq(1) end end @@ -46,12 +46,12 @@ class DummyMessage < SEPA::Message subject { DummyMessage.new } it 'should have a reader method' do - subject.message_identification.should match(/SEPA-KING\/[0-9]+/) + expect(subject.message_identification).to match(/SEPA-KING\/[0-9]+/) end it 'should have a writer method' do subject.message_identification = "MY_MESSAGE_ID/#{Time.now.to_i}" - subject.message_identification.should match(/MY_MESSAGE_ID/) + expect(subject.message_identification).to match(/MY_MESSAGE_ID/) end end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index d2bebc7..de1e624 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -26,7 +26,6 @@ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration RSpec.configure do |config| - config.treat_symbols_as_metadata_keys_with_true_values = true config.run_all_when_everything_filtered = true config.filter_run :focus diff --git a/spec/support/custom_matcher.rb b/spec/support/custom_matcher.rb index 6a46060..b2ee507 100644 --- a/spec/support/custom_matcher.rb +++ b/spec/support/custom_matcher.rb @@ -6,10 +6,10 @@ @schema = Nokogiri::XML::Schema(File.read("lib/schema/#{xsd}")) @doc = Nokogiri::XML(actual) - @schema.should be_valid(@doc) + expect(@schema).to be_valid(@doc) end - failure_message_for_should do |actual| + failure_message do |actual| # Return the validation errors as string @schema.validate(@doc).join("\n") end @@ -21,13 +21,13 @@ doc.remove_namespaces! # so we can use shorter xpath's without any namespace nodes = doc.xpath(xpath) - nodes.should_not be_empty + expect(nodes).not_to be_empty if text nodes.each do |node| if text.is_a?(Regexp) - node.content.should =~ text + expect(node.content).to match(text) else - node.content.should == text + expect(node.content).to eq(text) end end end @@ -39,21 +39,21 @@ attributes = Array(options[:for]) attributes.each do |attribute| - match_for_should do |actual| + match do |actual| values.all? { |value| expect( - actual.new(attribute => value) - ).to have(:no).errors_on(attribute) + actual.new(attribute => value).errors_on(attribute).size + ).to eq 0 } end end attributes.each do |attribute| - match_for_should_not do |actual| + match_when_negated do |actual| values.all? { |value| expect( - actual.new(attribute => value) - ).to have_at_least(1).errors_on(attribute) + actual.new(attribute => value).errors_on(attribute).size + ).to be >= 1 } end end diff --git a/spec/transaction_spec.rb b/spec/transaction_spec.rb index 71e29f7..c408977 100644 --- a/spec/transaction_spec.rb +++ b/spec/transaction_spec.rb @@ -4,75 +4,75 @@ describe SEPA::Transaction do describe :new do it 'should have default for reference' do - SEPA::Transaction.new.reference.should == 'NOTPROVIDED' + expect(SEPA::Transaction.new.reference).to eq('NOTPROVIDED') end it 'should have default for requested_date' do - SEPA::Transaction.new.requested_date.should == Date.today.next + expect(SEPA::Transaction.new.requested_date).to eq(Date.today.next) end it 'should have default for batch_booking' do - SEPA::Transaction.new.batch_booking.should == true + expect(SEPA::Transaction.new.batch_booking).to eq(true) end end context 'Name' do it 'should accept valid value' do - SEPA::Transaction.should accept('Manfred Mustermann III.', 'Zahlemann & Söhne GbR', 'X' * 70, for: :name) + expect(SEPA::Transaction).to accept('Manfred Mustermann III.', 'Zahlemann & Söhne GbR', 'X' * 70, for: :name) end it 'should not accept invalid value' do - SEPA::Transaction.should_not accept(nil, '', 'X' * 71, for: :name) + expect(SEPA::Transaction).not_to accept(nil, '', 'X' * 71, for: :name) end end context 'IBAN' do it 'should accept valid value' do - SEPA::Transaction.should accept('DE21500500009876543210', 'PL61109010140000071219812874', for: :iban) + expect(SEPA::Transaction).to accept('DE21500500009876543210', 'PL61109010140000071219812874', for: :iban) end it 'should not accept invalid value' do - SEPA::Transaction.should_not accept(nil, '', 'invalid', for: :iban) + expect(SEPA::Transaction).not_to accept(nil, '', 'invalid', for: :iban) end end context 'BIC' do it 'should accept valid value' do - SEPA::Transaction.should accept('DEUTDEFF', 'DEUTDEFF500', 'SPUEDE2UXXX', for: :bic) + expect(SEPA::Transaction).to accept('DEUTDEFF', 'DEUTDEFF500', 'SPUEDE2UXXX', for: :bic) end it 'should not accept invalid value' do - SEPA::Transaction.should_not accept('', 'invalid', for: :bic) + expect(SEPA::Transaction).not_to accept('', 'invalid', for: :bic) end end context 'Amount' do it 'should accept valid value' do - SEPA::Transaction.should accept(0.01, 1, 100, 100.00, 99.99, 1234567890.12, BigDecimal('10'), '42', '42.51', '42.512', 1.23456, for: :amount) + expect(SEPA::Transaction).to accept(0.01, 1, 100, 100.00, 99.99, 1234567890.12, BigDecimal('10'), '42', '42.51', '42.512', 1.23456, for: :amount) end it 'should not accept invalid value' do - SEPA::Transaction.should_not accept(nil, 0, -3, 'xz', for: :amount) + expect(SEPA::Transaction).not_to accept(nil, 0, -3, 'xz', for: :amount) end end context 'Reference' do it 'should accept valid value' do - SEPA::Transaction.should accept(nil, 'ABC-1234/78.0', 'X' * 35, for: :reference) + expect(SEPA::Transaction).to accept(nil, 'ABC-1234/78.0', 'X' * 35, for: :reference) end it 'should not accept invalid value' do - SEPA::Transaction.should_not accept('', 'X' * 36, for: :reference) + expect(SEPA::Transaction).not_to accept('', 'X' * 36, for: :reference) end end context 'Remittance information' do it 'should allow valid value' do - SEPA::Transaction.should accept(nil, 'Bonus', 'X' * 140, for: :remittance_information) + expect(SEPA::Transaction).to accept(nil, 'Bonus', 'X' * 140, for: :remittance_information) end it 'should not allow invalid value' do - SEPA::Transaction.should_not accept('', 'X' * 141, for: :remittance_information) + expect(SEPA::Transaction).not_to accept('', 'X' * 141, for: :remittance_information) end end end diff --git a/spec/validation_spec.rb b/spec/validation_spec.rb index 3ea050b..c1651b4 100644 --- a/spec/validation_spec.rb +++ b/spec/validation_spec.rb @@ -2,24 +2,24 @@ describe 'Credit Transfer Initiation' do it "should validate example file" do - File.read('spec/examples/pain.001.002.03.xml').should validate_against('pain.001.002.03.xsd') - File.read('spec/examples/pain.001.003.03.xml').should validate_against('pain.001.003.03.xsd') + expect(File.read('spec/examples/pain.001.002.03.xml')).to validate_against('pain.001.002.03.xsd') + expect(File.read('spec/examples/pain.001.003.03.xml')).to validate_against('pain.001.003.03.xsd') end it 'should not validate dummy string' do - 'foo'.should_not validate_against('pain.001.002.03.xsd') - 'foo'.should_not validate_against('pain.001.003.03.xsd') + expect('foo').not_to validate_against('pain.001.002.03.xsd') + expect('foo').not_to validate_against('pain.001.003.03.xsd') end end describe 'Direct Debit Initiation' do it 'should validate example file' do - File.read('spec/examples/pain.008.002.02.xml').should validate_against('pain.008.002.02.xsd') - File.read('spec/examples/pain.008.003.02.xml').should validate_against('pain.008.003.02.xsd') + expect(File.read('spec/examples/pain.008.002.02.xml')).to validate_against('pain.008.002.02.xsd') + expect(File.read('spec/examples/pain.008.003.02.xml')).to validate_against('pain.008.003.02.xsd') end it 'should not validate dummy string' do - 'foo'.should_not validate_against('pain.008.002.02.xsd') - 'foo'.should_not validate_against('pain.008.003.02.xsd') + expect('foo').not_to validate_against('pain.008.002.02.xsd') + expect('foo').not_to validate_against('pain.008.003.02.xsd') end end diff --git a/spec/validator_spec.rb b/spec/validator_spec.rb index b4d23d6..582c89a 100644 --- a/spec/validator_spec.rb +++ b/spec/validator_spec.rb @@ -10,11 +10,11 @@ class Validatable end it 'should accept valid IBAN' do - Validatable.should accept('DE21500500009876543210', 'DE87200500001234567890', for: [:iban, :iban_the_terrible]) + expect(Validatable).to accept('DE21500500009876543210', 'DE87200500001234567890', for: [:iban, :iban_the_terrible]) end it 'should not accept an invalid IBAN' do - Validatable.should_not accept('', 'xxx', 'DE22500500009876543210', 'DE2150050000987654321', for: [:iban, :iban_the_terrible]) + expect(Validatable).not_to accept('', 'xxx', 'DE22500500009876543210', 'DE2150050000987654321', for: [:iban, :iban_the_terrible]) end end @@ -27,11 +27,11 @@ class Validatable end it 'should accept valid BICs' do - Validatable.should accept('DEUTDEDBDUE', 'DUSSDEDDXXX', for: [:bic, :custom_bic]) + expect(Validatable).to accept('DEUTDEDBDUE', 'DUSSDEDDXXX', for: [:bic, :custom_bic]) end it 'should not accept an invalid BIC' do - Validatable.should_not accept('', 'GENODE61HR', 'DEUTDEDBDUEDEUTDEDBDUE', for: [:bic, :custom_bic]) + expect(Validatable).not_to accept('', 'GENODE61HR', 'DEUTDEDBDUEDEUTDEDBDUE', for: [:bic, :custom_bic]) end end @@ -44,11 +44,11 @@ class Validatable end it 'should accept valid creditor_identifier' do - Validatable.should accept('DE98ZZZ09999999999', 'AT12ZZZ00000000001', 'FR12ZZZ123456', 'NL97ZZZ123456780001', for: [:creditor_identifier, :crid]) + expect(Validatable).to accept('DE98ZZZ09999999999', 'AT12ZZZ00000000001', 'FR12ZZZ123456', 'NL97ZZZ123456780001', for: [:creditor_identifier, :crid]) end it 'should not accept an invalid creditor_identifier' do - Validatable.should_not accept('', 'xxx', 'DE98ZZZ099999999990', for: [:creditor_identifier, :crid]) + expect(Validatable).not_to accept('', 'xxx', 'DE98ZZZ099999999990', for: [:creditor_identifier, :crid]) end end @@ -61,10 +61,10 @@ class Validatable end it 'should accept valid mandate_identifier' do - Validatable.should accept('XYZ-123', "+?/-:().,'", 'X' * 35, for: [:mandate_id, :mid]) + expect(Validatable).to accept('XYZ-123', "+?/-:().,'", 'X' * 35, for: [:mandate_id, :mid]) end it 'should not accept an invalid mandate_identifier' do - Validatable.should_not accept(nil, '', 'X' * 36, 'ABC 123', '#/*', 'Ümläüt', for: [:mandate_id, :mid]) + expect(Validatable).not_to accept(nil, '', 'X' * 36, 'ABC 123', '#/*', 'Ümläüt', for: [:mandate_id, :mid]) end end