Failure/Error: raise AuthenticationError
UserAuthenticator::AuthenticationError:
UserAuthenticator::AuthenticationError
below codes from user_authenticator_spec
require 'rails_helper'
describe UserAuthenticator do
describe '#perform' do
context 'when code is incorrect' do
it 'should raise an error' do
authenticator = described_class.new('sample_code')
expect(authenticator.perform).to raise_error(AuthenticationError)
expect(authenticator.user).to be_nil
end
end
end
end
and below codes from user_authenticator
class UserAuthenticator
class AuthenticationError < StandardError; end
attr_reader :user
def initialize(code)
end
def perform
raise AuthenticationError
end
end
I change this line code
expect(authenticator.perform).to raise_error(AuthenticationError)
to
expect{ authenticator.perform }.to raise_error(UserAuthenticator::AuthenticationError)
and it's work!