Skip to content

Commit

Permalink
Fix RSpec/DescribedClass cop
Browse files Browse the repository at this point in the history
  • Loading branch information
mjankowski committed Mar 12, 2024
1 parent d4ed7e4 commit e335dd1
Show file tree
Hide file tree
Showing 12 changed files with 29 additions and 29 deletions.
12 changes: 6 additions & 6 deletions spec/lib/feed_manager_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
end

it 'tracks at least as many statuses as reblogs', :skip_stub do
expect(FeedManager::REBLOG_FALLOFF).to be <= FeedManager::MAX_ITEMS
expect(described_class::REBLOG_FALLOFF).to be <= described_class::MAX_ITEMS
end

describe '#key' do
Expand Down Expand Up @@ -225,12 +225,12 @@
it 'trims timelines if they will have more than FeedManager::MAX_ITEMS' do
account = Fabricate(:account)
status = Fabricate(:status)
members = Array.new(FeedManager::MAX_ITEMS) { |count| [count, count] }
members = Array.new(described_class::MAX_ITEMS) { |count| [count, count] }
redis.zadd("feed:home:#{account.id}", members)

described_class.instance.push_to_home(account, status)

expect(redis.zcard("feed:home:#{account.id}")).to eq FeedManager::MAX_ITEMS
expect(redis.zcard("feed:home:#{account.id}")).to eq described_class::MAX_ITEMS
end

context 'with reblogs' do
Expand Down Expand Up @@ -260,7 +260,7 @@
described_class.instance.push_to_home(account, reblogged)

# Fill the feed with intervening statuses
FeedManager::REBLOG_FALLOFF.times do
described_class::REBLOG_FALLOFF.times do
described_class.instance.push_to_home(account, Fabricate(:status))
end

Expand Down Expand Up @@ -321,7 +321,7 @@
described_class.instance.push_to_home(account, reblogs.first)

# Fill the feed with intervening statuses
FeedManager::REBLOG_FALLOFF.times do
described_class::REBLOG_FALLOFF.times do
described_class.instance.push_to_home(account, Fabricate(:status))
end

Expand Down Expand Up @@ -467,7 +467,7 @@
status = Fabricate(:status, reblog: reblogged)

described_class.instance.push_to_home(receiver, reblogged)
FeedManager::REBLOG_FALLOFF.times { described_class.instance.push_to_home(receiver, Fabricate(:status)) }
described_class::REBLOG_FALLOFF.times { described_class.instance.push_to_home(receiver, Fabricate(:status)) }
described_class.instance.push_to_home(receiver, status)

# The reblogging status should show up under normal conditions.
Expand Down
2 changes: 1 addition & 1 deletion spec/lib/sanitize/config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

describe Sanitize::Config do
describe '::MASTODON_STRICT' do
subject { Sanitize::Config::MASTODON_STRICT }
subject { described_class::MASTODON_STRICT }

it 'converts h1 to p strong' do
expect(Sanitize.fragment('<h1>Foo</h1>', subject)).to eq '<p><strong>Foo</strong></p>'
Expand Down
2 changes: 1 addition & 1 deletion spec/lib/signature_parser_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
let(:header) { 'hello this is malformed!' }

it 'raises an error' do
expect { subject }.to raise_error(SignatureParser::ParsingError)
expect { subject }.to raise_error(described_class::ParsingError)
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions spec/lib/webfinger_resource_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@

expect do
described_class.new(resource).username
end.to raise_error(WebfingerResource::InvalidRequest)
end.to raise_error(described_class::InvalidRequest)
end

it 'finds the username in a valid https route' do
Expand Down Expand Up @@ -137,7 +137,7 @@

expect do
described_class.new(resource).username
end.to raise_error(WebfingerResource::InvalidRequest)
end.to raise_error(described_class::InvalidRequest)
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/models/account_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -678,7 +678,7 @@
end

describe 'MENTION_RE' do
subject { Account::MENTION_RE }
subject { described_class::MENTION_RE }

it 'matches usernames in the middle of a sentence' do
expect(subject.match('Hello to @alice from me')[1]).to eq 'alice'
Expand Down
2 changes: 1 addition & 1 deletion spec/models/form/import_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

it 'has errors' do
subject.validate
expect(subject.errors[:data]).to include(I18n.t('imports.errors.over_rows_processing_limit', count: Form::Import::ROWS_PROCESSING_LIMIT))
expect(subject.errors[:data]).to include(I18n.t('imports.errors.over_rows_processing_limit', count: described_class::ROWS_PROCESSING_LIMIT))
end
end

Expand Down
2 changes: 1 addition & 1 deletion spec/models/privacy_policy_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
it 'has the privacy text' do
policy = described_class.current

expect(policy.text).to eq(PrivacyPolicy::DEFAULT_PRIVACY_POLICY)
expect(policy.text).to eq(described_class::DEFAULT_PRIVACY_POLICY)
end
end

Expand Down
2 changes: 1 addition & 1 deletion spec/models/tag_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
end

