Sha256: 9654186b1943e923c0693760dfc391af2b87e4c051637fdc8d09c3248914096f

Contents?: true

Size: 1.83 KB

Versions: 1

Compression:

Stored size: 1.83 KB

Contents

describe Unidom::Category::Category, type: :model do

  before :each do
  end

  after :each do
  end

  context do

    model_attributes = {
      scheme_id:    SecureRandom.uuid,
      code:         'XC',
      name:         'Top Category',
      abbreviation: 'TopCat'
    }

    name_max_length         = described_class.columns_hash['name'].limit
    abbreviation_max_length = described_class.columns_hash['abbreviation'].limit

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

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

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

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
unidom-category-1.6.1 lib/rspec/models/unidom/category/category_spec.rb