-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Include code into stats last_error message
- Loading branch information
Showing
11 changed files
with
163 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# frozen_string_literal: true | ||
|
||
RSpec.describe NATS::Service::ErrorWrapper do | ||
subject { described_class.new(error) } | ||
|
||
let(:error) { {code: 503, description: "error"} } | ||
|
||
describe "#description" do | ||
it "combines code with message" do | ||
expect(subject.description).to eq("503:error") | ||
end | ||
end | ||
|
||
context "when error is a string" do | ||
let(:error) { "error" } | ||
|
||
it "builds an error from the string" do | ||
expect(subject).to have_attributes(code: 500, message: "error", data: "") | ||
end | ||
end | ||
|
||
context "when error is a hash" do | ||
let(:error) { {code: 503, description: "error", data: "data"} } | ||
|
||
it "builds an error from the hash" do | ||
expect(subject).to have_attributes(code: 503, message: "error", data: "data") | ||
end | ||
end | ||
|
||
context "when error is of Exception" do | ||
let(:error) { StandardError.new("error") } | ||
|
||
it "builds an error from the error" do | ||
expect(subject).to have_attributes(code: 500, message: "error", data: "") | ||
end | ||
end | ||
|
||
context "when error is of ErrorWrapper" do | ||
let(:error) { described_class.new("error") } | ||
|
||
it "builds an error from the wrapper" do | ||
expect(subject).to have_attributes(code: 500, message: "error", data: "") | ||
end | ||
end | ||
|
||
context "when error is a random object" do | ||
let(:error) { [1, 2, 3] } | ||
|
||
it "builds an error from the object" do | ||
expect(subject).to have_attributes(code: 500, message: "[1, 2, 3]", data: "") | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters