<commit_before>require 'spec_helper'

describe UserRole do
  context 'with casual stats' do
    let(:casual_stats) {
      instance_double(Stats,
        commit_count_user: 1,
        commit_count_total: 100,
        commits_authored_percentage: 1,
        contribution_rank_by_commits: 100,
        total_contributors: 100,
        tier: 100,
      )
    }

    it 'reports "Casual Contributor"' do
      expect(UserRole.new(casual_stats).to_s).to match /casual/i
    end
  end

  context 'with top tier stats' do
    let(:top_tier_stats) {
      instance_double(Stats,
        commit_count_user: 9,
        commit_count_total: 100,
        commits_authored_percentage: 9,
        contribution_rank_by_commits: 4,
        total_contributors: 100,
        tier: 5,
      )<commit_msg>Suppress warnings caused by Adamantium + instance_double interaction<commit_after>require 'spec_helper'

describe UserRole do
  around do |example|
    # warnings caused by Adamantium trying to freeze an instance_double
    Kernel::silence_warnings(&example)
  end

  context 'with casual stats' do
    let(:casual_stats) {
      instance_double(Stats,
        commit_count_user: 1,
        commit_count_total: 100,
        commits_authored_percentage: 1,
        contribution_rank_by_commits: 100,
        total_contributors: 100,
        tier: 100,
      )
    }

    it 'reports "Casual Contributor"' do
      expect(UserRole.new(casual_stats).to_s).to match /casual/i
    end
  end

  context 'with top tier stats' do
    let(:top_tier_stats) {
      instance_double(Stats,
        commit_count_user: 9,
        commit_count_total: 100,
        commits_authored_percentage: 9,
        contribution_rank_by_commits: 4,
        total_contributors: 100,
        tier: 5,
      )
{'fraction_non_alphanumeric': 0.07430516165626773, 'fraction_numerical': 0.027226318774815655, 'mean_word_length': 2.73728813559322, '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': '2987609', 'n_tokens_mistral': 618, 'n_tokens_neox': 553, 'n_words': 128}