<commit_before>require 'rails_helper'

describe Repository, :type => :model do
  describe 'validations' do
    it { is_expected.to validate_presence_of(:name) }
    it { is_expected.to validate_presence_of(:address) }
    it { is_expected.to validate_presence_of(:configuration_id) }
    it { is_expected.to validate_presence_of(:project_id) }
    it { is_expected.to validate_uniqueness_of(:name).scoped_to(:project_id).with_message(/should be unique within project/) }
  end

  describe 'associations' do
    it { is_expected.to belong_to(:project)}
    it { is_expected.to have_many(:processings)}
  end

  describe 'methods' do
    describe 'supported_types' do
      before :each do
        Downloaders::GitDownloader.expects(:available?).at_least_once.returns(true)
        Downloaders::SvnDownloader.expects(:available?).at_least_once.returns(true)
      end

      it 'should add available repository types to supported_types and return them' do
        expect(Repository.supported_types).to include("GIT")
        expect(Repository.supported_types).to include(:SVN)
      end
    end

    describe 'configuration' do
      subject { FactoryGirl.build(:repository) }

      it 'should call the Gatekeeper Configuration' do
        KalibroGatekeeperClient::Entities::Configuration.expects(:find).twice.with(subject.configuration_id).returns(subject.configuration)
        subject.configuration
      end
    end

    describe 'configuration=' do
      subject { FactoryGirl.build(:repository) }
      let(:configuration) { FactoryGirl.build(:another_configuration) }

      it 'should call the Gatekeeper Configuration' do
        subject.configuration = configuration
        expect(subject.configuration_id).to eq(configuration.id)
      end
    end

    describe 'process' do
      it 'is expected to raise a NotImplementedError' do
        expect{ subject.process }.to raise_error(NotImplementedError)
      end
    end
  end
end<commit_msg>repository spec fixed for SVN<commit_after>require 'rails_helper'

describe Repository, :type => :model do
  describe 'validations' do
    it { is_expected.to validate_presence_of(:name) }
    it { is_expected.to validate_presence_of(:address) }
    it { is_expected.to validate_presence_of(:configuration_id) }
    it { is_expected.to validate_presence_of(:project_id) }
    it { is_expected.to validate_uniqueness_of(:name).scoped_to(:project_id).with_message(/should be unique within project/) }
  end

  describe 'associations' do
    it { is_expected.to belong_to(:project)}
    it { is_expected.to have_many(:processings)}
  end

  describe 'methods' do
    describe 'supported_types' do
      before :each do
        Downloaders::GitDownloader.expects(:available?).at_least_once.returns(true)
        Downloaders::SvnDownloader.expects(:available?).at_least_once.returns(true)
      end

      it 'should add available repository types to supported_types and return them' do
        expect(Repository.supported_types).to include("GIT")
        expect(Repository.supported_types).to include("SVN")
      end
    end

    describe 'configuration' do
      subject { FactoryGirl.build(:repository) }

      it 'should call the Gatekeeper Configuration' do
        KalibroGatekeeperClient::Entities::Configuration.expects(:find).twice.with(subject.configuration_id).returns(subject.configuration)
        subject.configuration
      end
    end

    describe 'configuration=' do
      subject { FactoryGirl.build(:repository) }
      let(:configuration) { FactoryGirl.build(:another_configuration) }

      it 'should call the Gatekeeper Configuration' do
        subject.configuration = configuration
        expect(subject.configuration_id).to eq(configuration.id)
      end
    end

    describe 'process' do
      it 'is expected to raise a NotImplementedError' do
        expect{ subject.process }.to raise_error(NotImplementedError)
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.09002805406783984, 'fraction_numerical': 0.0, 'mean_word_length': 3.7310012062726177, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3805564', 'n_tokens_mistral': 1114, 'n_tokens_neox': 1077, 'n_words': 253}