<commit_before>require File.dirname(__FILE__) + '/../spec_helper'

describe Author do

  should_allow_values_for :name, "<NAME>", :allow_nil => true
  should_validate_length_of :name, :minimum => 2, :maximum => 255
  should_allow_values_for :email, "<EMAIL>", :allow_nil => true
  should_not_allow_values_for :email, "test", "test@test", "test@"
  should_have_many :versions

  it "should have unique values for email scoped on name" do
    Author.new_from_string("<NAME> <<EMAIL>>")
    validate_uniqueness_of :email, :scope => :name, :case_sensitive => false
  end

  it "should create new from string" do
    Author.should_receive(:find_or_create_by_name).with("Unknown")
    Author.new_from_string("")

    Author.should_receive(:find_or_create).with("<NAME>", nil)
    Author.new_from_string("<NAME>")

    Author.should_receive(:find_or_create).with(nil, "<EMAIL>")
    Author.new_from_string("<EMAIL>")

    Author.should_receive(:find_or_create).with("<NAME>", "<EMAIL>")
    Author.new_from_string("<NAME> <<EMAIL>>")
  end

end<commit_msg>Update spec to reflect changes in Author model<commit_after>require File.dirname(__FILE__) + '/../spec_helper'

describe Author do

  should_allow_values_for :name, "<NAME>", :allow_nil => true
  should_validate_length_of :name, :minimum => 2, :maximum => 255
  should_allow_values_for :email, "<EMAIL>", :allow_nil => true
  should_have_many :versions

  it "should have unique values for email scoped on name" do
    Author.new_from_string("<NAME> <<EMAIL>>")
    validate_uniqueness_of :email, :scope => :name, :case_sensitive => false
  end

  it "should create new from string" do
    Author.should_receive(:find_or_create_by_name).with("Unknown")
    Author.new_from_string("")

    Author.should_receive(:find_or_create).with("<NAME>", nil)
    Author.new_from_string("<NAME>")

    Author.should_receive(:find_or_create).with(nil, "<EMAIL>")
    Author.new_from_string("<EMAIL>")

    Author.should_receive(:find_or_create).with("<NAME>", "<EMAIL>")
    Author.new_from_string("<NAME> <<EMAIL>>")
  end

end
{'fraction_non_alphanumeric': 0.14825581395348839, 'fraction_numerical': 0.003875968992248062, 'mean_word_length': 5.433021806853582, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 43, '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': '3365644', 'n_tokens_mistral': 702, 'n_tokens_neox': 672, 'n_words': 141}