lib/cucumber/ast/feature_element.rb in aslakhellesoy-cucumber-0.3.0 vs lib/cucumber/ast/feature_element.rb in aslakhellesoy-cucumber-0.3.0.1
- old
+ new
@@ -1,5 +1,7 @@
+require 'enumerator'
+
module Cucumber
module FeatureElement
def attach_steps(steps)
steps.each {|step| step.feature_element = self}
end
@@ -7,13 +9,27 @@
def file_colon_line(line = @line)
@feature.file_colon_line(line) if @feature
end
def text_length
- @keyword.jlength + @name.jlength
+ name_line_lengths.max
end
+ def first_line_length
+ name_line_lengths[0]
+ end
+
+ def name_line_lengths
+ if @name.empty?
+ [@keyword.jlength]
+ else
+ @name.split("\n").enum_for(:each_with_index).map do |line, line_number|
+ line_number == 0 ? @keyword.jlength + line.jlength : line.jlength + Ast::Step::INDENT - 1 # We -1 as names which are not keyword lines are missing a space between keyword and name
+ end
+ end
+ end
+
def matches_scenario_names?(scenario_names)
scenario_names.detect{|name| name == @name}
end
def backtrace_line(name = "#{@keyword} #{@name}", line = @line)
@@ -29,14 +45,7 @@
end
def accept_hook?(hook)
@tags.accept_hook?(hook)
end
-
- # TODO: Remove when we use StepCollection everywhere
- def previous_step(step)
- i = @steps.index(step) || -1
- @steps[i-1]
- end
-
end
-end
\ No newline at end of file
+end