<commit_before>describe Unidom::Certificate::China::BusinessLicense, type: :model do

  before :each do
  end

  after :each do
  end

  context do

    model_attributes = {
      registration_number:              '123456789012345',
      unified_social_credit_identifier: '123456789012345678',
      name:                             '<NAME>.',
      address:                          '#305, Building #n, #n Some Street, Some City',
      legal_representative_name:        'YiDa',
      issuing_authority_name:           'Some City PS Department',
      validity_from_date:               Date.current-10.years,
      validity_thru_date:               Date.current+10.years
    }

    registration_number_max_length              = described_class.columns_hash['registration_number'].limit
    unified_social_credit_identifier_max_length = described_class.columns_hash['unified_social_credit_identifier'].limit

    it_behaves_like 'Unidom::Common::Concerns::ModelExtension', model_attributes

    it_behaves_like 'validates', model_attributes, :registration_number,
      {                            } => 0,
      { registration_number: nil   } => 0,
      { registration_number: ''    } => 0,
      { registration_number: '1'   } => 2,
      { registration_number: 'A'   } => 3,
      { registration_number: '11'  } => 2,
      { registration_number: 'AA'  } => 3,
      { registration_number: '111' } => 2,
      { registration_number: 'AAA' } => 3,
      { registration_number: '1'*(registration_number_max_length-1) } => 2,
      { registration_number: 'A'*(registration_number_max_length-1) } => 3,
      { registration_number: '1'*registration_number_max_length     } => 0,
      { registration_number: 'A'*registration_number_max_length     } => 2,
      { registration_number: '1'*(registration_number_max_length+1) } => 2,
      { registration_number: 'A'*(registration_number_max_length+1) } => 3

    it_behaves_like 'validates', model_attributes, :unified_social_credit_identifier,
      {                                         } => 0,
      { unified_social_credit_identifier: nil   } => 0,
      { unified_social_credit_identifier: ''    } => 0,
      { unified_social_credit_identifier: '1'   } => 1,
      { unified_social_credit_identifier: 'A'   } => 1,
      { unified_social_credit_identifier: '11'  } => 1,
      { unified_social_credit_identifier: 'AA'  } => 1,
      { unified_social_credit_identifier: '111' } => 1,
      { unified_social_credit_identifier: 'AAA' } => 1,
      { unified_social_credit_identifier: '1'*(unified_social_credit_identifier_max_length-1) } => 1,
      { unified_social_credit_identifier: 'A'*(unified_social_credit_identifier_max_length-1) } => 1,
      { unified_social_credit_identifier: '1'*unified_social_credit_identifier_max_length     } => 0,
      { unified_social_credit_identifier: 'A'*unified_social_credit_identifier_max_length     } => 0,
      { unified_social_credit_identifier: '1'*(unified_social_credit_identifier_max_length+1) } => 1,
      { unified_social_credit_identifier: 'A'*(unified_social_credit_identifier_max_length+1) } => 1

  end

end<commit_msg>1, Improve the Business License spec for the validations on the #name attribute, & the #address attribute.<commit_after>describe Unidom::Certificate::China::BusinessLicense, type: :model do

  before :each do
  end

  after :each do
  end

  context do

    model_attributes = {
      registration_number:              '123456789012345',
      unified_social_credit_identifier: '123456789012345678',
      name:                             '<NAME>.',
      address:                          '#305, Building #n, #n Some Street, Some City',
      legal_representative_name:        'YiDa',
      issuing_authority_name:           'Some City PS Department',
      validity_from_date:               Date.current-10.years,
      validity_thru_date:               Date.current+10.years
    }

    registration_number_max_length              = described_class.columns_hash['registration_number'].limit
    unified_social_credit_identifier_max_length = described_class.columns_hash['unified_social_credit_identifier'].limit

    it_behaves_like 'Unidom::Common::Concerns::ModelExtension', model_attributes

    it_behaves_like 'validates', model_attributes, :registration_number,
      {                            } => 0,
      { registration_number: nil   } => 0,
      { registration_number: ''    } => 0,
      { registration_number: '1'   } => 2,
      { registration_number: 'A'   } => 3,
      { registration_number: '11'  } => 2,
      { registration_number: 'AA'  } => 3,
      { registration_number: '111' } => 2,
      { registration_number: 'AAA' } => 3,
      { registration_number: '1'*(registration_number_max_length-1) } => 2,
      { registration_number: 'A'*(registration_number_max_length-1) } => 3,
      { registration_number: '1'*registration_number_max_length     } => 0,
      { registration_number: 'A'*registration_number_max_length     } => 2,
      { registration_number: '1'*(registration_number_max_length+1) } => 2,
      { registration_number: 'A'*(registration_number_max_length+1) } => 3

    it_behaves_like 'validates', model_attributes, :unified_social_credit_identifier,
      {                                         } => 0,
      { unified_social_credit_identifier: nil   } => 0,
      { unified_social_credit_identifier: ''    } => 0,
      { unified_social_credit_identifier: '1'   } => 1,
      { unified_social_credit_identifier: 'A'   } => 1,
      { unified_social_credit_identifier: '11'  } => 1,
      { unified_social_credit_identifier: 'AA'  } => 1,
      { unified_social_credit_identifier: '111' } => 1,
      { unified_social_credit_identifier: 'AAA' } => 1,
      { unified_social_credit_identifier: '1'*(unified_social_credit_identifier_max_length-1) } => 1,
      { unified_social_credit_identifier: 'A'*(unified_social_credit_identifier_max_length-1) } => 1,
      { unified_social_credit_identifier: '1'*unified_social_credit_identifier_max_length     } => 0,
      { unified_social_credit_identifier: 'A'*unified_social_credit_identifier_max_length     } => 0,
      { unified_social_credit_identifier: '1'*(unified_social_credit_identifier_max_length+1) } => 1,
      { unified_social_credit_identifier: 'A'*(unified_social_credit_identifier_max_length+1) } => 1

    it_behaves_like 'validates text', model_attributes, :name,    length: 2..described_class.columns_hash['name'].limit
    it_behaves_like 'validates text', model_attributes, :address, length: 2..described_class.columns_hash['address'].limit

  end

end
{'fraction_non_alphanumeric': 0.11388762683628653, 'fraction_numerical': 0.029532030895047707, 'mean_word_length': 3.2010178117048347, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 65, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '532814', 'n_tokens_mistral': 2239, 'n_tokens_neox': 1980, 'n_words': 314}