Class: Cucumber::Ast::Background

Inherits:
Scenario show all
Defined in:
lib/cucumber/ast/background.rb

Instance Attribute Summary collapse

Attributes inherited from Scenario

#background, #feature

Instance Method Summary collapse

Methods inherited from Scenario

#accept_steps, #at_header_or_step_lines?, #at_lines?, #backtrace_line, #file_line, #matches_scenario_names?, #max_line_length, #previous_step, #source_indent, #tagged_with?, #text_length, #undefined?

Constructor Details

#initialize(comment, line, keyword, steps) ⇒ Background

Returns a new instance of Background.



8
9
10
11
# File 'lib/cucumber/ast/background.rb', line 8

def initialize(comment, line, keyword, steps)
  @record_executed_steps = true
  super(comment, Tags.new(1, []), line, keyword, "", steps)
end

Instance Attribute Details

#statusObject (readonly)

Returns the value of attribute status.



6
7
8
# File 'lib/cucumber/ast/background.rb', line 6

def status
  @status
end

#worldObject

Returns the value of attribute world.



5
6
7
# File 'lib/cucumber/ast/background.rb', line 5

def world
  @world
end

Instance Method Details

#accept(visitor) ⇒ Object



13
14
15
16
17
18
19
20
21
# File 'lib/cucumber/ast/background.rb', line 13

def accept(visitor)
  @world = visitor.new_world
  if already_visited_steps?
    @status = execute_steps(visitor)
  else
    @status = visit_background_and_steps(visitor, @steps)
    @steps_visited = true
  end
end

#already_visited_steps?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/cucumber/ast/background.rb', line 27

def already_visited_steps?
  @steps_visited
end

#step_executed(step) ⇒ Object



23
24
25
# File 'lib/cucumber/ast/background.rb', line 23

def step_executed(step)
  @feature.step_executed(step) if @feature && @record_executed_steps
end

#to_sexpObject

:nodoc:



31
32
33
34
35
36
37
38
39
40
# File 'lib/cucumber/ast/background.rb', line 31

def to_sexp #:nodoc:
  sexp = [:background, @line, @keyword]
  comment = @comment.to_sexp
  sexp += [comment] if comment
  tags = @tags.to_sexp
  sexp += tags if tags.any?
  steps = @steps.map{|step| step.to_sexp}
  sexp += steps if steps.any?
  sexp
end