<commit_before>RSpec.describe Metasploit::Cache::Exploit::Instance::Ephemeral do
  context 'resurrecting attributes' do
    context '#exploit_instance' do
      subject(:exploit_instance) {
        exploit_instance_ephemeral.exploit_instance
      }

      #
      # lets
      #

      let(:exploit_instance_ephemeral) {
        described_class.new(
            exploit_metasploit_module_instance: exploit_metasploit_module_instance
        )
      }

      let(:metasploit_class) {
        double(
            'exploit Metasploit Module class',
            ephemeral_cache_by_source: {},
            real_path_sha1_hex_digest: existing_exploit_instance.exploit_class.ancestor.real_path_sha1_hex_digest
        )
      }

      let(:exploit_metasploit_module_instance) {
        double('exploit Metasploit Module instance').tap { |instance|
          allow(instance).to receive(:class).and_return(metasploit_class)
        }
      }

      #
      # let!s
      #

      let!(:existing_exploit_instance) {
        FactoryGirl.create(:metasploit_cache_exploit_instance)
      }

      #
      # Callbacks
      #

      before(:each) do
        metasploit_class.ephemeral_cache_by_source[:ancestor] = metasploit_class
      end

      it { is_expected.to be_a Metasploit::Cache::Exploit::Instance }

      it 'has #exploit_class matching pre-existing Metasploit::Cache::Exploit::Class' do
        expect(exploit_instance.exploit_class).to eq(existing_exploit_instance.exploit_class)
      end
    end
  end

  context 'validations' do
    it { is_expected.to validate_presence_of(:logger) }
    it { is_expected.to validate_presence_of(:exploit_metasploit_module_instance) }
  end

  context '#persist' do
    subject(:persist) {
      exploit_instance_ephemeral.persist(*args)
    }

    let(:exploit_instance_ephemeral) {
      described_class.new(
          logger: logger,
          exploit_metasploit_module_instance: exploit_metasploit_module_instance
      )
    }

    let(:exploit_metasploit_module_instance) {
      double('exploit Metasploit Module instance').tap { |instance|
        allow(instance).to receive(:class).and_return(metasploit_class)

        architecture_abbreviation = FactoryGirl.generate :metasploit_cache_architecture_abbreviation

        allow(instance).to receive(:arch).and_return([architecture_abbreviation])

        author = double('Metasploit Module instance author')
        author_name = FactoryGirl.generate :metasploit_cache_author_name
        email_address_domain = FactoryGirl.generate :metasploit_cache_email_address_domain
        email_address_local = FactoryGirl.generate :metasploit_cache_email_address_local
        email_address_full = "#{email_address_local}@#{email_address_domain}"

        allow(author).to receive(:name).and_return(author_name)
        allow(author).to receive(:email).and_return(email_address_full)

        allow(instance).to receive(:author).and_return([author])

        allow(instance).to receive(:default_target).and_return(nil)

        description = FactoryGirl.generate :metasploit_cache_exploit_instance_description

        allow(instance).to receive(:description).and_return(description)

        name = FactoryGirl.generate :metasploit_cache_exploit_instance_name

        allow(instance).to receive(:name).and_return(name)

        license_abbreviation = FactoryGirl.generate :metasploit_cache_license_abbreviation

        allow(instance).to receive(:license).and_return(license_abbreviation)

        platform = double('Platform', realname: 'Windows XP')
        platform_list = double('Platform List', platforms: [platform])
<commit_msg>Add missing stub for disclosure_date<commit_after>RSpec.describe Metasploit::Cache::Exploit::Instance::Ephemeral do
  context 'resurrecting attributes' do
    context '#exploit_instance' do
      subject(:exploit_instance) {
        exploit_instance_ephemeral.exploit_instance
      }

      #
      # lets
      #

      let(:exploit_instance_ephemeral) {
        described_class.new(
            exploit_metasploit_module_instance: exploit_metasploit_module_instance
        )
      }

      let(:metasploit_class) {
        double(
            'exploit Metasploit Module class',
            ephemeral_cache_by_source: {},
            real_path_sha1_hex_digest: existing_exploit_instance.exploit_class.ancestor.real_path_sha1_hex_digest
        )
      }

      let(:exploit_metasploit_module_instance) {
        double('exploit Metasploit Module instance').tap { |instance|
          allow(instance).to receive(:class).and_return(metasploit_class)
        }
      }

      #
      # let!s
      #

      let!(:existing_exploit_instance) {
        FactoryGirl.create(:metasploit_cache_exploit_instance)
      }

      #
      # Callbacks
      #

      before(:each) do
        metasploit_class.ephemeral_cache_by_source[:ancestor] = metasploit_class
      end

      it { is_expected.to be_a Metasploit::Cache::Exploit::Instance }

      it 'has #exploit_class matching pre-existing Metasploit::Cache::Exploit::Class' do
        expect(exploit_instance.exploit_class).to eq(existing_exploit_instance.exploit_class)
      end
    end
  end

  context 'validations' do
    it { is_expected.to validate_presence_of(:logger) }
    it { is_expected.to validate_presence_of(:exploit_metasploit_module_instance) }
  end

  context '#persist' do
    subject(:persist) {
      exploit_instance_ephemeral.persist(*args)
    }

    let(:exploit_instance_ephemeral) {
      described_class.new(
          logger: logger,
          exploit_metasploit_module_instance: exploit_metasploit_module_instance
      )
    }

    let(:exploit_metasploit_module_instance) {
      double('exploit Metasploit Module instance').tap { |instance|
        allow(instance).to receive(:class).and_return(metasploit_class)

        architecture_abbreviation = FactoryGirl.generate :metasploit_cache_architecture_abbreviation

        allow(instance).to receive(:arch).and_return([architecture_abbreviation])

        author = double('Metasploit Module instance author')
        author_name = FactoryGirl.generate :metasploit_cache_author_name
        email_address_domain = FactoryGirl.generate :metasploit_cache_email_address_domain
        email_address_local = FactoryGirl.generate :metasploit_cache_email_address_local
        email_address_full = "#{email_address_local}@#{email_address_domain}"

        allow(author).to receive(:name).and_return(author_name)
        allow(author).to receive(:email).and_return(email_address_full)

        allow(instance).to receive(:author).and_return([author])

        allow(instance).to receive(:default_target).and_return(nil)

        description = FactoryGirl.generate :metasploit_cache_exploit_instance_description

        allow(instance).to receive(:description).and_return(description)

        allow(instance).to receive(:disclosure_date).and_return(Date.today)

        name = FactoryGirl.generate :metasploit_cache_exploit_instance_name

        allow(instance).to receive(:name).and_return(name)

        license_abbreviation = FactoryGirl.generate :metasploit_cache_license_abbreviation

        allow(instance).to receive(:license).and_return(license_abbreviation)

        platform = double('Platform', realname: 'Windows XP')
        platform_list = double('Platform List', platforms: [platform])

{'fraction_non_alphanumeric': 0.08698015765153574, 'fraction_numerical': 0.0005436259853220984, 'mean_word_length': 3.5679702048417132, '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': '3633767', 'n_tokens_mistral': 2346, 'n_tokens_neox': 2180, 'n_words': 290}