Sha256: 7fa95e14c2a5a921c89dc08d7575ebe620ed665dd7c9a1158e3fff1e83f1a8fa

Contents?: true

Size: 2 KB

Versions: 20

Compression:

Stored size: 2 KB

Contents

require 'enumerator'
require 'gherkin/tag_expression'

module Cucumber
  module Ast
    module FeatureElement #:nodoc:
      attr_accessor :feature

      attr_reader :gherkin_statement, :raw_steps, :title, :description
      def gherkin_statement(statement=nil)
        @gherkin_statement ||= statement
      end

      def add_step(step)
        @raw_steps << step
      end

      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 first_line_length
        name_line_lengths[0]
      end

      def text_length
        name_line_lengths.max
      end

      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

      def matches_scenario_names?(scenario_name_regexps)
        scenario_name_regexps.detect{|n| n =~ 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
        init
        @steps.max_line_length(self)
      end

      def accept_hook?(hook)
        Gherkin::TagExpression.new(hook.tag_expressions).eval(source_tags)
      end
      
      def source_tag_names
        source_tags.map { |tag| tag.name }
      end

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

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

Version data entries

20 entries across 18 versions & 8 rubygems

Version Path
candlepin-api-0.4.0 bundle/ruby/1.9.1/gems/cucumber-1.2.1/lib/cucumber/ast/feature_element.rb
candlepin-api-0.4.0 bundle/ruby/gems/cucumber-1.2.1/lib/cucumber/ast/feature_element.rb
candlepin-api-0.4.0 bundle/ruby/1.8/gems/cucumber-1.2.1/lib/cucumber/ast/feature_element.rb
librarian-puppet-0.9.9 vendor/gems/ruby/1.9.1/gems/cucumber-1.2.1/lib/cucumber/ast/feature_element.rb
librarian-puppet-0.9.8 vendor/gems/ruby/1.9.1/gems/cucumber-1.2.1/lib/cucumber/ast/feature_element.rb
librarian-puppet-0.9.4 vendor/gems/ruby/1.8/gems/cucumber-1.2.1/lib/cucumber/ast/feature_element.rb
casecumber-1.2.1.cb2 lib/cucumber/ast/feature_element.rb
librarian-puppet-0.9.3 vendor/gems/ruby/1.8/gems/cucumber-1.2.1/lib/cucumber/ast/feature_element.rb
cucumber-1.2.1 lib/cucumber/ast/feature_element.rb
resque-pool-0.3.0 vendor/bundle/ruby/1.8/gems/cucumber-1.1.9/lib/cucumber/ast/feature_element.rb
ftl-0.2.0 vendor/bundle/gems/cucumber-1.2.0/lib/cucumber/ast/feature_element.rb
cucumber-1.2.0 lib/cucumber/ast/feature_element.rb
frameworks-capybara-0.2.0.rc6 vendor/bundle/ruby/1.8/gems/cucumber-1.1.9/lib/cucumber/ast/feature_element.rb
frameworks-capybara-0.2.0.rc5 vendor/bundle/ruby/1.8/gems/cucumber-1.1.9/lib/cucumber/ast/feature_element.rb
frameworks-capybara-0.2.0.rc4 vendor/bundle/ruby/1.8/gems/cucumber-1.1.9/lib/cucumber/ast/feature_element.rb
frameworks-capybara-0.2.0.rc3 vendor/bundle/ruby/1.8/gems/cucumber-1.1.9/lib/cucumber/ast/feature_element.rb
frameworks-capybara-0.2.0.rc2 vendor/bundle/ruby/1.8/gems/cucumber-1.1.9/lib/cucumber/ast/feature_element.rb
resque-pool-0.3.0.beta.2 vendor/bundle/ruby/1.8/gems/cucumber-1.1.9/lib/cucumber/ast/feature_element.rb
radiant-1.0.0 ruby-debug/ruby/1.8/gems/cucumber-1.1.9/lib/cucumber/ast/feature_element.rb
cucumber-1.1.9 lib/cucumber/ast/feature_element.rb