From 20fa46296d61f578a3eaf03bd769dfbac98299c9 Mon Sep 17 00:00:00 2001 From: Daniel Duvall Date: Tue, 19 Apr 2016 13:10:37 -0700 Subject: [PATCH] Avoid negative `Cucumber::Ast::HasSteps#source_indent` (#926) Some monkey patched implementations of `String#indent`, such as Active Support's, do not handle negative values (see issue #620). This behavior isn't strictly a bug in Cucumber but a lower bound of 0 in `#source_indent` would mitigate the occurrences of related errors. --- lib/cucumber/ast/has_steps.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/cucumber/ast/has_steps.rb b/lib/cucumber/ast/has_steps.rb index c6744aff3f..30ac18f46a 100644 --- a/lib/cucumber/ast/has_steps.rb +++ b/lib/cucumber/ast/has_steps.rb @@ -46,7 +46,7 @@ def backtrace_line(step_name = "#{@keyword}: #{name}", line = self.line) end def source_indent(text_length) - max_line_length - text_length + [max_line_length - text_length, 0].max end def max_line_length