From 1df2ffc3eee80ab53de00d076658dd546515a9bd Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Fri, 16 Feb 2024 02:42:03 -0500 Subject: [PATCH] Use `subject` in blacklist email validator spec (#29211) --- spec/validators/blacklisted_email_validator_spec.rb | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/spec/validators/blacklisted_email_validator_spec.rb b/spec/validators/blacklisted_email_validator_spec.rb index 6292f0737e..86760df2e7 100644 --- a/spec/validators/blacklisted_email_validator_spec.rb +++ b/spec/validators/blacklisted_email_validator_spec.rb @@ -4,7 +4,7 @@ require 'rails_helper' RSpec.describe BlacklistedEmailValidator do describe '#validate' do - subject { described_class.new.validate(user); errors } + subject { described_class.new.validate(user) } let(:user) { instance_double(User, email: 'info@mail.com', sign_up_ip: '1.2.3.4', errors: errors) } let(:errors) { instance_double(ActiveModel::Errors, add: nil) } @@ -18,7 +18,8 @@ RSpec.describe BlacklistedEmailValidator do let(:blocked_email) { true } it 'adds error' do - described_class.new.validate(user) + subject + expect(errors).to have_received(:add).with(:email, :blocked).once end end @@ -27,7 +28,8 @@ RSpec.describe BlacklistedEmailValidator do let(:blocked_email) { false } it 'does not add errors' do - described_class.new.validate(user) + subject + expect(errors).to_not have_received(:add) end @@ -39,7 +41,8 @@ RSpec.describe BlacklistedEmailValidator do end it 'adds error' do - described_class.new.validate(user) + subject + expect(errors).to have_received(:add).with(:email, :taken).once end end