Sha256: a5b7fb365a4e4fe29172769847294d7115d97f64c77759698803c8f0f194a8ac

Contents?: true

Size: 1.8 KB

Versions: 26

Compression:

Stored size: 1.8 KB

Contents

require 'cucumber/ast/feature_element'

module Cucumber
  module Ast
    class Scenario
      include FeatureElement
      
      def initialize(background, comment, tags, line, keyword, name, steps)
        @background, @comment, @tags, @line, @keyword, @name = background, comment, tags, line, keyword, name
        attach_steps(steps)
        
        step_invocations = steps.map{|step| step.step_invocation}
        if @background
          @steps = @background.step_collection(step_invocations)
        else
          @steps = StepCollection.new(step_invocations)
        end
      end

      def feature=(feature)
        @feature = feature
        @background.feature = feature if @background
      end

      def descend?(visitor)
        visitor.matches_lines?(self) &&
        visitor.included_by_tags?(self) &&
        !visitor.excluded_by_tags?(self) &&
        visitor.matches_scenario_names?(self)
      end

      def accept(visitor)
        visitor.visit_comment(@comment)
        visitor.visit_tags(@tags)
        visitor.visit_scenario_name(@keyword, @name, file_colon_line(@line), source_indent(text_length))

        skip = @background && @background.failed?
        skip_invoke! if skip
        visitor.step_mother.before_and_after(self, skip) do
          visitor.visit_steps(@steps)
        end
      end

      def skip_invoke!
        @steps.each{|step_invocation| step_invocation.skip_invoke!}
        @feature.next_feature_element(self) do |next_one|
          next_one.skip_invoke!
        end
      end

      def to_sexp
        sexp = [:scenario, @line, @keyword, @name]
        comment = @comment.to_sexp
        sexp += [comment] if comment
        tags = @tags.to_sexp
        sexp += tags if tags.any?
        steps = @steps.to_sexp
        sexp += steps if steps.any?
        sexp
      end

    end
  end
end

Version data entries

26 entries across 26 versions & 4 rubygems

Version Path
aslakhellesoy-cucumber-0.1.100.1 lib/cucumber/ast/scenario.rb
aslakhellesoy-cucumber-0.1.100.2 lib/cucumber/ast/scenario.rb
aslakhellesoy-cucumber-0.1.100.3 lib/cucumber/ast/scenario.rb
aslakhellesoy-cucumber-0.1.100.4 lib/cucumber/ast/scenario.rb
aslakhellesoy-cucumber-0.1.100.5 lib/cucumber/ast/scenario.rb
aslakhellesoy-cucumber-0.2.0.1 lib/cucumber/ast/scenario.rb
aslakhellesoy-cucumber-0.2.0.2 lib/cucumber/ast/scenario.rb
aslakhellesoy-cucumber-0.2.0.3 lib/cucumber/ast/scenario.rb
aslakhellesoy-cucumber-0.2.0.4 lib/cucumber/ast/scenario.rb
aslakhellesoy-cucumber-0.2.0 lib/cucumber/ast/scenario.rb
aslakhellesoy-cucumber-0.2.1 lib/cucumber/ast/scenario.rb
aslakhellesoy-cucumber-0.2.2.1 lib/cucumber/ast/scenario.rb
aslakhellesoy-cucumber-0.2.2.2 lib/cucumber/ast/scenario.rb
aslakhellesoy-cucumber-0.2.2 lib/cucumber/ast/scenario.rb
aslakhellesoy-cucumber-0.2.3.1 lib/cucumber/ast/scenario.rb
aslakhellesoy-cucumber-0.2.3.2 lib/cucumber/ast/scenario.rb
aslakhellesoy-cucumber-0.2.3 lib/cucumber/ast/scenario.rb
fcoury-cucumber-0.2.3.1 lib/cucumber/ast/scenario.rb
kosmas58-cucumber-0.1.100.5 lib/cucumber/ast/scenario.rb
kosmas58-cucumber-0.2.0.1 lib/cucumber/ast/scenario.rb