Skip to content

Commit

Permalink
Avoid negative #source_indent which blows up in certain cases
Browse files Browse the repository at this point in the history
Some monkey patched implementations of `String#indent`, such as Active
Support's, do not handle negative values (see issue cucumber#620). This behavior
isn't strictly a bug in Cucumber but a lower bound of 0 in
`Cucumber::Ast::HasSteps#source_indent` would avoid these types of
errors from bubbling up.
  • Loading branch information
marxarelli committed Oct 26, 2015
1 parent 2b19d9f commit ce88418
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/cucumber/ast/has_steps.rb
Expand Up @@ -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
Expand Down

0 comments on commit ce88418

Please sign in to comment.