diff --git a/lib/eve_online/esi/base.rb b/lib/eve_online/esi/base.rb index 1f405106..6d8b5f10 100644 --- a/lib/eve_online/esi/base.rb +++ b/lib/eve_online/esi/base.rb @@ -137,7 +137,7 @@ def query def resource @resource ||= if http_method == :get - connection.public_send(http_method, uri) + connection.get(uri) elsif http_method == :post connection.public_send(http_method, uri, payload) end diff --git a/spec/eve_online/esi/base_spec.rb b/spec/eve_online/esi/base_spec.rb index 2deb5895..a9da8094 100644 --- a/spec/eve_online/esi/base_spec.rb +++ b/spec/eve_online/esi/base_spec.rb @@ -491,33 +491,33 @@ let(:connection) { double } - before { expect(subject).to receive(:http_method).and_return(http_method).twice } + before { expect(subject).to receive(:http_method).and_return(http_method) } before { expect(subject).to receive(:uri).and_return(uri) } before { expect(subject).to receive(:connection).and_return(connection) } - before { expect(connection).to receive(:public_send).with(http_method, uri).and_raise(Faraday::ConnectionFailed, nil) } + before { expect(connection).to receive(:get).with(uri).and_raise(Faraday::ConnectionFailed, nil) } specify { expect { subject.resource }.to raise_error(EveOnline::Exceptions::Timeout) } end context "when throw Faraday::TimeoutError" do - # let(:http_method) { double } - # - # let(:uri) { double } - # - # let(:connection) { double } - # - # before { expect(subject).to receive(:http_method).and_return(http_method) } - # - # before { expect(subject).to receive(:uri).and_return(uri) } - # - # before { expect(subject).to receive(:connection).and_return(connection) } - # - # before { expect(connection).to receive(:public_send).with(http_method, uri).and_raise(Faraday::TimeoutError, nil) } - # - # specify { expect { subject.resource }.to raise_error(EveOnline::Exceptions::Timeout) } + let(:http_method) { :get } + + let(:uri) { double } + + let(:connection) { double } + + before { expect(subject).to receive(:http_method).and_return(http_method) } + + before { expect(subject).to receive(:uri).and_return(uri) } + + before { expect(subject).to receive(:connection).and_return(connection) } + + before { expect(connection).to receive(:get).with(uri).and_raise(Faraday::TimeoutError, nil) } + + specify { expect { subject.resource }.to raise_error(EveOnline::Exceptions::Timeout) } end end