Module: Cucumber::Ast::FeatureElement

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

Overview

:nodoc:

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#featureObject

Returns the value of attribute feature.



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

def feature
  @feature
end

Instance Method Details

#accept_hook?(hook) ⇒ Boolean

Returns:

  • (Boolean)


51
52
53
# File 'lib/cucumber/ast/feature_element.rb', line 51

def accept_hook?(hook)
  Tags.matches?(source_tag_names, hook.tag_names)
end

#attach_steps(steps) ⇒ Object



9
10
11
# File 'lib/cucumber/ast/feature_element.rb', line 9

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

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



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

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

#file_colon_line(line = @line) ⇒ Object



13
14
15
# File 'lib/cucumber/ast/feature_element.rb', line 13

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

#first_line_lengthObject



21
22
23
# File 'lib/cucumber/ast/feature_element.rb', line 21

def first_line_length
  name_line_lengths[0]
end

#languageObject



63
64
65
# File 'lib/cucumber/ast/feature_element.rb', line 63

def language
  @feature.language
end

#matches_scenario_names?(scenario_name_regexps) ⇒ Boolean

Returns:

  • (Boolean)


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

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

#max_line_lengthObject



47
48
49
# File 'lib/cucumber/ast/feature_element.rb', line 47

def max_line_length
  @steps.max_line_length(self)
end

#name_line_lengthsObject



25
26
27
28
29
30
31
32
33
# File 'lib/cucumber/ast/feature_element.rb', line 25

def name_line_lengths
  if @name.strip.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

#source_indent(text_length) ⇒ Object



43
44
45
# File 'lib/cucumber/ast/feature_element.rb', line 43

def source_indent(text_length)
  max_line_length - text_length
end

#source_tag_namesObject



55
56
57
# File 'lib/cucumber/ast/feature_element.rb', line 55

def source_tag_names
  (@tags.tag_names + (@feature ? @feature.source_tag_names : [])).uniq
end

#tag_count(tag) ⇒ Object



59
60
61
# File 'lib/cucumber/ast/feature_element.rb', line 59

def tag_count(tag)
  @feature.tag_count(tag) == 0 ? @tags.count(tag) : @feature.tag_count(tag)
end

#text_lengthObject



17
18
19
# File 'lib/cucumber/ast/feature_element.rb', line 17

def text_length
  name_line_lengths.max
end