From 15f6336cddcf342ad7c6b79e443d1a39bee3f7a1 Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Fri, 25 Oct 2024 04:02:13 -0400 Subject: [PATCH] Simplify model validation specs for `AccountMigration` (#32494) --- spec/models/account_migration_spec.rb | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/spec/models/account_migration_spec.rb b/spec/models/account_migration_spec.rb index d658915ce3..b92771e8f5 100644 --- a/spec/models/account_migration_spec.rb +++ b/spec/models/account_migration_spec.rb @@ -9,8 +9,8 @@ RSpec.describe AccountMigration do end end - describe 'validations' do - subject { described_class.new(account: source_account, acct: target_acct) } + describe 'Validations' do + subject { Fabricate.build :account_migration, account: source_account } let(:source_account) { Fabricate(:account) } let(:target_acct) { target_account.acct } @@ -26,9 +26,7 @@ RSpec.describe AccountMigration do allow(service_double).to receive(:call).with(target_acct, anything).and_return(target_account) end - it 'passes validations' do - expect(subject).to be_valid - end + it { is_expected.to allow_value(target_account.acct).for(:acct) } end context 'with unresolvable account' do @@ -40,17 +38,13 @@ RSpec.describe AccountMigration do allow(service_double).to receive(:call).with(target_acct, anything).and_return(nil) end - it 'has errors on acct field' do - expect(subject).to model_have_error_on_field(:acct) - end + it { is_expected.to_not allow_value(target_acct).for(:acct) } end context 'with a space in the domain part' do let(:target_acct) { 'target@remote. org' } - it 'has errors on acct field' do - expect(subject).to model_have_error_on_field(:acct) - end + it { is_expected.to_not allow_value(target_acct).for(:acct) } end end end