Sha256: 6780a8dfa2bb2714c972891ca8a3b039ff751696f61cda37ba05633d61f83d65
Contents?: true
Size: 986 Bytes
Versions: 3
Compression:
Stored size: 986 Bytes
Contents
module LightServiceExt RSpec.describe ApplicationValidatorAction do let(:action_class) do Class.new(ApplicationValidatorAction) do self.contract_class = Class.new(ApplicationContract) do params { required(:key).filled(:string) } end end end let(:value) { 'some-value' } let(:input) { { key: value } } let(:ctx) { ApplicationContext.make_with_defaults(input) } subject(:context) { action_class.execute(ctx) } context 'with valid attributes' do it 'returns promised params and empty errors' do expect(context.success?).to be(true) expect(context.errors).to be_empty expect(context[:params].keys).to eql(%i[key]) end end context 'with invalid attributes' do let(:value) { nil } it 'returns promised params and filled in errors' do expect(context).to be_failure expect(context.errors).to eql(key: 'must be filled') end end end end
Version data entries
3 entries across 3 versions & 1 rubygems