DEV: Use proper wording for contexts in specs

This commit is contained in:
Loïc Guitaut
2022-07-27 18:14:14 +02:00
committed by Loïc Guitaut
parent 02987e05d5
commit 3eaac56797
337 changed files with 2172 additions and 2723 deletions

View File

@ -90,7 +90,7 @@ RSpec.describe Onebox::Engine::AllowlistedGenericOnebox do
end
describe 'canonical link' do
context 'uses canonical link if available' do
context 'when using canonical link if available' do
let(:mobile_url) { "https://m.etsy.com/in-en/listing/87673424/personalized-word-pillow-case-letter" }
let(:canonical_url) { "https://www.etsy.com/in-en/listing/87673424/personalized-word-pillow-case-letter" }
before do
@ -111,7 +111,7 @@ RSpec.describe Onebox::Engine::AllowlistedGenericOnebox do
end
end
context 'does not use canonical link for Discourse topics' do
context 'when not using canonical link for Discourse topics' do
let(:discourse_topic_url) { "https://meta.discourse.org/t/congratulations-most-stars-in-2013-github-octoverse/12483" }
let(:discourse_topic_reply_url) { "https://meta.discourse.org/t/congratulations-most-stars-in-2013-github-octoverse/12483/2" }
before do
@ -164,7 +164,7 @@ RSpec.describe Onebox::Engine::AllowlistedGenericOnebox do
end
describe 'missing description' do
context 'works without description if image is present' do
context 'when working without description if image is present' do
before do
stub_request(:get, "https://edition.cnn.com/2020/05/15/health/gallery/coronavirus-people-adopting-pets-photos/index.html")
.to_return(status: 200, body: onebox_response('cnn'))
@ -183,7 +183,7 @@ RSpec.describe Onebox::Engine::AllowlistedGenericOnebox do
end
end
context 'uses basic meta description when necessary' do
context 'when using basic meta description when necessary' do
before do
stub_request(:get, "https://www.reddit.com/r/colors/comments/b4d5xm/literally_nothing_black_edition/")
.to_return(status: 200, body: onebox_response('reddit_image'))
@ -204,7 +204,7 @@ RSpec.describe Onebox::Engine::AllowlistedGenericOnebox do
end
describe 'article html hosts' do
context 'returns article_html for hosts in article_html_hosts' do
context 'when returning article_html for hosts in article_html_hosts' do
before do
stub_request(:get, "https://www.imdb.com/title/tt0108002/")
.to_return(status: 200, body: onebox_response('imdb'))

View File

@ -1,7 +1,7 @@
# frozen_string_literal: true
RSpec.describe Onebox::Engine::AmazonOnebox do
context "regular amazon page" do
describe "regular amazon page" do
before do
@link = "https://www.amazon.com/Knit-Noro-Accessories-Colorful-Little/dp/193609620X"
@uri = "https://www.amazon.com/dp/193609620X"
@ -10,7 +10,7 @@ RSpec.describe Onebox::Engine::AmazonOnebox do
.to_return(status: 200, body: onebox_response("amazon"))
end
include_context "engines"
include_context "with engines"
it_behaves_like "an engine"
describe "works with international domains" do
@ -101,7 +101,7 @@ RSpec.describe Onebox::Engine::AmazonOnebox do
end
end
context "amazon with opengraph" do
describe "amazon with opengraph" do
let(:link) { "https://www.amazon.com/dp/B01MFXN4Y2" }
let(:html) { described_class.new(link).to_html }
@ -128,7 +128,7 @@ RSpec.describe Onebox::Engine::AmazonOnebox do
end
end
context "amazon book page" do
describe "amazon book page" do
let(:link) { "https://www.amazon.com/dp/B00AYQNR46" }
let(:html) { described_class.new(link).to_html }
@ -156,7 +156,7 @@ RSpec.describe Onebox::Engine::AmazonOnebox do
end
end
context "amazon ebook page" do
describe "amazon ebook page" do
let(:link) { "https://www.amazon.com/dp/193435659X" }
let(:html) { described_class.new(link).to_html }
@ -192,7 +192,7 @@ RSpec.describe Onebox::Engine::AmazonOnebox do
end
end
context "non-standard response from Amazon" do
describe "non-standard response from Amazon" do
let(:link) { "https://www.amazon.com/dp/B0123ABCD3210" }
let(:onebox) { described_class.new(link) }
@ -215,7 +215,7 @@ RSpec.describe Onebox::Engine::AmazonOnebox do
end
end
context "alternate page layout response from Amazon" do
describe "alternate page layout response from Amazon" do
let(:link) { "https://www.amazon.com/dp/B07FQ7M16H" }
let(:html) { described_class.new(link).to_html }

