Sha256: 7df8524ec1e3f78c88f5ab6a4091be6557aca1963ad3b6060af9e6cd4c859d18

Contents?: true

Size: 1.22 KB

Versions: 1

Compression:

Stored size: 1.22 KB

Contents

require "spec_helper"

describe CompareLinker::GithubLinkFinder do
  let(:octokit) { double.as_null_object }

  subject { described_class.new(octokit) }


  describe "#find" do
    before do
      allow(HTTPClient).to receive(:get_content).and_return load_fixture("rails.json")
    end

    it "extracts repo_owner and repo_name" do
      subject.find("rails")
      expect(subject.repo_owner).to eq "rails"
      expect(subject.repo_name).to eq "rails"
    end

    context "if github url includes trailing slash" do
      before do
        allow(HTTPClient).to receive(:get_content).and_return load_fixture("web_translate_it.json")
      end

      it "extracts repo_owner and repo_name without trailing slash" do
        subject.find("web_translate_it")
        expect(subject.repo_owner).to eq "atelierconvivialite"
        expect(subject.repo_name).to eq "webtranslateit"
      end
    end

    context "if gem not found on rubygems.org" do
      before do
        allow(HTTPClient).to receive(:get_content).and_return load_fixture("not_found.json")
      end

      it "extracts homepage_uri" do
        subject.find("not_found")
        expect(subject.homepage_uri).to eq "https://rubygems.org/gems/not_found"
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
compare_linker-1.1.5 spec/lib/compare_linker/github_link_finder_spec.rb