spec/rest/orders_spec.rb in finapps-2.2.17 vs spec/rest/orders_spec.rb in finapps-2.2.18

- old
+ new

@@ -131,6 +131,35 @@ it { expect { update }.not_to raise_error } it('results is nil') { expect(results).to be_nil } it('error messages array is populated') { expect(error_messages.first.downcase).to eq('invalid request body') } end end + + describe '#destroy' do + subject(:orders) { FinApps::REST::Orders.new(client) } + + context 'when missing id' do + let(:destroy) { subject.destroy(nil) } + it('returns missing argument error') { expect { destroy }.to raise_error(FinAppsCore::MissingArgumentsError) } + end + + context 'when invalid id is provided' do + let(:destroy) { subject.destroy(:invalid_id) } + let(:results) { destroy[RESULTS] } + let(:error_messages) { destroy[ERROR_MESSAGES] } + + it { expect { destroy }.not_to raise_error } + it('results is nil') { expect(results).to be_nil } + it('error messages array is populated') { expect(error_messages.first.downcase).to eq('resource not found') } + end + + context 'for valid id' do + let(:destroy) { subject.destroy(:valid_id) } + let(:results) { destroy[RESULTS] } + let(:error_messages) { destroy[ERROR_MESSAGES] } + + it { expect { destroy }.not_to raise_error } + it('results is nil') { expect(results).to be_nil } + it('error_messages array is empty') { expect(error_messages).to eq([]) } + end + end end