diff --git a/lib/public/verb.rb b/lib/public/verb.rb index 93bf171..914db21 100644 --- a/lib/public/verb.rb +++ b/lib/public/verb.rb @@ -78,7 +78,7 @@ def dump sig { params(spec: T.untyped).returns(Verb) } def self.load(spec) - id = spec['id'].to_sym + id = spec['id']&.to_sym raise ArgumentError, "Missing verb ID: #{id}" if id.nil? dto = spec['dto'] diff --git a/spec/public/resource_spec.rb b/spec/public/resource_spec.rb index dc40bea..1587c93 100644 --- a/spec/public/resource_spec.rb +++ b/spec/public/resource_spec.rb @@ -64,6 +64,15 @@ it { expect(subject).to be_a(described_class) } + context 'when verb has no id' do + let(:dump) { resource.dump } + let(:spec) do + resource.dump.tap { |s| s['verbs']['copy'].delete('id') } + end + + it { expect { subject }.to raise_error(ArgumentError) } + end + describe 'paginateable' do context 'when the paginateable property is not provided' do it 'is true by default' do