From d8d57db55cc6db6036d2e3eb0fbe20a7d7a0f205 Mon Sep 17 00:00:00 2001 From: Phillip Davis Date: Mon, 30 Mar 2026 15:35:45 -0400 Subject: [PATCH] make invisible separator tests less dumb and pass --- test/property/test_invisible_separator.rb | 33 +++++++++++------------ 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/test/property/test_invisible_separator.rb b/test/property/test_invisible_separator.rb index e3994d056e1b2bd37402cf1688846ebf1f607691..aad1f729859f2cdad2355bc6d1f644574f01017b 100644 --- a/test/property/test_invisible_separator.rb +++ b/test/property/test_invisible_separator.rb @@ -12,8 +12,12 @@ class InvisibleSeparatorPropertyTest < Minitest::Test def setup reset_stanzas! reset_redis! + WebMock.reset! end + BW_MESSAGES_URL = + "https://messaging.bandwidth.com/api/v2/users/account/messages" + def test_message_containing_invisible_separator_is_rejected property_of { words = array(range(1, 6)) { sized(range(3, 10)) { string(:alnum) } } @@ -28,11 +32,7 @@ class InvisibleSeparatorPropertyTest < Minitest::Test }.check { |body, dest| reset_stanzas! reset_redis! - - stub_request(:post, BW_MESSAGES_URL).to_return( - status: 201, - body: JSON.dump(id: "bw-msg-stub") - ) + WebMock.reset! m = Blather::Stanza::Message.new("#{dest}@component", body) m.from = "test@example.com" @@ -65,8 +65,14 @@ class InvisibleSeparatorPropertyTest < Minitest::Test }.check { |body, dest| reset_stanzas! reset_redis! - - stub_request(:post, BW_MESSAGES_URL).to_return( + WebMock.reset! + + bw_req = stub_request(:post, BW_MESSAGES_URL).with( + body: hash_including( + to: dest, + text: body + ) + ).to_return( status: 201, body: JSON.dump(id: "bw-msg-stub") ) @@ -75,16 +81,9 @@ class InvisibleSeparatorPropertyTest < Minitest::Test m.from = "test@example.com" process_stanza(m) - written.each do |response| - stanza = Blather::XMPPNode.parse(response.to_xml) - next unless stanza.error? - - error = stanza.find_first("error") - msg = "Clean message rejected as " \ - "recipient-unavailable: #{body.inspect}" - refute_equal "recipient-unavailable", - xmpp_error_name(error), msg - end + assert_empty written, + "Expected no error stanzas for body: #{body.inspect}" + assert_requested bw_req } end em :test_message_without_invisible_separator_is_not_rejected_as_unavailable