Sha256: 9b689df871468ea131a9773495b36c631c34b96168e2b4d4984ec8e63fbcd311
Contents?: true
Size: 1.03 KB
Versions: 2
Compression:
Stored size: 1.03 KB
Contents
require 'spec_helper' RSpec.describe Mailgun::CommunicationError do describe '.new' do context "when the Response body doesn't have a `message` property" do it "doesn't raise an error" do expect do described_class.new('Boom!', Mailgun::Response.from_hash({ code: 401, body: '{}' })) end.not_to raise_error end context "when the Response body has an `Error` property" do it "uses the `Error` property as the API message" do subject = described_class.new('Boom!', Mailgun::Response.from_hash({ code: 401, body: '{"Error":"unauthorized"}' })) expect(subject.message).to eq("Boom!: unauthorized") end end context "when the Response body has an `error` property" do it "uses the `Error` property as the API message" do subject = described_class.new('Boom!', Mailgun::Response.from_hash({ code: 401, body: '{"error":"not found"}' })) expect(subject.message).to eq("Boom!: not found") end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
mailgun-ruby-1.2.16 | spec/unit/exceptions/exceptions_spec.rb |
mailgun-ruby-1.2.15 | spec/unit/exceptions/exceptions_spec.rb |