<commit_before># encoding: utf-8
require 'spec_helper'

describe SEPA::Transaction do
  describe :new do
    it 'should have default for reference' do
      expect(SEPA::Transaction.new.reference).to eq('NOTPROVIDED')
    end

    it 'should have default for requested_date' do
      expect(SEPA::Transaction.new.requested_date).to eq(Date.new(1999, 1, 1))
    end

    it 'should have default for batch_booking' do
      expect(SEPA::Transaction.new.batch_booking).to eq(true)
    end
  end

  context 'Name' do
    it 'should accept valid value' do
      expect(SEPA::Transaction).to accept('<NAME>.', 'Zahlemann & Söhne GbR', 'X' * 70, for: :name)
    end

    it 'should not accept invalid value' do
      expect(SEPA::Transaction).not_to accept(nil, '', 'X' * 71, for: :name)
    end
  end

  context 'Adress' do
    context 'with address_line' do
      it 'should accept valid value' do
        expect(SEPA::Transaction).to accept(SEPA::DebtorAddress.new(
          country_code: "CH",
          address_line1: "Musterstrasse 123",
          address_line2: "1234 Musterstadt"
        ), for: :debtor_address)
      end

      it 'should accept valid value' do
        expect(SEPA::Transaction).to accept(SEPA::CreditorAddress.new(
          country_code: "CH",
          address_line1: "Musterstrasse 123",
          address_line2: "1234 Musterstadt"
        ), for: :creditor_address)
      end
    end

    context 'with individual address fields' do
      it 'should accept valid value' do
        expect(SEPA::Transaction).to accept(SEPA::DebtorAddress.new(
          country_code: "CH",
          street_name:     'Mustergasse',
          building_number: '123',
          post_code:       '1234',
          town_name:       'Musterstadt'
        ), for: :debtor_address)
      end

      it 'should accept valid value' do<commit_msg>test: Fix typo in test context name<commit_after># encoding: utf-8
require 'spec_helper'

describe SEPA::Transaction do
  describe :new do
    it 'should have default for reference' do
      expect(SEPA::Transaction.new.reference).to eq('NOTPROVIDED')
    end

    it 'should have default for requested_date' do
      expect(SEPA::Transaction.new.requested_date).to eq(Date.new(1999, 1, 1))
    end

    it 'should have default for batch_booking' do
      expect(SEPA::Transaction.new.batch_booking).to eq(true)
    end
  end

  context 'Name' do
    it 'should accept valid value' do
      expect(SEPA::Transaction).to accept('<NAME>.', 'Zahlemann & <NAME>', 'X' * 70, for: :name)
    end

    it 'should not accept invalid value' do
      expect(SEPA::Transaction).not_to accept(nil, '', 'X' * 71, for: :name)
    end
  end

  context 'Address' do
    context 'with address_line' do
      it 'should accept valid value' do
        expect(SEPA::Transaction).to accept(SEPA::DebtorAddress.new(
          country_code: "CH",
          address_line1: "Musterstrasse 123",
          address_line2: "1234 Musterstadt"
        ), for: :debtor_address)
      end

      it 'should accept valid value' do
        expect(SEPA::Transaction).to accept(SEPA::CreditorAddress.new(
          country_code: "CH",
          address_line1: "Musterstrasse 123",
          address_line2: "1234 Musterstadt"
        ), for: :creditor_address)
      end
    end

    context 'with individual address fields' do
      it 'should accept valid value' do
        expect(SEPA::Transaction).to accept(SEPA::DebtorAddress.new(
          country_code: "CH",
          street_name:     'Mustergasse',
          building_number: '123',
          post_code:       '1234',
          town_name:       'Musterstadt'
        ), for: :debtor_address)
      end

      it 'should accept valid value' do
{'fraction_non_alphanumeric': 0.10700808625336927, 'fraction_numerical': 0.01940700808625337, 'mean_word_length': 2.6888667992047712, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4859093', 'n_tokens_mistral': 1205, 'n_tokens_neox': 1125, 'n_words': 318}