describe 'HASHTAG_RE' do
subject { Tag::HASHTAG_RE }
subject { described_class::HASHTAG_RE }

it 'does not match URLs with anchors with non-hashtag characters' do
expect(subject.match('Check this out https://medium.com/@alice/some-article#.abcdef123')).to be_nil
Expand Down
22 changes: 11 additions & 11 deletions spec/models/user_role_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
describe '#can?' do
context 'with a single flag' do
it 'returns true if any of them are present' do
subject.permissions = UserRole::FLAGS[:manage_reports]
subject.permissions = described_class::FLAGS[:manage_reports]
expect(subject.can?(:manage_reports)).to be true
end

Expand All @@ -19,7 +19,7 @@

context 'with multiple flags' do
it 'returns true if any of them are present' do
subject.permissions = UserRole::FLAGS[:manage_users]
subject.permissions = described_class::FLAGS[:manage_users]
expect(subject.can?(:manage_reports, :manage_users)).to be true
end

Expand Down Expand Up @@ -51,7 +51,7 @@

describe '#permissions_as_keys' do
before do
subject.permissions = UserRole::FLAGS[:invite_users] | UserRole::FLAGS[:view_dashboard] | UserRole::FLAGS[:manage_reports]
subject.permissions = described_class::FLAGS[:invite_users] | described_class::FLAGS[:view_dashboard] | described_class::FLAGS[:manage_reports]
end

it 'returns an array' do
Expand All @@ -70,23 +70,23 @@
let(:input) { %w(manage_users) }

it 'sets permission flags' do
expect(subject.permissions).to eq UserRole::FLAGS[:manage_users]
expect(subject.permissions).to eq described_class::FLAGS[:manage_users]
end
end

context 'with multiple values' do
let(:input) { %w(manage_users manage_reports) }

it 'sets permission flags' do
expect(subject.permissions).to eq UserRole::FLAGS[:manage_users] | UserRole::FLAGS[:manage_reports]
expect(subject.permissions).to eq described_class::FLAGS[:manage_users] | described_class::FLAGS[:manage_reports]
end
end

context 'with an unknown value' do
let(:input) { %w(foo) }

it 'does not set permission flags' do
expect(subject.permissions).to eq UserRole::Flags::NONE
expect(subject.permissions).to eq described_class::Flags::NONE
end
end
end
Expand All @@ -96,7 +96,7 @@
subject { described_class.nobody }

it 'returns none' do
expect(subject.computed_permissions).to eq UserRole::Flags::NONE
expect(subject.computed_permissions).to eq described_class::Flags::NONE
end
end

Expand All @@ -110,11 +110,11 @@

context 'when role has the administrator flag' do
before do
subject.permissions = UserRole::FLAGS[:administrator]
subject.permissions = described_class::FLAGS[:administrator]
end

it 'returns all permissions' do
expect(subject.computed_permissions).to eq UserRole::Flags::ALL
expect(subject.computed_permissions).to eq described_class::Flags::ALL
end
end

Expand All @@ -135,7 +135,7 @@
end

it 'has default permissions' do
expect(subject.permissions).to eq UserRole::FLAGS[:invite_users]
expect(subject.permissions).to eq described_class::FLAGS[:invite_users]
end

it 'has negative position' do
Expand All @@ -155,7 +155,7 @@
end

it 'has no permissions' do
expect(subject.permissions).to eq UserRole::Flags::NONE
expect(subject.permissions).to eq described_class::Flags::NONE
end

it 'has negative position' do
Expand Down
4 changes: 2 additions & 2 deletions spec/models/user_settings_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

context 'when setting was not defined' do
it 'raises error' do
expect { subject[:foo] }.to raise_error UserSettings::KeyError
expect { subject[:foo] }.to raise_error described_class::KeyError
end
end
end
Expand Down Expand Up @@ -93,7 +93,7 @@
describe '.definition_for' do
context 'when key is defined' do
it 'returns a setting' do
expect(described_class.definition_for(:always_send_emails)).to be_a UserSettings::Setting
expect(described_class.definition_for(:always_send_emails)).to be_a described_class::Setting
end
end

Expand Down
2 changes: 1 addition & 1 deletion spec/services/post_status_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@

expect do
subject.call(account, text: '@alice hm, @bob is really annoying lately', allowed_mentions: [mentioned_account.id])
end.to raise_error(an_instance_of(PostStatusService::UnexpectedMentionsError).and(having_attributes(accounts: [unexpected_mentioned_account])))
end.to raise_error(an_instance_of(described_class::UnexpectedMentionsError).and(having_attributes(accounts: [unexpected_mentioned_account])))
end

it 'processes duplicate mentions correctly' do
Expand Down
2 changes: 1 addition & 1 deletion spec/validators/follow_limit_validator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@

follow.valid?

expect(follow.errors[:base]).to include(I18n.t('users.follow_limit_reached', limit: FollowLimitValidator::LIMIT))
expect(follow.errors[:base]).to include(I18n.t('users.follow_limit_reached', limit: described_class::LIMIT))
end
end

Expand Down

0 comments on commit e335dd1

Please sign in to comment.