<commit_before>describe Unidom::Standard::Standard, type: :model do

  before :each do
  end

  after :each do
  end

  context do

    model_attributes = {
      name:         '<NAME>',
      number:       'GB/T 3259-2008',
      ics_code:     '11-23-68',
      published_on: Date.current-1.year,
      applied_on:   Date.current,
      obsoleted_on: Date.current+20.years
    }

    name_max_length   = described_class.columns_hash['name'].limit
    number_max_length = described_class.columns_hash['number'].limit

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

    it_behaves_like 'validates', model_attributes, :name,
      {             } => 0,
      { name: nil   } => 2,
      { name: ''    } => 2,
      { name: 'A'   } => 1,
      { name: 'AA'  } => 0,
      { name: 'AAA' } => 0,
      { name: 'A'*(name_max_length-1) } => 0,
      { name: 'A'*name_max_length     } => 0,
      { name: 'A'*(name_max_length+1) } => 1

    it_behaves_like 'validates', model_attributes, :number,
      {               } => 0,
      { number: nil   } => 2,
      { number: ''    } => 2,
      { number: 'A'   } => 1,
      { number: 'AA'  } => 0,
      { number: 'AAA' } => 0,
      { number: 'A'*(name_max_length-1) } => 0,
      { number: 'A'*name_max_length     } => 0,
      { number: 'A'*(name_max_length+1) } => 1

  end

end
<commit_msg>1, Improve the Standard spec for the number_is scope.<commit_after>describe Unidom::Standard::Standard, type: :model do

  before :each do
  end

  after :each do
  end

  context do

    model_attributes = {
      name:         '<NAME>',
      number:       'GB/T 3259-2008',
      ics_code:     '11-23-68',
      published_on: Date.current-1.year,
      applied_on:   Date.current,
      obsoleted_on: Date.current+20.years
    }

    name_max_length   = described_class.columns_hash['name'].limit
    number_max_length = described_class.columns_hash['number'].limit

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

    it_behaves_like 'validates', model_attributes, :name,
      {             } => 0,
      { name: nil   } => 2,
      { name: ''    } => 2,
      { name: 'A'   } => 1,
      { name: 'AA'  } => 0,
      { name: 'AAA' } => 0,
      { name: 'A'*(name_max_length-1) } => 0,
      { name: 'A'*name_max_length     } => 0,
      { name: 'A'*(name_max_length+1) } => 1

    it_behaves_like 'validates', model_attributes, :number,
      {               } => 0,
      { number: nil   } => 2,
      { number: ''    } => 2,
      { number: 'A'   } => 1,
      { number: 'AA'  } => 0,
      { number: 'AAA' } => 0,
      { number: 'A'*(name_max_length-1) } => 0,
      { number: 'A'*name_max_length     } => 0,
      { number: 'A'*(name_max_length+1) } => 1

    it_behaves_like 'scope', :number_is, [
      { attributes_collection: [ model_attributes                                                ], count_diff: 1, args: [ model_attributes[:number]       ] },
      { attributes_collection: [ model_attributes                                                ], count_diff: 0, args: [ "#{model_attributes[:number]}0" ] },
      { attributes_collection: [ model_attributes.merge(number: "#{model_attributes[:number]}0") ], count_diff: 0, args: [ model_attributes[:number]       ] },
      { attributes_collection: [ model_attributes.merge(number: "#{model_attributes[:number]}0") ], count_diff: 1, args: [ "#{model_attributes[:number]}0" ] } ]

  end

end

{'fraction_non_alphanumeric': 0.1620997980963369, 'fraction_numerical': 0.02509374098644361, 'mean_word_length': 2.2230483271375463, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 41, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2488351', 'n_tokens_mistral': 1269, 'n_tokens_neox': 1179, 'n_words': 225}