spec/client_spec.rb in gull-0.3.1 vs spec/client_spec.rb in gull-0.3.2
- old
+ new
@@ -55,27 +55,49 @@
message = 'Timeout while connecting to NWS web service'
client = Gull::Client.new
expect { client.fetch }.to raise_error(Gull::TimeoutError, message)
end
- it 'should raise own error if http error occurs' do
+ it 'should raise own error if http errors occur' do
stub_request(:get, 'http://alerts.weather.gov/cap/us.php?x=1')
.with(headers: { 'Accept' => '*/*' })
.to_raise(HTTPClient::KeepAliveDisconnected)
- message = 'HTTP error while connecting to NWS web service'
+ message = 'Could not connect to NWS web service'
client = Gull::Client.new
expect { client.fetch }.to raise_error(Gull::HttpError, message) do |error|
expect(error.original).to be_a(HTTPClient::KeepAliveDisconnected)
end
stub_request(:get, 'http://alerts.weather.gov/cap/us.php?x=1')
.with(headers: { 'Accept' => '*/*' })
+ .to_raise(HTTPClient::BadResponseError)
+
+ message = 'Could not connect to NWS web service'
+ client = Gull::Client.new
+ expect { client.fetch }.to raise_error(Gull::HttpError, message) do |error|
+ expect(error.original).to be_a(HTTPClient::BadResponseError)
+ end
+ end
+
+ it 'should raise own error if connection errors occur' do
+ stub_request(:get, 'http://alerts.weather.gov/cap/us.php?x=1')
+ .with(headers: { 'Accept' => '*/*' })
.to_raise(SocketError)
- message = 'HTTP error while connecting to NWS web service'
+ message = 'Could not connect to NWS web service'
client = Gull::Client.new
expect { client.fetch }.to raise_error(Gull::HttpError, message) do |error|
expect(error.original).to be_a(SocketError)
+ end
+
+ stub_request(:get, 'http://alerts.weather.gov/cap/us.php?x=1')
+ .with(headers: { 'Accept' => '*/*' })
+ .to_raise(Errno::ECONNREFUSED)
+
+ message = 'Could not connect to NWS web service'
+ client = Gull::Client.new
+ expect { client.fetch }.to raise_error(Gull::HttpError, message) do |error|
+ expect(error.original).to be_a(Errno::ECONNREFUSED)
end
end
end