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 f952e74 commit ec73e62
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ jobs:
- name: Install dependencies
run: bundle install
- name: Run test
run: rake test
run: bundle exec rake test
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 ec73e62

Please sign in to comment.