<commit_before>require 'rails_helper'

RSpec.describe 'Devise Mutil Email' do
  describe '.required_fields' do
    it 'does not raise any errors' do
      expect { Devise::Models.check_fields!(User) }.to_not raise_error
      expect { Devise::Models.check_fields!(Email) }.to_not raise_error
    end
  end

  describe 'Authenticatable' do
    context 'when emails association is not detected' do
      it 'raises an error' do
        expect do
          class UserWithoutEmail < ActiveRecord::Base
            self.table_name = 'users'

            devise :multi_email_authenticatable
          end
        end.to raise_error(RuntimeError)
      end
    end

    context 'when user association is not detected' do
      it 'raises an error' do
        expect do
          class EmailWithoutUser < ActiveRecord::Base
            self.table_name = 'emails'
          end

          class UserWithEmails < ActiveRecord::Base
            self.table_name = 'users'<commit_msg>Spec: Fix a typo in RSpec description (#47)<commit_after>require 'rails_helper'

RSpec.describe 'Devise Multi Email' do
  describe '.required_fields' do
    it 'does not raise any errors' do
      expect { Devise::Models.check_fields!(User) }.to_not raise_error
      expect { Devise::Models.check_fields!(Email) }.to_not raise_error
    end
  end

  describe 'Authenticatable' do
    context 'when emails association is not detected' do
      it 'raises an error' do
        expect do
          class UserWithoutEmail < ActiveRecord::Base
            self.table_name = 'users'

            devise :multi_email_authenticatable
          end
        end.to raise_error(RuntimeError)
      end
    end

    context 'when user association is not detected' do
      it 'raises an error' do
        expect do
          class EmailWithoutUser < ActiveRecord::Base
            self.table_name = 'emails'
          end

          class UserWithEmails < ActiveRecord::Base
            self.table_name = 'users'
{'fraction_non_alphanumeric': 0.06896551724137931, 'fraction_numerical': 0.0010141987829614604, 'mean_word_length': 2.437282229965157, 'pattern_counts': {'":': 0, '<': 9, '<?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': '3067333', 'n_tokens_mistral': 556, 'n_tokens_neox': 538, 'n_words': 172}