DEV: Avoid instance variables in specs

Small followup of https://github.com/discourse/discourse/pull/27705
This commit is contained in:
Loïc Guitaut
2024-07-11 12:15:48 +02:00
committed by Loïc Guitaut
parent 797f659eed
commit b0480dd34e
7 changed files with 105 additions and 92 deletions

View File

@ -2,23 +2,26 @@
RSpec.describe Onebox::Engine::GithubActionsOnebox do
describe "PR check run" do
before do
@link = "https://github.com/discourse/discourse/pull/13128/checks?check_run_id=2660861130"
@pr_run_uri = "https://api.github.com/repos/discourse/discourse/pulls/13128"
@run_uri = "https://api.github.com/repos/discourse/discourse/check-runs/2660861130"
let(:pr_run_uri) { "https://api.github.com/repos/discourse/discourse/pulls/13128" }
let(:run_uri) { "https://api.github.com/repos/discourse/discourse/check-runs/2660861130" }
stub_request(:get, @pr_run_uri).to_return(
before do
stub_request(:get, pr_run_uri).to_return(
status: 200,
body: onebox_response("githubactions_pr"),
)
stub_request(:get, @run_uri).to_return(
stub_request(:get, run_uri).to_return(
status: 200,
body: onebox_response("githubactions_pr_run"),
)
end
include_context "with engines"
include_context "with engines" do
let(:link) do
"https://github.com/discourse/discourse/pull/13128/checks?check_run_id=2660861130"
end
end
it_behaves_like "an engine"
describe "#to_html" do
@ -36,7 +39,7 @@ RSpec.describe Onebox::Engine::GithubActionsOnebox do
it "sends it as part of the request" do
html
expect(WebMock).to have_requested(:get, @run_uri).with(
expect(WebMock).to have_requested(:get, run_uri).with(
headers: {
"Authorization" => "Bearer #{SiteSetting.github_onebox_access_token}",
},
@ -46,17 +49,18 @@ RSpec.describe Onebox::Engine::GithubActionsOnebox do
end
describe "GitHub Actions run" do
before do
@link = "https://github.com/discourse/discourse/actions/runs/873214216"
@pr_run_uri = "https://api.github.com/repos/discourse/discourse/actions/runs/873214216"
let(:pr_run_uri) { "https://api.github.com/repos/discourse/discourse/actions/runs/873214216" }
stub_request(:get, @pr_run_uri).to_return(
before do
stub_request(:get, pr_run_uri).to_return(
status: 200,
body: onebox_response("githubactions_actions_run"),
)
end
include_context "with engines"
include_context "with engines" do
let(:link) { "https://github.com/discourse/discourse/actions/runs/873214216" }
end
it_behaves_like "an engine"
describe "#to_html" do
@ -78,7 +82,7 @@ RSpec.describe Onebox::Engine::GithubActionsOnebox do
it "sends it as part of the request" do
html
expect(WebMock).to have_requested(:get, @pr_run_uri).with(
expect(WebMock).to have_requested(:get, pr_run_uri).with(
headers: {
"Authorization" => "Bearer #{SiteSetting.github_onebox_access_token}",
},