From d71883f55a3019a005ee60f48cbc4be262393fb3 Mon Sep 17 00:00:00 2001 From: adfoster-r7 Date: Mon, 18 Sep 2023 16:40:47 +0100 Subject: [PATCH] Fix broken test suite when running in small console window --- spec/spec_helper.rb | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index f3e60d788a02..c762e5384298 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -164,6 +164,15 @@ Msf::FeatureManager.instance.set(Msf::FeatureManager::DATASTORE_FALLBACKS, true) end end + + # rex-text table performs word wrapping on msfconsole tables: + # https://github.com/rapid7/rex-text/blob/11e59416f7d8cce18b8b8b9893b3277e6ad0bea1/lib/rex/text/wrapped_table.rb#L74 + # This can cause some integration tests to fail if the tests are run from smaller consoles + # This mock will ensure that the tests run without word-wrapping. + config.before(:each) do + mock_io_console = double(:console, winsize: { rows: 30, columns: ::BigDecimal::INFINITY }.values) + allow(::IO).to receive(:console).and_return(mock_io_console) + end end if load_metasploit