Class: Cucumber::Ast::Scenario

Inherits:
Object
  • Object
show all
Includes:
FeatureElement
Defined in:
lib/cucumber/ast/scenario.rb

Instance Method Summary collapse

Methods included from FeatureElement

#attach_steps, #backtrace_line, #file_colon_line, #matches_scenario_names?, #max_line_length, #previous_step, #source_indent, #text_length

Constructor Details

#initialize(background, comment, tags, line, keyword, name, steps) ⇒ Scenario

Returns a new instance of Scenario.



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/cucumber/ast/scenario.rb', line 8

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

Instance Method Details

#accept(visitor) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
# File 'lib/cucumber/ast/scenario.rb', line 25

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

#feature=(feature) ⇒ Object



20
21
22
23
# File 'lib/cucumber/ast/scenario.rb', line 20

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

#skip_invoke!Object



37
38
39
40
41
42
# File 'lib/cucumber/ast/scenario.rb', line 37

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

#to_sexpObject



44
45
46
47
48
49
50
51
52
53
# File 'lib/cucumber/ast/scenario.rb', line 44

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