View File

@ -12,7 +12,7 @@ RSpec.describe Onebox::Engine::GithubActionsOnebox do
.to_return(status: 200, body: onebox_response("githubactions_pr_run"))
end
include_context "engines"
include_context "with engines"
it_behaves_like "an engine"
describe "#to_html" do
@ -34,7 +34,7 @@ RSpec.describe Onebox::Engine::GithubActionsOnebox do
.to_return(status: 200, body: onebox_response("githubactions_actions_run"))
end
include_context "engines"
include_context "with engines"
it_behaves_like "an engine"
describe "#to_html" do

View File

@ -8,7 +8,7 @@ RSpec.describe Onebox::Engine::GithubBlobOnebox do
.to_return(status: 200, body: onebox_response(described_class.onebox_name))
end
include_context "engines"
include_context "with engines"
it_behaves_like "an engine"
describe "#to_html" do

View File

@ -9,7 +9,7 @@ RSpec.describe Onebox::Engine::GithubCommitOnebox do
stub_request(:get, @uri).to_return(status: 200, body: onebox_response("githubcommit"))
end
include_context "engines"
include_context "with engines"
it_behaves_like "an engine"
describe "#to_html" do
@ -64,7 +64,7 @@ RSpec.describe Onebox::Engine::GithubCommitOnebox do
.to_return(status: 200, body: onebox_response("githubcommit"))
end
include_context "engines"
include_context "with engines"
# TODO: fix test to make sure it's not failing when matching object
# it_behaves_like "an engine"

View File

@ -9,7 +9,7 @@ RSpec.describe Onebox::Engine::GithubFolderOnebox do
stub_request(:get, @uri).to_return(status: 200, body: onebox_response(described_class.onebox_name))
end
include_context "engines"
include_context "with engines"
it_behaves_like "an engine"
describe "#to_html" do

View File

@ -8,7 +8,7 @@ RSpec.describe Onebox::Engine::GithubGistOnebox do
.to_return(status: 200, body: onebox_response(described_class.onebox_name))
end
include_context "engines"
include_context "with engines"
it_behaves_like "an engine"
describe "#data" do

View File

@ -8,7 +8,7 @@ RSpec.describe Onebox::Engine::GithubPullRequestOnebox do
stub_request(:get, @uri).to_return(status: 200, body: onebox_response(described_class.onebox_name))
end
include_context "engines"
include_context "with engines"
it_behaves_like "an engine"
describe "#to_html" do

View File

@ -8,7 +8,7 @@ RSpec.describe Onebox::Engine::GitlabBlobOnebox do
.to_return(status: 200, body: onebox_response(described_class.onebox_name))
end
include_context "engines"
include_context "with engines"
it_behaves_like "an engine"
describe "#to_html" do

View File

@ -7,7 +7,7 @@ RSpec.describe Onebox::Engine::GoogleDocsOnebox do
stub_request(:get, @link).to_return(status: 200, body: onebox_response("googledocs"))
end
include_context "engines"
include_context "with engines"
it_behaves_like "an engine"
describe "#to_html" do

View File

