<commit_before>require 'rails_helper'

RSpec.describe Character, type: :model do
  describe "required validations" do
    it "is valid with a name and user_id" do
      character = Character.new(name: 'Bob', user_id: 1)
      expect(character).to be_valid
    end

    it "is invalid without a name" do
      character = Character.new(name: nil, user_id: 1)
      character.valid?
      expect(character.errors[:name]).to include("can't be blank")
    end

    it "is invalid without a user_id" do
      character = Character.new(name: 'Bob', user_id: nil)
      character.valid?
      expect(character.errors[:user_id]).to include("can't be blank")
    end
  end

  describe "bio length" do
    it "is valid with a bio under 4000 characters" do
      pending "implement"
      raise "fail"
    end

    it "is invalid with a bio over 4000 characters" do
      pending "implement"
      raise "fail"
    end
  end

  describe "traits length" do
    it "is valid with traits under 800 characters" do
      pending "implement"
      raise "fail"
    end

    it "is invalid with traits over 800 characters" do
      pending "implement"
      raise "fail"
    end
  end

  describe "sort" do
    it "returns a sorted array of characters by creation date" do
      pending "implement"
      raise "fail"
      #expect(Character.ordered).to eq []
    end
  end

end<commit_msg>fill in character model tests for bio and traits validations<commit_after>require 'rails_helper'

RSpec.describe Character, type: :model do
  describe "required validations" do
    it "is valid with a name and user_id" do
      character = Character.new(name: 'Bob', user_id: 1)
      expect(character).to be_valid
    end

    it "is invalid without a name" do
      character = Character.new(name: nil, user_id: 1)
      character.valid?
      expect(character.errors[:name]).to include("can't be blank")
    end

    it "is invalid without a user_id" do
      character = Character.new(name: 'Bob', user_id: nil)
      character.valid?
      expect(character.errors[:user_id]).to include("can't be blank")
    end
  end

  describe "bio length" do
    it "is valid with a bio under 4000 characters" do
      character = Character.new(name: 'Bob', user_id: 1, bio: Faker::Lorem.characters(3999))
      expect(character).to be_valid
    end

    it "is invalid with a bio over 4000 characters" do
      character = Character.new(name: 'Bob', user_id: 1, bio: Faker::Lorem.characters(4001))
      character.valid?
      expect(character.errors[:bio]).to include("is too long (maximum is 4000 characters)")
    end
  end

  describe "traits length" do
    it "is valid with traits under 800 characters" do
      character = Character.new(name: 'Bob', user_id: 1, traits: Faker::Lorem.characters(799))
      expect(character).to be_valid
    end

    it "is invalid with traits over 800 characters" do
      character = Character.new(name: 'Bob', user_id: 1, traits: Faker::Lorem.characters(801))
      character.valid?
      expect(character.errors[:traits]).to include("is too long (maximum is 800 characters)")
    end
  end

  describe "sort" do
    it "returns a sorted array of characters by creation date" do
      pending "implement"
      raise "fail"
      #expect(Character.ordered).to eq []
    end
  end

end
{'fraction_non_alphanumeric': 0.09601944697660286, 'fraction_numerical': 0.01731996353691887, 'mean_word_length': 2.9854721549636802, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '2620245', 'n_tokens_mistral': 1045, 'n_tokens_neox': 965, 'n_words': 354}