Sha256: a23c661a2ae00edaf6b2ffdeaa89f6bc5b2faf98c0f5664a6ff97b8d1b40dc77

Contents?: true

Size: 1.69 KB

Versions: 13

Compression:

Stored size: 1.69 KB

Contents

require 'enumerator'
require 'cucumber/ast/tags'

module Cucumber
  module Ast
    module FeatureElement #:nodoc:
      attr_accessor :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.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

      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.matches?(source_tag_names, hook.tag_name_lists)
      end

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

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

      def language
        @feature.language if @feature
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 4 rubygems

Version Path
cucumber-0.5.3 lib/cucumber/ast/feature_element.rb
cucumber-0.5.2 lib/cucumber/ast/feature_element.rb
cucumber-0.5.1 lib/cucumber/ast/feature_element.rb
cucumber-0.5.0 lib/cucumber/ast/feature_element.rb
cucumber-0.4.5.rc2 lib/cucumber/ast/feature_element.rb
kbaum-cucumber-0.4.5.pre lib/cucumber/ast/feature_element.rb
cucumber-0.4.5.rc1 lib/cucumber/ast/feature_element.rb
middleman-0.10.17 vendor/gems/gems/cucumber-0.4.4/lib/cucumber/ast/feature_element.rb
middleman-0.10.16 vendor/gems/gems/cucumber-0.4.4/lib/cucumber/ast/feature_element.rb
middleman-0.10.15 vendor/gems/gems/cucumber-0.4.4/lib/cucumber/ast/feature_element.rb
rackjour-0.1.8 vendor/gems/gems/cucumber-0.4.4/lib/cucumber/ast/feature_element.rb
middleman-0.10.14 vendor/gems/gems/cucumber-0.4.4/lib/cucumber/ast/feature_element.rb
cucumber-0.4.4 lib/cucumber/ast/feature_element.rb