DEV: Apply syntax_tree formatting to spec/*

This commit is contained in:
David Taylor
2023-01-09 11:18:21 +00:00
parent 0cf6421716
commit cb932d6ee1
907 changed files with 58693 additions and 45909 deletions

View File

@ -5,93 +5,97 @@ RSpec.describe EmailSettingsExceptionHandler do
it "formats a Net::POPAuthenticationError" do
exception = Net::POPAuthenticationError.new("invalid credentials")
expect(subject.class.friendly_exception_message(exception, "pop.test.com")).to eq(
I18n.t("email_settings.pop3_authentication_error")
I18n.t("email_settings.pop3_authentication_error"),
)
end
it "formats a Net::IMAP::NoResponseError for invalid credentials" do
exception = Net::IMAP::NoResponseError.new(stub(data: stub(text: "Invalid credentials")))
expect(subject.class.friendly_exception_message(exception, "imap.test.com")).to eq(
I18n.t("email_settings.imap_authentication_error")
I18n.t("email_settings.imap_authentication_error"),
)
end
it "formats a general Net::IMAP::NoResponseError" do
exception = Net::IMAP::NoResponseError.new(stub(data: stub(text: "NO bad problem (Failure)")))
expect(subject.class.friendly_exception_message(exception, "imap.test.com")).to eq(
I18n.t("email_settings.imap_no_response_error", message: "NO bad problem")
I18n.t("email_settings.imap_no_response_error", message: "NO bad problem"),
)
end
it "formats a general Net::IMAP::NoResponseError with application-specific password Gmail error" do
exception = Net::IMAP::NoResponseError.new(stub(data: stub(text: "NO Application-specific password required")))
exception =
Net::IMAP::NoResponseError.new(
stub(data: stub(text: "NO Application-specific password required")),
)
expect(subject.class.friendly_exception_message(exception, "imap.gmail.com")).to eq(
I18n.t("email_settings.authentication_error_gmail_app_password")
I18n.t("email_settings.authentication_error_gmail_app_password"),
)
end
it "formats a Net::SMTPAuthenticationError" do
exception = Net::SMTPAuthenticationError.new("invalid credentials")
expect(subject.class.friendly_exception_message(exception, "smtp.test.com")).to eq(
I18n.t("email_settings.smtp_authentication_error")
I18n.t("email_settings.smtp_authentication_error"),
)
end
it "formats a Net::SMTPAuthenticationError with application-specific password Gmail error" do
exception = Net::SMTPAuthenticationError.new(nil, message: "Application-specific password required")
exception =
Net::SMTPAuthenticationError.new(nil, message: "Application-specific password required")
expect(subject.class.friendly_exception_message(exception, "smtp.gmail.com")).to eq(
I18n.t("email_settings.authentication_error_gmail_app_password")
I18n.t("email_settings.authentication_error_gmail_app_password"),
)
end
it "formats a Net::SMTPServerBusy" do
exception = Net::SMTPServerBusy.new("call me maybe later")
expect(subject.class.friendly_exception_message(exception, "smtp.test.com")).to eq(
I18n.t("email_settings.smtp_server_busy_error")
I18n.t("email_settings.smtp_server_busy_error"),
)
end
it "formats a Net::SMTPSyntaxError, Net::SMTPFatalError, and Net::SMTPUnknownError" do
exception = Net::SMTPSyntaxError.new(nil, message: "bad syntax")
expect(subject.class.friendly_exception_message(exception, "smtp.test.com")).to eq(
I18n.t("email_settings.smtp_unhandled_error", message: exception.message)
I18n.t("email_settings.smtp_unhandled_error", message: exception.message),
)
exception = Net::SMTPFatalError.new(nil, message: "fatal")
expect(subject.class.friendly_exception_message(exception, "smtp.test.com")).to eq(
I18n.t("email_settings.smtp_unhandled_error", message: exception.message)
I18n.t("email_settings.smtp_unhandled_error", message: exception.message),
)
exception = Net::SMTPUnknownError.new(nil, message: "unknown")
expect(subject.class.friendly_exception_message(exception, "smtp.test.com")).to eq(
I18n.t("email_settings.smtp_unhandled_error", message: exception.message)
I18n.t("email_settings.smtp_unhandled_error", message: exception.message),
)
end
it "formats a SocketError and Errno::ECONNREFUSED" do
exception = SocketError.new("bad socket")
expect(subject.class.friendly_exception_message(exception, "smtp.test.com")).to eq(
I18n.t("email_settings.connection_error")
I18n.t("email_settings.connection_error"),
)
exception = Errno::ECONNREFUSED.new("no thanks")
expect(subject.class.friendly_exception_message(exception, "smtp.test.com")).to eq(
I18n.t("email_settings.connection_error")
I18n.t("email_settings.connection_error"),
)
end
it "formats a Net::OpenTimeout and Net::ReadTimeout error" do
exception = Net::OpenTimeout.new("timed out")
expect(subject.class.friendly_exception_message(exception, "smtp.test.com")).to eq(
I18n.t("email_settings.timeout_error")
I18n.t("email_settings.timeout_error"),
)
exception = Net::ReadTimeout.new("timed out")
expect(subject.class.friendly_exception_message(exception, "smtp.test.com")).to eq(
I18n.t("email_settings.timeout_error")
I18n.t("email_settings.timeout_error"),
)
end
it "formats unhandled errors" do
exception = StandardError.new("unknown")
expect(subject.class.friendly_exception_message(exception, "smtp.test.com")).to eq(
I18n.t("email_settings.unhandled_error", message: exception.message)
I18n.t("email_settings.unhandled_error", message: exception.message),
)
end
end