diff --git a/spec/app/github_repo_fetcher_spec.rb b/spec/app/github_repo_fetcher_spec.rb index d060cf27e7..c362613ba7 100644 --- a/spec/app/github_repo_fetcher_spec.rb +++ b/spec/app/github_repo_fetcher_spec.rb @@ -7,16 +7,16 @@ ) end - let(:repo) do - double("stubbed repo", name: "some-repo", private_repo?: false, default_branch: "master") - end let(:private_repo) { double("Private repo", private_repo?: true) } - let(:public_repo) { double("Public repo", private_repo?: false) } + + def public_repo + double("Public repo", private_repo?: false, default_branch: "master") + end describe "#repo" do it "fetches a repo from cache if it exists" do allow(CACHE).to receive(:fetch).with("all-repos", hash_including(:expires_in)) do - [OpenStruct.new({ name: "some-repo", default_branch: "master" })] + [public_repo] end repo = GitHubRepoFetcher.instance.repo("some-repo") @@ -51,7 +51,7 @@ def readme_url end it "caches the first response" do - allow(GitHubRepoFetcher.instance).to receive(:repo).and_return(repo) + allow(GitHubRepoFetcher.instance).to receive(:repo).and_return(public_repo) stubbed_request = stub_request(:get, readme_url) .to_return(status: 200, body: "Foo") @@ -121,9 +121,7 @@ def with_stubbed_client(temporary_client) doc = double("doc", name: "foo.md", download_url: "foo_url", path: "docs/foo.md", html_url: "foo_html_url") allow(GitHubRepoFetcher.instance).to receive(:latest_commit).and_return(commit) - allow(GitHubRepoFetcher.instance).to receive(:repo).with(repo_name).and_return( - double("repo", private_repo?: false, default_branch: "main"), - ) + allow(GitHubRepoFetcher.instance).to receive(:repo).with(repo_name).and_return(public_repo) allow(HTTP).to receive(:get).with(doc.download_url).and_return(doc_contents) with_stubbed_client(double("Octokit::Client", contents: [doc])) do expect(GitHubRepoFetcher.instance.docs(repo_name)).to eq([