<commit_before>require "rails_helper"

describe Repository do
  describe ".all" do
    it "returns a list of repositories" do
      VCR.use_cassette("repository/all") do
        list = Repository.list
        repo = list.first
        expect(list).to be_instance_of Collection
        expect(repo).to be_instance_of Repository
        expect(repo.name).to eq "image1"
      end
    end
  end

  describe ".find" do
    let(:name) { "randomguy1/image1" }

    it "returns one repository including tags on successful response" do
      VCR.use_cassette("repository/find_success") do
        repo = Repository.find name
        expect(repo).to be_instance_of Repository
        expect(repo.name).to eq name
        expect(repo.tags).to eq %w(latest)
      end
    end

    it "returns one returns without tags on 404 response" do
      VCR.use_cassette("repository/find_not_found") do
        repo = Repository.find name
        expect(repo).to be_instance_of Repository
        expect(repo.name).to eq name
        expect(repo.tags).to eq []
      end
    end
  end

  describe "#namespace" do
    subject { Repository.new(name: name) }

    context "when the name contains a namespace and image" do
      let(:name) { "randomguy1/image1" }

      it "returns just the namespace part" do
        expect(subject.namespace).to eq "randomguy1"
      end
    end

    context "when the name contains only a image" do
      let(:name)  { "image1" }
      let(:label) { "custom-label" }

      context "when a custom root label is passed" do
        it "returns the passed root label" do
          expect(subject.namespace label).to eq label
        end
      end<commit_msg>add test coverage for #8<commit_after>require "rails_helper"

describe Repository do
  describe ".all" do
    it "returns a list of repositories" do
      VCR.use_cassette("repository/all") do
        list = Repository.list
        repo = list.first
        expect(list).to be_instance_of Collection
        expect(repo).to be_instance_of Repository
        expect(repo.name).to eq "image1"
      end
    end
  end

  describe ".find" do
    let(:name) { "randomguy1/image1" }

    it "returns one repository including tags on successful response" do
      VCR.use_cassette("repository/find_success") do
        repo = Repository.find name
        expect(repo).to be_instance_of Repository
        expect(repo.name).to eq name
        expect(repo.tags).to eq %w(latest)
      end
    end

    it "returns one returns without tags on 404 response" do
      VCR.use_cassette("repository/find_not_found") do
        repo = Repository.find name
        expect(repo).to be_instance_of Repository
        expect(repo.name).to eq name
        expect(repo.tags).to eq []
      end
    end
  end

  describe "#namespace" do
    subject { Repository.new(name: name) }

    context "when the name contains a namespace and image" do
      let(:name) { "randomguy1/image1" }

      it "returns just the namespace part" do
        expect(subject.namespace).to eq "randomguy1"
      end
    end

    context "when the name contains a namespace (with slash) and image" do
      let(:name) { "department/randomguy1/image1" }

      it "returns just the namespace part" do
        expect(subject.namespace).to eq "department/randomguy1"
      end
    end

    context "when the name contains only a image" do
      let(:name)  { "image1" }
      let(:label) { "custom-label" }

      context "when a custom root label is passed" do
        it "returns the passed root label" do
          expect(subject.namespace label).to eq label
        end
      end
{'fraction_non_alphanumeric': 0.08523042754025541, 'fraction_numerical': 0.006662965019433648, 'mean_word_length': 2.464423076923077, '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': '6863252', 'n_tokens_mistral': 1083, 'n_tokens_neox': 1039, 'n_words': 339}