@ -8,7 +8,7 @@ RSpec.describe Onebox::Engine::GooglePlayAppOnebox do
.to_return(status: 200, body: onebox_response("googleplayapp"))
end
include_context "engines"
include_context "with engines"
it_behaves_like "an engine"
describe "#to_html" do

View File

@ -1,7 +1,7 @@
# frozen_string_literal: true
RSpec.describe Onebox::Engine::HackernewsOnebox do
context "When oneboxing a comment" do
context "when oneboxing a comment" do
let(:link) { "https://news.ycombinator.com/item?id=30181167" }
let(:api_link) { "https://hacker-news.firebaseio.com/v0/item/30181167.json" }
let(:html) { described_class.new(link).to_html }
@ -27,7 +27,7 @@ RSpec.describe Onebox::Engine::HackernewsOnebox do
end
end
context "When oneboxing a story" do
context "when oneboxing a story" do
let(:link) { "https://news.ycombinator.com/item?id=5172905" }
let(:api_link) { "https://hacker-news.firebaseio.com/v0/item/5172905.json" }
let(:html) { described_class.new(link).to_html }

View File

@ -29,7 +29,7 @@ RSpec.describe Onebox::Engine::PubmedOnebox do
expect(html).to include(link)
end
context "Pubmed electronic print" do
describe "Pubmed electronic print" do
let(:link) { "http://www.ncbi.nlm.nih.gov/pubmed/24737116" }
let(:xml_link) { "http://www.ncbi.nlm.nih.gov/pubmed/24737116?report=xml&format=text" }
let(:html) { described_class.new(link).to_html }
@ -56,7 +56,7 @@ RSpec.describe Onebox::Engine::PubmedOnebox do
end
end
context "regex URI match" do
describe "regex URI match" do
it "matches on specific articles" do
expect(match("http://www.ncbi.nlm.nih.gov/pubmed/7288891")).to eq true
end

View File

@ -49,7 +49,7 @@ RSpec.describe Onebox::Engine::StackExchangeOnebox do
.to_return(status: 200, body: onebox_response('stackexchange-question'))
end
include_context 'engines'
include_context 'with engines'
it_behaves_like 'an engine'
describe '#to_html' do
@ -80,7 +80,7 @@ RSpec.describe Onebox::Engine::StackExchangeOnebox do
.to_return(status: 200, body: onebox_response('stackexchange-answer'))
end
include_context 'engines'
include_context 'with engines'
it_behaves_like 'an engine'
describe '#to_html' do

View File

@ -1,7 +1,7 @@
# frozen_string_literal: true
RSpec.describe Onebox::Engine::TrelloOnebox do
context "Boards" do
describe "Boards" do
it "should onebox with SEF url corrrectly" do
expect(Onebox.preview('https://trello.com/b/nC8QJJoZ/trello-development-roadmap').to_s).to match('iframe src="https://trello.com/b/nC8QJJoZ.html"')
end
@ -14,7 +14,7 @@ RSpec.describe Onebox::Engine::TrelloOnebox do
end
end
context "Cards" do
describe "Cards" do
it "should onebox with SEF url corrrectly" do
expect(Onebox.preview('https://trello.com/c/NIRpzVDM/1211-what-can-you-expect-from-this-board').to_s).to match('iframe src="https://trello.com/c/NIRpzVDM.html"')
end

View File

