Sha256: d7ab65a33f49217e389fb1f5a93ddeca4439b2fff491de23501514a154e9655d

Contents?: true

Size: 1.31 KB

Versions: 22

Compression:

Stored size: 1.31 KB

Contents

require 'enumerator'

module Cucumber
  module FeatureElement
    attr_writer :feature

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

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

    def text_length
      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_name_regexps)
      scenario_name_regexps.detect{|name| name =~ @name}
    end 

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

    def source_indent(text_length)
      max_line_length - text_length
    end

    def max_line_length
      @steps.max_line_length(self)
    end

    def accept_hook?(hook)
      @tags.accept_hook?(hook) || @feature.accept_hook?(hook)
    end
    
    def language
      @feature.language
    end
  end
end

Version data entries

22 entries across 22 versions & 6 rubygems

Version Path
aslakhellesoy-cucumber-0.3.11.200907091518 lib/cucumber/ast/feature_element.rb
aslakhellesoy-cucumber-0.3.11.5 lib/cucumber/ast/feature_element.rb
aslakhellesoy-cucumber-0.3.11.6 lib/cucumber/ast/feature_element.rb
aslakhellesoy-cucumber-0.3.90 lib/cucumber/ast/feature_element.rb
aslakhellesoy-cucumber-0.3.92 lib/cucumber/ast/feature_element.rb
aslakhellesoy-cucumber-0.3.93.1 lib/cucumber/ast/feature_element.rb
aslakhellesoy-cucumber-0.3.93 lib/cucumber/ast/feature_element.rb
jwilger-cucumber-0.3.11.200906161550 lib/cucumber/ast/feature_element.rb
jwilger-cucumber-0.3.11.200907091518 lib/cucumber/ast/feature_element.rb
kosmas58-cucumber-0.3.11.6 lib/cucumber/ast/feature_element.rb
kosmas58-cucumber-0.3.90 lib/cucumber/ast/feature_element.rb
kosmas58-cucumber-0.3.92 lib/cucumber/ast/feature_element.rb
kosmas58-cucumber-0.3.93.1 lib/cucumber/ast/feature_element.rb
square-cucumber-0.3.12.2 lib/cucumber/ast/feature_element.rb
square-cucumber-0.3.93.1.1 lib/cucumber/ast/feature_element.rb
square-cucumber-0.3.93.1 lib/cucumber/ast/feature_element.rb
squirrel-cucumber-0.3.12.1 lib/cucumber/ast/feature_element.rb
squirrel-cucumber-0.3.12 lib/cucumber/ast/feature_element.rb
cucumber-0.3.90 lib/cucumber/ast/feature_element.rb
cucumber-0.3.91 lib/cucumber/ast/feature_element.rb