Skip to content

Commit

Permalink
Use subject in blacklist email validator spec (#29211)
Browse files Browse the repository at this point in the history
  • Loading branch information
mjankowski committed Feb 16, 2024
1 parent fc4f823 commit 1df2ffc
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions spec/validators/blacklisted_email_validator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

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) }
Expand All @@ -18,7 +18,8 @@
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
Expand All @@ -27,7 +28,8 @@
let(:blocked_email) { false }

it 'does not add errors' do
described_class.new.validate(user)
subject

expect(errors).to_not have_received(:add)
end

Expand All @@ -39,7 +41,8 @@
end

it 'adds error' do
described_class.new.validate(user)
subject

expect(errors).to have_received(:add).with(:email, :taken).once
end
end
Expand Down

0 comments on commit 1df2ffc

Please sign in to comment.