Sha256: 9dd797c469f3400ca68119ef72f84bfafc0759611a9c45d6053fe5a6bb90ed94
Contents?: true
Size: 1.19 KB
Versions: 6
Compression:
Stored size: 1.19 KB
Contents
module LightServiceExt RSpec.describe ApplicationContract do let(:contract_class) do Class.new(ApplicationContract) do params do required(:email).maybe(:string) end rule(:email).validate(:email) end end describe '.keys' do it 'returns schema rule keys' do expect(contract_class.keys).to match_array([:email]) end end describe '.register_macro' do describe ':email' do let(:email) { nil } let(:params) { { email: email } } subject(:result) { contract_class.new.call(params) } context 'with valid email' do let(:email) { 'email@domain.com' } it 'returns success' do expect(result).to be_success end end context 'with invalid email' do let(:email) { 'emaildomain.com' } it 'returns failure' do expect(result).to be_failure errors = result.errors.to_h expect(errors.keys).to match_array([:email]) error_messages = errors[:email] expect(error_messages).to match_array(["must be a valid email"]) end end end end end end
Version data entries
6 entries across 6 versions & 1 rubygems