Fix RSpec/ContextWording cop (#24739)

This commit is contained in:
Matt Jankowski 2023-05-03 23:49:08 -04:00 committed by GitHub
parent cf18cc2891
commit 710745e16b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
105 changed files with 559 additions and 668 deletions

View file

@ -8,7 +8,7 @@ RSpec.describe TextFormatter do
let(:preloaded_accounts) { nil }
context 'given text containing plain text' do
context 'when given text containing plain text' do
let(:text) { 'text' }
it 'paragraphizes the text' do
@ -16,7 +16,7 @@ RSpec.describe TextFormatter do
end
end
context 'given text containing line feeds' do
context 'when given text containing line feeds' do
let(:text) { "line\nfeed" }
it 'removes line feeds' do
@ -24,7 +24,7 @@ RSpec.describe TextFormatter do
end
end
context 'given text containing linkable mentions' do
context 'when given text containing linkable mentions' do
let(:preloaded_accounts) { [Fabricate(:account, username: 'alice')] }
let(:text) { '@alice' }
@ -33,7 +33,7 @@ RSpec.describe TextFormatter do
end
end
context 'given text containing unlinkable mentions' do
context 'when given text containing unlinkable mentions' do
let(:preloaded_accounts) { [] }
let(:text) { '@alice' }
@ -42,7 +42,7 @@ RSpec.describe TextFormatter do
end
end
context 'given a stand-alone medium URL' do
context 'when given a stand-alone medium URL' do
let(:text) { 'https://hackernoon.com/the-power-to-build-communities-a-response-to-mark-zuckerberg-3f2cac9148a4' }
it 'matches the full URL' do
@ -50,7 +50,7 @@ RSpec.describe TextFormatter do
end
end
context 'given a stand-alone google URL' do
context 'when given a stand-alone google URL' do
let(:text) { 'http://google.com' }
it 'matches the full URL' do
@ -58,7 +58,7 @@ RSpec.describe TextFormatter do
end
end
context 'given a stand-alone URL with a newer TLD' do
context 'when given a stand-alone URL with a newer TLD' do
let(:text) { 'http://example.gay' }
it 'matches the full URL' do
@ -66,7 +66,7 @@ RSpec.describe TextFormatter do
end
end
context 'given a stand-alone IDN URL' do
context 'when given a stand-alone IDN URL' do
let(:text) { 'https://nic.みんな/' }
it 'matches the full URL' do
@ -78,7 +78,7 @@ RSpec.describe TextFormatter do
end
end
context 'given a URL with a trailing period' do
context 'when given a URL with a trailing period' do
let(:text) { 'http://www.mcmansionhell.com/post/156408871451/50-states-of-mcmansion-hell-scottsdale-arizona. ' }
it 'matches the full URL but not the period' do
@ -86,7 +86,7 @@ RSpec.describe TextFormatter do
end
end
context 'given a URL enclosed with parentheses' do
context 'when given a URL enclosed with parentheses' do
let(:text) { '(http://google.com/)' }
it 'matches the full URL but not the parentheses' do
@ -94,7 +94,7 @@ RSpec.describe TextFormatter do
end
end
context 'given a URL with a trailing exclamation point' do
context 'when given a URL with a trailing exclamation point' do
let(:text) { 'http://www.google.com!' }
it 'matches the full URL but not the exclamation point' do
@ -102,7 +102,7 @@ RSpec.describe TextFormatter do
end
end
context 'given a URL with a trailing single quote' do
context 'when given a URL with a trailing single quote' do
let(:text) { "http://www.google.com'" }
it 'matches the full URL but not the single quote' do
@ -110,7 +110,7 @@ RSpec.describe TextFormatter do
end
end
context 'given a URL with a trailing angle bracket' do
context 'when given a URL with a trailing angle bracket' do
let(:text) { 'http://www.google.com>' }
it 'matches the full URL but not the angle bracket' do
@ -118,7 +118,7 @@ RSpec.describe TextFormatter do
end
end
context 'given a URL with a query string' do
context 'when given a URL with a query string' do
context 'with escaped unicode character' do
let(:text) { 'https://www.ruby-toolbox.com/search?utf8=%E2%9C%93&q=autolink' }
@ -152,7 +152,7 @@ RSpec.describe TextFormatter do
end
end
context 'given a URL with parentheses in it' do
context 'when given a URL with parentheses in it' do
let(:text) { 'https://en.wikipedia.org/wiki/Diaspora_(software)' }
it 'matches the full URL' do
@ -160,7 +160,7 @@ RSpec.describe TextFormatter do
end
end
context 'given a URL in quotation marks' do
context 'when given a URL in quotation marks' do
let(:text) { '"https://example.com/"' }
it 'does not match the quotation marks' do
@ -168,7 +168,7 @@ RSpec.describe TextFormatter do
end
end
context 'given a URL in angle brackets' do
context 'when given a URL in angle brackets' do
let(:text) { '<https://example.com/>' }
it 'does not match the angle brackets' do
@ -176,7 +176,7 @@ RSpec.describe TextFormatter do
end
end
context 'given a URL with Japanese path string' do
context 'when given a URL with Japanese path string' do
let(:text) { 'https://ja.wikipedia.org/wiki/日本' }
it 'matches the full URL' do
@ -184,7 +184,7 @@ RSpec.describe TextFormatter do
end
end
context 'given a URL with Korean path string' do
context 'when given a URL with Korean path string' do
let(:text) { 'https://ko.wikipedia.org/wiki/대한민국' }
it 'matches the full URL' do
@ -192,7 +192,7 @@ RSpec.describe TextFormatter do
end
end
context 'given a URL with a full-width space' do
context 'when given a URL with a full-width space' do
let(:text) { 'https://example.com/ abc123' }
it 'does not match the full-width space' do
@ -200,7 +200,7 @@ RSpec.describe TextFormatter do
end
end
context 'given a URL in Japanese quotation marks' do
context 'when given a URL in Japanese quotation marks' do
let(:text) { '「[https://example.org/」' }
it 'does not match the quotation marks' do
@ -208,7 +208,7 @@ RSpec.describe TextFormatter do
end
end
context 'given a URL with Simplified Chinese path string' do
context 'when given a URL with Simplified Chinese path string' do
let(:text) { 'https://baike.baidu.com/item/中华人民共和国' }
it 'matches the full URL' do
@ -216,7 +216,7 @@ RSpec.describe TextFormatter do
end
end
context 'given a URL with Traditional Chinese path string' do
context 'when given a URL with Traditional Chinese path string' do
let(:text) { 'https://zh.wikipedia.org/wiki/臺灣' }
it 'matches the full URL' do
@ -224,7 +224,7 @@ RSpec.describe TextFormatter do
end
end
context 'given a URL containing unsafe code (XSS attack, visible part)' do
context 'when given a URL containing unsafe code (XSS attack, visible part)' do
let(:text) { 'http://example.com/b<del>b</del>' }
it 'does not include the HTML in the URL' do
@ -236,7 +236,7 @@ RSpec.describe TextFormatter do
end
end
context 'given a URL containing unsafe code (XSS attack, invisible part)' do
context 'when given a URL containing unsafe code (XSS attack, invisible part)' do
let(:text) { 'http://example.com/blahblahblahblah/a<script>alert("Hello")</script>' }
it 'does not include the HTML in the URL' do
@ -248,7 +248,7 @@ RSpec.describe TextFormatter do
end
end
context 'given text containing HTML code (script tag)' do
context 'when given text containing HTML code (script tag)' do
let(:text) { '<script>alert("Hello")</script>' }
it 'escapes the HTML' do
@ -256,7 +256,7 @@ RSpec.describe TextFormatter do
end
end
context 'given text containing HTML (XSS attack)' do
context 'when given text containing HTML (XSS attack)' do
let(:text) { %q{<img src="javascript:alert('XSS');">} }
it 'escapes the HTML' do
@ -264,7 +264,7 @@ RSpec.describe TextFormatter do
end
end
context 'given an invalid URL' do
context 'when given an invalid URL' do
let(:text) { 'http://www\.google\.com' }
it 'outputs the raw URL' do
@ -272,7 +272,7 @@ RSpec.describe TextFormatter do
end
end
context 'given text containing a hashtag' do
context 'when given text containing a hashtag' do
let(:text) { '#hashtag' }
it 'creates a hashtag link' do
@ -280,7 +280,7 @@ RSpec.describe TextFormatter do
end
end
context 'given text containing a hashtag with Unicode chars' do
context 'when given text containing a hashtag with Unicode chars' do
let(:text) { '#hashtagタグ' }
it 'creates a hashtag link' do
@ -288,7 +288,7 @@ RSpec.describe TextFormatter do
end
end
context 'given text with a stand-alone xmpp: URI' do
context 'when given text with a stand-alone xmpp: URI' do
let(:text) { 'xmpp:user@instance.com' }
it 'matches the full URI' do
@ -296,7 +296,7 @@ RSpec.describe TextFormatter do
end
end
context 'given text with an xmpp: URI with a query-string' do
context 'when given text with an xmpp: URI with a query-string' do
let(:text) { 'please join xmpp:muc@instance.com?join right now' }
it 'matches the full URI' do
@ -304,7 +304,7 @@ RSpec.describe TextFormatter do
end
end
context 'given text containing a magnet: URI' do
context 'when given text containing a magnet: URI' do
let(:text) { 'wikipedia gives this example of a magnet uri: magnet:?xt=urn:btih:c12fe1c06bba254a9dc9f519b335aa7c1367a88a' }
it 'matches the full URI' do