<commit_before>require 'rails_helper'

module Socializer
  RSpec.describe ActivityAudienceList, type: :service do
    describe 'when the activity argument is nil' do
      context '.new should raise an ArgumentError' do
        let(:audience_list) { ActivityAudienceList.new(activity: nil) }
        it { expect { audience_list }.to raise_error(ArgumentError) }
      end

      context '.perform should raise an ArgumentError' do
        let(:audience_list) { ActivityAudienceList.perform(activity: nil) }
        it { expect { audience_list }.to raise_error(ArgumentError) }
      end
    end

    describe 'when the activity argument is the wrong type' do
      let(:audience_list) { ActivityAudienceList.new(activity: Person.new) }
      it { expect { audience_list }.to raise_error(ArgumentError) }
    end

    describe '.perform' do
      let(:activity) { create(:socializer_activity) }
      let(:audience_list) { ActivityAudienceList.new(activity: activity).perform }

      it { expect(audience_list).to be_kind_of(Array) }
      it { expect(audience_list.size).to eq(1) }
      it { expect(audience_list.first).to start_with('name') }
    end
  end
end<commit_msg>add the 'without an audience' context<commit_after>require 'rails_helper'

module Socializer
  RSpec.describe ActivityAudienceList, type: :service do
    describe 'when the activity argument is nil' do
      context '.new should raise an ArgumentError' do
        let(:audience_list) { ActivityAudienceList.new(activity: nil) }
        it { expect { audience_list }.to raise_error(ArgumentError) }
      end

      context '.perform should raise an ArgumentError' do
        let(:audience_list) { ActivityAudienceList.perform(activity: nil) }
        it { expect { audience_list }.to raise_error(ArgumentError) }
      end
    end

    describe 'when the activity argument is the wrong type' do
      let(:audience_list) { ActivityAudienceList.new(activity: Person.new) }
      it { expect { audience_list }.to raise_error(ArgumentError) }
    end

    describe '.perform' do
      context 'without an audience' do
        let(:activity) { create(:socializer_activity) }
        let(:audience_list) { ActivityAudienceList.new(activity: activity).perform }

        it { expect(audience_list).to be_kind_of(Array) }
        it { expect(audience_list.size).to eq(1) }
        it { expect(audience_list.first).to start_with('name') }
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.09535552815454172, 'fraction_numerical': 0.0008220304151253596, 'mean_word_length': 3.3620071684587813, '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': '664968', 'n_tokens_mistral': 710, 'n_tokens_neox': 697, 'n_words': 188}