Use `subject` in blacklist email validator spec (#29211)
parent
fc4f823464
commit
1df2ffc3ee
|
@ -4,7 +4,7 @@ require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe BlacklistedEmailValidator do
|
RSpec.describe BlacklistedEmailValidator do
|
||||||
describe '#validate' 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(: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) }
|
let(:errors) { instance_double(ActiveModel::Errors, add: nil) }
|
||||||
|
@ -18,7 +18,8 @@ RSpec.describe BlacklistedEmailValidator do
|
||||||
let(:blocked_email) { true }
|
let(:blocked_email) { true }
|
||||||
|
|
||||||
it 'adds error' do
|
it 'adds error' do
|
||||||
described_class.new.validate(user)
|
subject
|
||||||
|
|
||||||
expect(errors).to have_received(:add).with(:email, :blocked).once
|
expect(errors).to have_received(:add).with(:email, :blocked).once
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -27,7 +28,8 @@ RSpec.describe BlacklistedEmailValidator do
|
||||||
let(:blocked_email) { false }
|
let(:blocked_email) { false }
|
||||||
|
|
||||||
it 'does not add errors' do
|
it 'does not add errors' do
|
||||||
described_class.new.validate(user)
|
subject
|
||||||
|
|
||||||
expect(errors).to_not have_received(:add)
|
expect(errors).to_not have_received(:add)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -39,7 +41,8 @@ RSpec.describe BlacklistedEmailValidator do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'adds error' do
|
it 'adds error' do
|
||||||
described_class.new.validate(user)
|
subject
|
||||||
|
|
||||||
expect(errors).to have_received(:add).with(:email, :taken).once
|
expect(errors).to have_received(:add).with(:email, :taken).once
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue