Skip to content

Commit 5e542ea

Browse files
committed
Replace faulty spec with something more useful
Not sure what the intention was but this spec did not test any faraday error handling. What actually happened was that HTTPTransport really tried to hit the API and ended up with error. We *do not* want to hit any APIs like that in specs, this causes instability of the spec suite. That's why I added webmock to ensure we're not sending any HTTP requests in specs.
1 parent b933d4b commit 5e542ea

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

sentry-ruby/lib/sentry/transport/http_transport.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ class HTTPTransport < Transport
2323
Zlib::BufError, Errno::EHOSTUNREACH, Errno::ECONNREFUSED
2424
].freeze
2525

26-
2726
def initialize(*args)
2827
super
2928
log_debug("Sentry HTTP Transport will connect to #{@dsn.server}") if @dsn

sentry-ruby/spec/sentry/transport_spec.rb

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -531,11 +531,14 @@
531531
end
532532
end
533533

534-
context "with Faraday::Error" do
534+
context "with an HTTP exception" do
535+
before do
536+
stub_request(:post, "http://sentry.localdomain:80/sentry/api/42/envelope/").
537+
to_raise(Timeout::Error)
538+
end
539+
535540
it "raises the error" do
536-
expect do
537-
subject.send_event(event)
538-
end.to raise_error(Sentry::ExternalError)
541+
expect { subject.send_event(event) }.to raise_error(Sentry::ExternalError)
539542
end
540543
end
541544
end

0 commit comments

Comments
 (0)