@ -40,7 +40,7 @@ RSpec.describe Onebox::Engine::TwitterStatusOnebox do
end
end
shared_context "standard tweet info" do
shared_context "with standard tweet info" do
before do
@link = "https://twitter.com/vyki_e/status/363116819147538433"
@onebox_fixture = "twitterstatus"
@ -55,7 +55,7 @@ RSpec.describe Onebox::Engine::TwitterStatusOnebox do
let(:retweets_count) { "0" }
end
shared_context "quoted tweet info" do
shared_context "with quoted tweet info" do
before do
@link = "https://twitter.com/metallica/status/1128068672289890305"
@onebox_fixture = "twitterstatus_quoted"
@ -72,7 +72,7 @@ RSpec.describe Onebox::Engine::TwitterStatusOnebox do
let(:retweets_count) { "201" }
end
shared_context "featured image info" do
shared_context "with featured image info" do
before do
@link = "https://twitter.com/codinghorror/status/1409351083177046020"
@onebox_fixture = "twitterstatus_featured_image"
@ -111,8 +111,8 @@ RSpec.describe Onebox::Engine::TwitterStatusOnebox do
context "with a standard tweet" do
let(:tweet_content) { "I'm a sucker for pledges." }
include_context "standard tweet info"
include_context "engines"
include_context "with standard tweet info"
include_context "with engines"
it_behaves_like "an engine"
it_behaves_like "#to_html"
@ -123,8 +123,8 @@ RSpec.describe Onebox::Engine::TwitterStatusOnebox do
"Thank you to everyone who came out for #MetInParis last night for helping us support @EMMAUSolidarite &"
end
include_context "quoted tweet info"
include_context "engines"
include_context "with quoted tweet info"
include_context "with engines"
it_behaves_like "an engine"
it_behaves_like '#to_html'
@ -136,8 +136,8 @@ RSpec.describe Onebox::Engine::TwitterStatusOnebox do
"My first text message from my child! A moment that shall live on in infamy!"
end
include_context "featured image info"
include_context "engines"
include_context "with featured image info"
include_context "with engines"
it_behaves_like "an engine"
it_behaves_like '#to_html'
@ -289,8 +289,8 @@ RSpec.describe Onebox::Engine::TwitterStatusOnebox do
}
end
include_context "standard tweet info"
include_context "engines"
include_context "with standard tweet info"
include_context "with engines"
it_behaves_like "an engine"
it_behaves_like "#to_html"
@ -674,8 +674,8 @@ RSpec.describe Onebox::Engine::TwitterStatusOnebox do
}
end
include_context "quoted tweet info"
include_context "engines"
include_context "with quoted tweet info"
include_context "with engines"
it_behaves_like "an engine"
it_behaves_like '#to_html'

View File

@ -8,7 +8,7 @@ RSpec.describe Onebox::Engine::WikipediaOnebox do
.to_return(status: 200, body: onebox_response(described_class.onebox_name))
end
include_context "engines"
include_context "with engines"
it_behaves_like "an engine"
describe "#to_html" do
@ -21,7 +21,7 @@ RSpec.describe Onebox::Engine::WikipediaOnebox do
end
end
context "url with section hash" do
describe "url with section hash" do
before do
@link = "http://en.wikipedia.org/wiki/Billy_Jack#Soundtrack"
end
@ -31,7 +31,7 @@ RSpec.describe Onebox::Engine::WikipediaOnebox do
end
end
context "url with url-encoded section hash" do
describe "url with url-encoded section hash" do
before do
@link = "https://fr.wikipedia.org/wiki/Th%C3%A9ologie#La_th%C3%A9ologie_selon_Aristote"

View File

@ -51,7 +51,7 @@ RSpec.describe Onebox::Helpers do
expect(described_class.fetch_html_doc(uri).to_s).to match("success")
end
context "canonical link" do
context "with canonical link" do
it "follows canonical link" do
uri = 'https://www.example.com'
stub_request(:get, uri).to_return(status: 200, body: "<!DOCTYPE html><link rel='canonical' href='http://foobar.com/'/><p>invalid</p>")
@ -133,7 +133,7 @@ RSpec.describe Onebox::Helpers do
end
describe "user_agent" do
context "default" do
context "with default" do
it "has the default Discourse user agent" do
stub_request(:get, "http://example.com/some-resource")
.with(headers: { "user-agent" => /Discourse Forum Onebox/ })
@ -143,7 +143,7 @@ RSpec.describe Onebox::Helpers do
end
end
context "Custom option" do
context "with custom option" do
around do |example|
previous_options = Onebox.options.to_h
Onebox.options = { user_agent: "EvilTroutBot v0.1" }