<commit_before>require 'rails_helper'

RSpec.describe "Character Abilities" do
  it "should compare the abilities to the character for duplicates and pass" do
    user = Fabricate(:user)
    user.confirm!
    dd_class = Fabricate(:dd_class)
    race = Fabricate(:race)
    character = Character.new(user: user, dd_class: dd_class, race: race)
    selected_scores = {
      str: "11",
      dex: "12",
      const: "13",
      int: "14",
      wis: "15",
      cha: "16"
    }
    generated_scores = [11, 12, 13, 14, 15, 16]
    character.selected = selected_scores
    character.generated = generated_scores
    (character.update_attributes(selected_scores)).should == true
  end

  it "should compare the abilities to the character and fail because of greedy user" do
    pending "update attributes not working"
    user = Fabricate(:user)
    user.confirm!
    dd_class = Fabricate(:dd_class)
    race = Fabricate(:race)
    character = Character.new(user: user, dd_class: dd_class, race: race)
    selected_scores = {
      str: "16",
      dex: "16",
      const: "16",
      int: "16",
      wis: "16",
      cha: "16"
    }
    generated_scores = [11, 12, 13, 14, 15, 16]
    character.selected = selected_scores
    character.generated = generated_scores
    (character.update_attributes(selected_scores)).should_not eq true
  end

  it "should compare the abilities to the character and fail because of unfinished selection" do
    pending "update attributes not working"
    user = Fabricate(:user)
    user.confirm!
    dd_class = Fabricate(:dd_class)
    race = Fabricate(:race)
    character = Character.new(user: user, dd_class: dd_class, race: race)
    selected_scores = {
      "str" => "11",
      "dex" => "12",
      "const" => "13",
      "int" => "",
      "wis" => "",
      "cha" => ""
    }
    generated_scores = [11, 12, 13, 14, 15, 16]
    character.selected = selected_scores
    character.generated = generated_scores
    (character.update_attributes(selected_scores)).should_not eq true
  end
end<commit_msg>Refactored Character tests for more specific validation<commit_after>require 'rails_helper'

RSpec.describe "Character Abilities" do
  it "should compare the abilities to the character for duplicates and pass" do
    user = Fabricate(:user)
    user.confirm!
    dd_class = Fabricate(:dd_class)
    race = Fabricate(:race)
    character = Character.new(user: user, dd_class: dd_class, race: race)
    selected_scores = {
      str: "11",
      dex: "12",
      const: "13",
      int: "14",
      wis: "15",
      cha: "16"
    }
    generated_scores = [11, 12, 13, 14, 15, 16]
    character.selected = selected_scores
    character.generated = generated_scores
    (character.update_attributes(selected_scores)).should == true
  end

  it "should compare the abilities to the character and fail because of greedy user" do
    user = Fabricate(:user)
    user.confirm!
    dd_class = Fabricate(:dd_class)
    race = Fabricate(:race)
    character = Character.new(user: user, dd_class: dd_class, race: race)
    selected_scores = {
      str: "16",
      dex: "16",
      const: "16",
      int: "16",
      wis: "16",
      cha: "16"
    }
    generated_scores = [11, 12, 13, 14, 15, 16]
    character.selected = selected_scores
    character.generated = generated_scores
    (character.send :abilities_match?, selected_scores, generated_scores).should_not eq true
  end

  it "should compare the abilities to the character and fail because of unfinished selection" do
    user = Fabricate(:user)
    user.confirm!
    dd_class = Fabricate(:dd_class)
    race = Fabricate(:race)
    character = Character.new(user: user, dd_class: dd_class, race: race)
    selected_scores = {
      "str" => "11",
      "dex" => "12",
      "const" => "13",
      "int" => "",
      "wis" => "",
      "cha" => ""
    }
    generated_scores = [11, 12, 13, 14, 15, 16]
    character.selected = selected_scores
    character.generated = generated_scores
    (character.send :abilities_selected?, selected_scores).should_not eq true
  end
end
{'fraction_non_alphanumeric': 0.11745875400147747, 'fraction_numerical': 0.03250430928342773, 'mean_word_length': 3.062, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, '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': '218228', 'n_tokens_mistral': 1426, 'n_tokens_neox': 1258, 'n_words': 364}