Skip to content

Commit

Permalink
Add core assertions for assert_warn
Browse files Browse the repository at this point in the history
  • Loading branch information
nevans committed May 8, 2024
1 parent 6b2de76 commit cb6c277
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ group :development do
gem "bundler"
gem "rake"
gem "test-unit"
gem "test-unit-ruby-core", git: "https://github.com/ruby/test-unit-ruby-core"
end
16 changes: 16 additions & 0 deletions test/net/smtp/test_smtp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

require 'net/smtp'
require 'test/unit'
require "core_assertions"

Test::Unit::TestCase.include Test::Unit::CoreAssertions

module Net
class TestSMTP < Test::Unit::TestCase
Expand Down Expand Up @@ -628,6 +631,19 @@ def test_quit!
smtp.quit!
end

def test_quit_and_warn
server = FakeServer.start
def server.quit
@sock.puts "400 BUSY\r\n"
end
smtp = Net::SMTP.start 'localhost', server.port
assert_warn(/SMTPServerBusy during .*#quit!/i) do
smtp.quit!(exception: :warn)
end
assert_equal "QUIT\r\n", server.commands.last
refute smtp.started?
end

def test_quit_and_reraise
server = FakeServer.start
def server.quit
Expand Down

0 comments on commit cb6c277

Please sign in to comment.