Skip to content

Commit f79bbb5

Browse files
committed
Add core assertions for assert_warn
1 parent 87aca64 commit f79bbb5

3 files changed

Lines changed: 18 additions & 1 deletion

File tree

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,4 @@ jobs:
2626
- name: Install dependencies
2727
run: bundle install
2828
- name: Run test
29-
run: rake test
29+
run: bundle exec rake test

Gemfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ group :development do
66
gem "bundler"
77
gem "rake"
88
gem "test-unit"
9+
gem "test-unit-ruby-core", git: "https://github.com/ruby/test-unit-ruby-core"
910
end

test/net/smtp/test_smtp.rb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
require 'net/smtp'
44
require 'test/unit'
5+
require "core_assertions"
6+
7+
Test::Unit::TestCase.include Test::Unit::CoreAssertions
58

69
module Net
710
class TestSMTP < Test::Unit::TestCase
@@ -628,6 +631,19 @@ def test_quit!
628631
smtp.quit!
629632
end
630633

634+
def test_quit_and_warn
635+
server = FakeServer.start
636+
def server.quit
637+
@sock.puts "400 BUSY\r\n"
638+
end
639+
smtp = Net::SMTP.start 'localhost', server.port
640+
assert_warn(/SMTPServerBusy during .*#quit!/i) do
641+
smtp.quit!(exception: :warn)
642+
end
643+
assert_equal "QUIT\r\n", server.commands.last
644+
refute smtp.started?
645+
end
646+
631647
def test_quit_and_reraise
632648
server = FakeServer.start
633649
def server.quit

0 commit comments

Comments
 (0)