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)


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

def accept_hook?(hook)
  Gherkin::TagExpression.new(hook.tag_expressions).eval(source_tag_names)
end

#add_step(step) ⇒ Object



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

def add_step(step)
  @raw_steps << step
end

#attach_steps(steps) ⇒ Object



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

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

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



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

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

#file_colon_line(line = @line) ⇒ Object



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

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



68
69
70
# File 'lib/cucumber/ast/feature_element.rb', line 68

def language
  @feature.language if @feature
end

#matches_scenario_names?(scenario_name_regexps) ⇒ Boolean

Returns:

  • (Boolean)


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

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

#max_line_lengthObject



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

def max_line_length
  init
  @steps.max_line_length(self)
end

#name_line_lengthsObject



29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/cucumber/ast/feature_element.rb', line 29

def name_line_lengths
  if @name.strip.empty?
    [Ast::Step::INDENT + @keyword.unpack('U*').length + ': '.length]
  else
    @name.split("\n").enum_for(:each_with_index).map do |line, line_number|
      if line_number == 0
        Ast::Step::INDENT + @keyword.unpack('U*').length + ': '.length + line.unpack('U*').length
      else
        Ast::Step::INDENT + Ast::Step::INDENT + line.unpack('U*').length
      end
    end
  end
end

#source_indent(text_length) ⇒ Object



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

def source_indent(text_length)
  max_line_length - text_length
end

#source_tag_namesObject



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

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

#text_lengthObject



25
26
27
# File 'lib/cucumber/ast/feature_element.rb', line 25

def text_length
  name_line_lengths.max
end