<commit_before>module SpecFeatureHelper
  # if given a user, the password must be '<PASSWORD>' or given as a parameter
  # otherwise, the helper will create a user with a given password
  # returns the user it logs in as, navigates to root_path
  def login(user = nil, password = '<PASSWORD>')
    user ||= create(:user, password: password)
    visit root_path
    fill_in "Username", with: user.username
    fill_in "Password", with: password
    click_button "Log in"
    user
  end

  def row_for(title)
    find('tr') { |x| x.has_selector?('th', text: title) }
  end
end<commit_msg>Add error in tests if login fails<commit_after>module SpecFeatureHelper
  # if given a user, the password must be '<PASSWORD>' or given as a parameter
  # otherwise, the helper will create a user with a given password
  # returns the user it logs in as, navigates to root_path
  def login(user = nil, password = '<PASSWORD>')
    user ||= create(:user, password: password)
    visit root_path
    fill_in "Username", with: user.username
    fill_in "Password", with: password
    click_button "Log in"
    if page.all('.flash.error').present?
      raise(RuntimeError, "Failed to log in as '#{user.username}':\n" + page.find('.flash.error').text)
    end
    user
  end

  def row_for(title)
    find('tr') { |x| x.has_selector?('th', text: title) }
  end
end
{'fraction_non_alphanumeric': 0.11078066914498141, 'fraction_numerical': 0.0, 'mean_word_length': 3.6898954703832754, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '3728745', 'n_tokens_mistral': 413, 'n_tokens_neox': 410, 'n_words': 156}