Reduce expectations for `RSpec/MultipleExpectations` cop in `spec/presenters` specs (#27881)
This commit is contained in:
parent
155fb84141
commit
cb1a4a8713
|
@ -23,12 +23,14 @@ RSpec.describe AccountRelationshipsPresenter do
|
||||||
let(:options) { {} }
|
let(:options) { {} }
|
||||||
|
|
||||||
it 'sets default maps' do
|
it 'sets default maps' do
|
||||||
expect(presenter.following).to eq default_map
|
expect(presenter).to have_attributes(
|
||||||
expect(presenter.followed_by).to eq default_map
|
following: default_map,
|
||||||
expect(presenter.blocking).to eq default_map
|
followed_by: default_map,
|
||||||
expect(presenter.muting).to eq default_map
|
blocking: default_map,
|
||||||
expect(presenter.requested).to eq default_map
|
muting: default_map,
|
||||||
expect(presenter.domain_blocking).to eq default_map
|
requested: default_map,
|
||||||
|
domain_blocking: default_map
|
||||||
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -22,9 +22,12 @@ RSpec.describe FamiliarFollowersPresenter do
|
||||||
it 'returns followers you follow' do
|
it 'returns followers you follow' do
|
||||||
result = subject.accounts.first
|
result = subject.accounts.first
|
||||||
|
|
||||||
expect(result).to_not be_nil
|
expect(result)
|
||||||
expect(result.id).to eq requested_accounts.first.id
|
.to be_present
|
||||||
expect(result.accounts).to contain_exactly(familiar_follower)
|
.and have_attributes(
|
||||||
|
id: requested_accounts.first.id,
|
||||||
|
accounts: contain_exactly(familiar_follower)
|
||||||
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when requested account hides followers' do
|
context 'when requested account hides followers' do
|
||||||
|
@ -35,9 +38,12 @@ RSpec.describe FamiliarFollowersPresenter do
|
||||||
it 'does not return followers you follow' do
|
it 'does not return followers you follow' do
|
||||||
result = subject.accounts.first
|
result = subject.accounts.first
|
||||||
|
|
||||||
expect(result).to_not be_nil
|
expect(result)
|
||||||
expect(result.id).to eq requested_accounts.first.id
|
.to be_present
|
||||||
expect(result.accounts).to be_empty
|
.and have_attributes(
|
||||||
|
id: requested_accounts.first.id,
|
||||||
|
accounts: be_empty
|
||||||
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -49,9 +55,12 @@ RSpec.describe FamiliarFollowersPresenter do
|
||||||
it 'does not return followers you follow' do
|
it 'does not return followers you follow' do
|
||||||
result = subject.accounts.first
|
result = subject.accounts.first
|
||||||
|
|
||||||
expect(result).to_not be_nil
|
expect(result)
|
||||||
expect(result.id).to eq requested_accounts.first.id
|
.to be_present
|
||||||
expect(result.accounts).to be_empty
|
.and have_attributes(
|
||||||
|
id: requested_accounts.first.id,
|
||||||
|
accounts: be_empty
|
||||||
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -22,11 +22,13 @@ RSpec.describe StatusRelationshipsPresenter do
|
||||||
let(:options) { {} }
|
let(:options) { {} }
|
||||||
|
|
||||||
it 'sets default maps' do
|
it 'sets default maps' do
|
||||||
expect(presenter.reblogs_map).to eq default_map
|
expect(presenter).to have_attributes(
|
||||||
expect(presenter.favourites_map).to eq default_map
|
reblogs_map: eq(default_map),
|
||||||
expect(presenter.bookmarks_map).to eq default_map
|
favourites_map: eq(default_map),
|
||||||
expect(presenter.mutes_map).to eq default_map
|
bookmarks_map: eq(default_map),
|
||||||
expect(presenter.pins_map).to eq default_map
|
mutes_map: eq(default_map),
|
||||||
|
pins_map: eq(default_map)
|
||||||
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -80,18 +82,30 @@ RSpec.describe StatusRelationshipsPresenter do
|
||||||
|
|
||||||
it 'sets @filters_map to filter top-level status' do
|
it 'sets @filters_map to filter top-level status' do
|
||||||
matched_filters = presenter.filters_map[statuses[0].id]
|
matched_filters = presenter.filters_map[statuses[0].id]
|
||||||
expect(matched_filters.size).to eq 1
|
|
||||||
|
|
||||||
expect(matched_filters[0].filter.title).to eq 'filter1'
|
expect(matched_filters)
|
||||||
expect(matched_filters[0].keyword_matches).to eq ['banned']
|
.to be_an(Array)
|
||||||
|
.and have_attributes(size: 1)
|
||||||
|
.and contain_exactly(
|
||||||
|
have_attributes(
|
||||||
|
filter: have_attributes(title: 'filter1'),
|
||||||
|
keyword_matches: contain_exactly('banned')
|
||||||
|
)
|
||||||
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'sets @filters_map to filter reblogged status' do
|
it 'sets @filters_map to filter reblogged status' do
|
||||||
matched_filters = presenter.filters_map[statuses[1].reblog_of_id]
|
matched_filters = presenter.filters_map[statuses[1].reblog_of_id]
|
||||||
expect(matched_filters.size).to eq 1
|
|
||||||
|
|
||||||
expect(matched_filters[0].filter.title).to eq 'filter1'
|
expect(matched_filters)
|
||||||
expect(matched_filters[0].keyword_matches).to eq ['irrelevant']
|
.to be_an(Array)
|
||||||
|
.and have_attributes(size: 1)
|
||||||
|
.and contain_exactly(
|
||||||
|
have_attributes(
|
||||||
|
filter: have_attributes(title: 'filter1'),
|
||||||
|
keyword_matches: contain_exactly('irrelevant')
|
||||||
|
)
|
||||||
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -107,18 +121,30 @@ RSpec.describe StatusRelationshipsPresenter do
|
||||||
|
|
||||||
it 'sets @filters_map to filter top-level status' do
|
it 'sets @filters_map to filter top-level status' do
|
||||||
matched_filters = presenter.filters_map[statuses[0].id]
|
matched_filters = presenter.filters_map[statuses[0].id]
|
||||||
expect(matched_filters.size).to eq 1
|
|
||||||
|
|
||||||
expect(matched_filters[0].filter.title).to eq 'filter1'
|
expect(matched_filters)
|
||||||
expect(matched_filters[0].status_matches).to eq [statuses[0].id]
|
.to be_an(Array)
|
||||||
|
.and have_attributes(size: 1)
|
||||||
|
.and contain_exactly(
|
||||||
|
have_attributes(
|
||||||
|
filter: have_attributes(title: 'filter1'),
|
||||||
|
status_matches: contain_exactly(statuses.first.id)
|
||||||
|
)
|
||||||
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'sets @filters_map to filter reblogged status' do
|
it 'sets @filters_map to filter reblogged status' do
|
||||||
matched_filters = presenter.filters_map[statuses[1].reblog_of_id]
|
matched_filters = presenter.filters_map[statuses[1].reblog_of_id]
|
||||||
expect(matched_filters.size).to eq 1
|
|
||||||
|
|
||||||
expect(matched_filters[0].filter.title).to eq 'filter1'
|
expect(matched_filters)
|
||||||
expect(matched_filters[0].status_matches).to eq [statuses[1].reblog_of_id]
|
.to be_an(Array)
|
||||||
|
.and have_attributes(size: 1)
|
||||||
|
.and contain_exactly(
|
||||||
|
have_attributes(
|
||||||
|
filter: have_attributes(title: 'filter1'),
|
||||||
|
status_matches: contain_exactly(statuses.second.reblog_of_id)
|
||||||
|
)
|
||||||
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue