0
0
Fork 0

Fix RSpec/DescribedClass cop (#25104)

This commit is contained in:
Matt Jankowski 2023-06-06 07:58:33 -04:00 committed by GitHub
parent 1e243e2df7
commit c42591356d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
66 changed files with 347 additions and 414 deletions

View file

@ -6,19 +6,19 @@ describe Extractor do
describe 'extract_mentions_or_lists_with_indices' do
it 'returns an empty array if the given string does not have at signs' do
text = 'a string without at signs'
extracted = Extractor.extract_mentions_or_lists_with_indices(text)
extracted = described_class.extract_mentions_or_lists_with_indices(text)
expect(extracted).to eq []
end
it 'does not extract mentions which ends with particular characters' do
text = '@screen_name@'
extracted = Extractor.extract_mentions_or_lists_with_indices(text)
extracted = described_class.extract_mentions_or_lists_with_indices(text)
expect(extracted).to eq []
end
it 'returns mentions as an array' do
text = '@screen_name'
extracted = Extractor.extract_mentions_or_lists_with_indices(text)
extracted = described_class.extract_mentions_or_lists_with_indices(text)
expect(extracted).to eq [
{ screen_name: 'screen_name', indices: [0, 12] },
]
@ -26,7 +26,7 @@ describe Extractor do
it 'yields mentions if a block is given' do
text = '@screen_name'
Extractor.extract_mentions_or_lists_with_indices(text) do |screen_name, start_position, end_position|
described_class.extract_mentions_or_lists_with_indices(text) do |screen_name, start_position, end_position|
expect(screen_name).to eq 'screen_name'
expect(start_position).to eq 0
expect(end_position).to eq 12
@ -37,31 +37,31 @@ describe Extractor do
describe 'extract_hashtags_with_indices' do
it 'returns an empty array if it does not have #' do
text = 'a string without hash sign'
extracted = Extractor.extract_hashtags_with_indices(text)
extracted = described_class.extract_hashtags_with_indices(text)
expect(extracted).to eq []
end
it 'does not exclude normal hash text before ://' do
text = '#hashtag://'
extracted = Extractor.extract_hashtags_with_indices(text)
extracted = described_class.extract_hashtags_with_indices(text)
expect(extracted).to eq [{ hashtag: 'hashtag', indices: [0, 8] }]
end
it 'excludes http://' do
text = '#hashtaghttp://'
extracted = Extractor.extract_hashtags_with_indices(text)
extracted = described_class.extract_hashtags_with_indices(text)
expect(extracted).to eq [{ hashtag: 'hashtag', indices: [0, 8] }]
end
it 'excludes https://' do
text = '#hashtaghttps://'
extracted = Extractor.extract_hashtags_with_indices(text)
extracted = described_class.extract_hashtags_with_indices(text)
expect(extracted).to eq [{ hashtag: 'hashtag', indices: [0, 8] }]
end
it 'yields hashtags if a block is given' do
text = '#hashtag'
Extractor.extract_hashtags_with_indices(text) do |hashtag, start_position, end_position|
described_class.extract_hashtags_with_indices(text) do |hashtag, start_position, end_position|
expect(hashtag).to eq 'hashtag'
expect(start_position).to eq 0
expect(end_position).to eq 8
@ -72,7 +72,7 @@ describe Extractor do
describe 'extract_cashtags_with_indices' do
it 'returns []' do
text = '$cashtag'
extracted = Extractor.extract_cashtags_with_indices(text)
extracted = described_class.extract_cashtags_with_indices(text)
expect(extracted).to eq []
end
end