Sha256: 27930a5fc2af2b2c5150cb41ffd385ba63f9c81705e84838bfb6c63cda502e24

Contents?: true

Size: 1.24 KB

Versions: 15

Compression:

Stored size: 1.24 KB

Contents

module ForestLiana
  describe ForestApiRequester do
    describe 'when an error occurs' do
      before do
        allow(HTTParty).to receive(:get).and_raise(StandardError, 'Custom error message')
        allow(HTTParty).to receive(:post).and_raise(StandardError, 'Custom error message')
      end

      describe 'Get' do
        it 'should keep the original error and raise it with backtrace' do
          err = nil

          begin
            ForestApiRequester.get('/incorrect_url')
          rescue => error
            err = error
          end

          expect(error)
            .to be_instance_of(StandardError)
            .and have_attributes(:message => 'Custom error message')
            .and have_attributes(:backtrace => be_truthy)
        end
      end

      describe 'Post' do
        it 'should keep the original error and raise it with backtrace' do
          err = nil

          begin
            ForestApiRequester.post('/incorrect_url')
          rescue => error
            err = error
          end

          expect(error)
            .to be_instance_of(StandardError)
            .and have_attributes(:message => 'Custom error message')
            .and have_attributes(:backtrace => be_truthy)
        end
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
forest_liana-9.11.1 spec/services/forest_liana/forest_api_requester_spec.rb
forest_liana-9.11.0 spec/services/forest_liana/forest_api_requester_spec.rb
forest_liana-9.10.6 spec/services/forest_liana/forest_api_requester_spec.rb
forest_liana-9.10.5 spec/services/forest_liana/forest_api_requester_spec.rb
forest_liana-9.10.4 spec/services/forest_liana/forest_api_requester_spec.rb
forest_liana-9.10.3 spec/services/forest_liana/forest_api_requester_spec.rb
forest_liana-9.10.2 spec/services/forest_liana/forest_api_requester_spec.rb
forest_liana-9.10.1 spec/services/forest_liana/forest_api_requester_spec.rb
forest_liana-9.10.0 spec/services/forest_liana/forest_api_requester_spec.rb
forest_liana-9.9.1 spec/services/forest_liana/forest_api_requester_spec.rb
forest_liana-9.9.0 spec/services/forest_liana/forest_api_requester_spec.rb
forest_liana-9.8.0 spec/services/forest_liana/forest_api_requester_spec.rb
forest_liana-9.7.0 spec/services/forest_liana/forest_api_requester_spec.rb
forest_liana-9.6.4 spec/services/forest_liana/forest_api_requester_spec.rb
forest_liana-9.6.3 spec/services/forest_liana/forest_api_requester_spec.rb