Module: Cucumber::FeatureElement

Included in:
Ast::Background, Ast::Scenario, Ast::ScenarioOutline
Defined in:
lib/cucumber/ast/feature_element.rb

Instance Method Summary collapse

Instance Method Details

#attach_steps(steps) ⇒ Object



3
4
5
# File 'lib/cucumber/ast/feature_element.rb', line 3

def attach_steps(steps)
  steps.each {|step| step.feature_element = self}
end

#backtrace_line(name = "#{@keyword} #{@name}", line = @line) ⇒ Object



27
28
29
# File 'lib/cucumber/ast/feature_element.rb', line 27

def backtrace_line(name = "#{@keyword} #{@name}", line = @line)
  @feature.backtrace_line(name, line) if @feature
end

#file_colon_line(line = @line) ⇒ Object



7
8
9
# File 'lib/cucumber/ast/feature_element.rb', line 7

def file_colon_line(line = @line)
  @feature.file_colon_line(line) if @feature
end

#has_tags?(tags) ⇒ Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/cucumber/ast/feature_element.rb', line 19

def has_tags?(tags)
  @tags.has_tags?(tags) || @feature.has_tags?(tags)
end

#matches_lines?(lines) ⇒ Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/cucumber/ast/feature_element.rb', line 15

def matches_lines?(lines)
  lines.index(@line) || @steps.matches_lines?(lines) || @tags.matches_lines?(lines)
end

#matches_scenario_names?(scenario_names) ⇒ Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/cucumber/ast/feature_element.rb', line 23

def matches_scenario_names?(scenario_names)
  scenario_names.detect{|name| name == @name}
end

#max_line_lengthObject



35
36
37
# File 'lib/cucumber/ast/feature_element.rb', line 35

def max_line_length
  @steps.max_line_length(self)
end

#previous_step(step) ⇒ Object

TODO: Remove when we use StepCollection everywhere



40
41
42
43
# File 'lib/cucumber/ast/feature_element.rb', line 40

def previous_step(step)
  i = @steps.index(step) || -1
  @steps[i-1]
end

#source_indent(text_length) ⇒ Object



31
32
33
# File 'lib/cucumber/ast/feature_element.rb', line 31

def source_indent(text_length)
  max_line_length - text_length
end

#text_lengthObject



11
12
13
# File 'lib/cucumber/ast/feature_element.rb', line 11

def text_length
  @keyword.jlength + @name.jlength
end