Class: SpecGuard::RSpec::Transport::Result
- Inherits:
-
Struct
- Object
- Struct
- SpecGuard::RSpec::Transport::Result
- Defined in:
- lib/specguard/rspec/transport.rb
Overview
What the ingest endpoint said, in the one form the caller has to handle.
outcome is one of:
:success a 2xx. `code` carries it (202 in the happy path).
:rejected a non-2xx. `code` carries it; nothing was raised.
:failed an exception was raised. `error` carries it.
Constant Summary collapse
- ADVICE =
The status codes worth spelling out, because each implies a different thing for the reader to do. A 401 means "rotate or fix the key"; a 400 means "the payload this gem built was refused", which is a bug report and not a credentials problem. Printing a bare number would leave a CI operator to guess which of the two they are looking at.
{ 400 => "the endpoint rejected the payload", 401 => "the API key was not accepted", 403 => "this API key may not write to that repository", 404 => "no ingest endpoint at that URL — check SPECGUARD_ENDPOINT", 413 => "the payload was too large for the endpoint", 429 => "rate limited by the endpoint" }.freeze
Instance Attribute Summary collapse
-
#code ⇒ Object
Returns the value of attribute code.
-
#error ⇒ Object
Returns the value of attribute error.
-
#outcome ⇒ Object
Returns the value of attribute outcome.
Instance Method Summary collapse
-
#reason ⇒ String?
A single clause naming what went wrong, for the one stderr line a run is allowed.
- #success? ⇒ Boolean
Instance Attribute Details
#code ⇒ Object
Returns the value of attribute code
150 151 152 |
# File 'lib/specguard/rspec/transport.rb', line 150 def code @code end |
#error ⇒ Object
Returns the value of attribute error
150 151 152 |
# File 'lib/specguard/rspec/transport.rb', line 150 def error @error end |
#outcome ⇒ Object
Returns the value of attribute outcome
150 151 152 |
# File 'lib/specguard/rspec/transport.rb', line 150 def outcome @outcome end |
Instance Method Details
#reason ⇒ String?
A single clause naming what went wrong, for the one stderr line a run
is allowed. nil on success, because there is nothing to say.
171 172 173 174 175 176 177 |
# File 'lib/specguard/rspec/transport.rb', line 171 def reason case outcome when :success then nil when :rejected then [+"HTTP #{code}", ADVICE[code]].compact.join(" — ") else "#{error.class}: #{error.}" end end |
#success? ⇒ Boolean
165 |
# File 'lib/specguard/rspec/transport.rb', line 165 def success? = outcome == :success |