From c6ea46d76f9c34947819146aa4d22ce3ac0bda70 Mon Sep 17 00:00:00 2001 From: Anthony Cook Date: Wed, 23 Feb 2022 10:45:47 -0800 Subject: [PATCH] Create placeholder spec for fixed index out of bounds error --- spec/formatter_spec.cr | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 spec/formatter_spec.cr diff --git a/spec/formatter_spec.cr b/spec/formatter_spec.cr new file mode 100644 index 0000000..679ebf5 --- /dev/null +++ b/spec/formatter_spec.cr @@ -0,0 +1,26 @@ +require "./spec_helper" +require "../src/entry" +require "../src/options" + +def new_formatter(path, options = Lister::Options.new) + Lister::Formatter.new(path, options) +end + +describe Lister::Formatter do + klass = Lister::Formatter + + describe "#line" do + pending "should not attempt to insert color codes past the end of the line" do + long_filename = "asdfghjklqwertyuiopzxcvbnm" + opts = Lister::Options.new + # stub out terminal width somehow + opts.terminal.width + # make entry + entry = Entry.new long_filename, opts + formatter = new_formatter(long_filename, opts) + formatter.line(entry, entry.name.size, 0) + # should generate a filename much lonager than the line, which before the fix would error out + # like "index out of range" for String#insert + end + end +end