test/messenging_test.rb in cliutils-1.0.3 vs test/messenging_test.rb in cliutils-1.0.4
- old
+ new
@@ -1,6 +1,5 @@
-require 'fileutils'
require 'logger'
require 'test/unit'
require File.join(File.dirname(__FILE__), '..', 'lib/cliutils/ext/String+Extensions')
require File.join(File.dirname(__FILE__), '..', 'lib/cliutils/pretty-io')
@@ -25,14 +24,14 @@
assert_output('# This is success'.green + "\n") { messenger.send(:success, 'This is success') }
assert_output('# This is warn'.yellow + "\n") { messenger.send(:warn, 'This is warn') }
end
def test_wrapping
- CLIUtils::PrettyIO.wrap_at(35)
+ CLIUtils::PrettyIO.wrap_char_limit = 35
long_str = 'This is a really long string that should wrap itself at some point, okay?'
- expected_str = long_str.gsub(/\n/, ' ').gsub(/(.{1,#{CLIUtils::PrettyIO.wrap_limit - 2}})(\s+|$)/, "# \\1\n").strip
+ expected_str = long_str.gsub(/\n/, ' ').gsub(/(.{1,#{CLIUtils::PrettyIO.wrap_char_limit - 2}})(\s+|$)/, "# \\1\n").strip
assert_output(expected_str.blue + "\n") { messenger.send(:info, long_str) }
end
def test_attach_detach
file_logger = Logger.new(@file1path)
@@ -45,9 +44,9 @@
messenger.send(:error, 'Error test')
messenger.detach(file_logger)
messenger.send(:warn, 'Warn test')
File.open(@file1path, 'r') do |f|
- assert_output("INFO: Info test\nERROR: Error test\n") { puts f.read.lines[1..-1].join }
+ assert_output("INFO: Info test\nERROR: Error test\n") { puts f.read.lines.to_a[1..-1].join }
end
end
end