diff options
| author | Adam Malczewski <[email protected]> | 2026-03-31 20:22:45 +0900 |
|---|---|---|
| committer | Adam Malczewski <[email protected]> | 2026-03-31 20:22:45 +0900 |
| commit | 3e32dec579fbdedec8c7ddb881207b25bb342e60 (patch) | |
| tree | 9db02b8f744fa2c1203b78e6c84a62f770bc1e73 /spec/dispatch/adapter/errors_spec.rb | |
| parent | a1eed75083df6afd4895a4438309319d2a9e5523 (diff) | |
| download | dispatch-adapter-copilot-3e32dec579fbdedec8c7ddb881207b25bb342e60.tar.gz dispatch-adapter-copilot-3e32dec579fbdedec8c7ddb881207b25bb342e60.zip | |
imp
Diffstat (limited to 'spec/dispatch/adapter/errors_spec.rb')
| -rw-r--r-- | spec/dispatch/adapter/errors_spec.rb | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/spec/dispatch/adapter/errors_spec.rb b/spec/dispatch/adapter/errors_spec.rb new file mode 100644 index 0000000..77c8389 --- /dev/null +++ b/spec/dispatch/adapter/errors_spec.rb @@ -0,0 +1,69 @@ +# frozen_string_literal: true + +RSpec.describe Dispatch::Adapter::Error do + it "carries message, status_code, and provider" do + error = described_class.new("test error", status_code: 500, provider: "TestProvider") + expect(error.message).to eq("test error") + expect(error.status_code).to eq(500) + expect(error.provider).to eq("TestProvider") + end + + it "defaults status_code and provider to nil" do + error = described_class.new("simple error") + expect(error.status_code).to be_nil + expect(error.provider).to be_nil + end + + it "inherits from StandardError" do + expect(described_class.ancestors).to include(StandardError) + end + + it "can be rescued as StandardError" do + expect { + raise described_class.new("test") + }.to raise_error(StandardError) + end +end + +RSpec.describe Dispatch::Adapter::AuthenticationError do + it "inherits from Error" do + expect(described_class.ancestors).to include(Dispatch::Adapter::Error) + end +end + +RSpec.describe Dispatch::Adapter::RateLimitError do + it "carries retry_after" do + error = described_class.new("rate limited", status_code: 429, provider: "Test", retry_after: 30) + expect(error.retry_after).to eq(30) + expect(error.status_code).to eq(429) + end + + it "defaults retry_after to nil" do + error = described_class.new("rate limited") + expect(error.retry_after).to be_nil + end + + it "is rescuable as Dispatch::Adapter::Error" do + expect { + raise described_class.new("rate limited") + }.to raise_error(Dispatch::Adapter::Error) + end +end + +RSpec.describe Dispatch::Adapter::ServerError do + it "inherits from Error" do + expect(described_class.ancestors).to include(Dispatch::Adapter::Error) + end +end + +RSpec.describe Dispatch::Adapter::RequestError do + it "inherits from Error" do + expect(described_class.ancestors).to include(Dispatch::Adapter::Error) + end +end + +RSpec.describe Dispatch::Adapter::ConnectionError do + it "inherits from Error" do + expect(described_class.ancestors).to include(Dispatch::Adapter::Error) + end +end |
