Class: Cucumber::Ast::TreeWalker

Inherits:
Object
  • Object
show all
Defined in:
lib/cucumber/ast/tree_walker.rb

Overview

Walks the AST, executing steps and notifying listeners

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(runtime, listeners = [], configuration = Cucumber::Configuration.default) ⇒ TreeWalker

Returns a new instance of TreeWalker.



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

def initialize(runtime, listeners = [], configuration = Cucumber::Configuration.default)
  @runtime, @listeners, @configuration = runtime, listeners, configuration
end

Instance Attribute Details

#configurationObject

:nodoc:



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

def configuration
  @configuration
end

#runtimeObject (readonly)

:nodoc:



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

def runtime
  @runtime
end

Instance Method Details

#embed(file, mime_type, label) ⇒ Object

Embed file of mime_type in the formatter. This method can be called from within StepDefinitions. For most formatters this is a no-op.



159
160
161
# File 'lib/cucumber/ast/tree_walker.rb', line 159

def embed(file, mime_type, label)
  broadcast(file, mime_type, label)
end

#execute(scenario, skip_hooks) ⇒ Object



12
13
14
15
16
17
# File 'lib/cucumber/ast/tree_walker.rb', line 12

def execute(scenario, skip_hooks)
  runtime.with_hooks(scenario, skip_hooks) do
    scenario.skip_invoke! if scenario.failed?
    visit_steps(scenario.steps)
  end
end

#puts(*messages) ⇒ Object

Print messages. This method can be called from within StepDefinitions.



153
154
155
# File 'lib/cucumber/ast/tree_walker.rb', line 153

def puts(*messages)
  broadcast(*messages)
end

#visit_background(background) ⇒ Object



62
63
64
65
66
# File 'lib/cucumber/ast/tree_walker.rb', line 62

def visit_background(background)
  broadcast(background) do
    background.accept(self)
  end
end

#visit_background_name(keyword, name, file_colon_line, source_indent) ⇒ Object



68
69
70
# File 'lib/cucumber/ast/tree_walker.rb', line 68

def visit_background_name(keyword, name, file_colon_line, source_indent)
  broadcast(keyword, name, file_colon_line, source_indent)
end

#visit_comment(comment) ⇒ Object



31
32
33
34
35
# File 'lib/cucumber/ast/tree_walker.rb', line 31

def visit_comment(comment)
  broadcast(comment) do
    comment.accept(self)
  end
end

#visit_comment_line(comment_line) ⇒ Object



37
38
39
# File 'lib/cucumber/ast/tree_walker.rb', line 37

def visit_comment_line(comment_line)
  broadcast(comment_line)
end

#visit_doc_string(string) ⇒ Object



132
133
134
# File 'lib/cucumber/ast/tree_walker.rb', line 132

def visit_doc_string(string)
  broadcast(string)
end

#visit_examples(examples) ⇒ Object



78
79
80
81
82
# File 'lib/cucumber/ast/tree_walker.rb', line 78

def visit_examples(examples)
  broadcast(examples) do
    examples.accept(self)
  end
end

#visit_examples_array(examples_array) ⇒ Object



72
73
74
75
76
# File 'lib/cucumber/ast/tree_walker.rb', line 72

def visit_examples_array(examples_array)
  broadcast(examples_array) do
    examples_array.accept(self)
  end
end

#visit_examples_name(keyword, name) ⇒ Object



84
85
86
# File 'lib/cucumber/ast/tree_walker.rb', line 84

def visit_examples_name(keyword, name)
  broadcast(keyword, name)
end

#visit_exception(exception, status) ⇒ Object

:nodoc:



128
129
130
# File 'lib/cucumber/ast/tree_walker.rb', line 128

def visit_exception(exception, status) #:nodoc:
  broadcast(exception, status)
end

#visit_feature(feature) ⇒ Object



25
26
27
28
29
# File 'lib/cucumber/ast/tree_walker.rb', line 25

def visit_feature(feature)
  broadcast(feature) do
    feature.accept(self)
  end
end

#visit_feature_element(feature_element) ⇒ Object

feature_element is either Scenario or ScenarioOutline



56
57
58
59
60
# File 'lib/cucumber/ast/tree_walker.rb', line 56

def visit_feature_element(feature_element)
  broadcast(feature_element) do
    feature_element.accept(self)
  end
end

#visit_feature_name(keyword, name) ⇒ Object



51
52
53
# File 'lib/cucumber/ast/tree_walker.rb', line 51

def visit_feature_name(keyword, name)
  broadcast(keyword, name)
end

#visit_features(features) ⇒ Object



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

def visit_features(features)
  broadcast(features) do
    features.accept(self)
  end
end

#visit_multiline_arg(multiline_arg) ⇒ Object

:nodoc:



122
123
124
125
126
# File 'lib/cucumber/ast/tree_walker.rb', line 122

def visit_multiline_arg(multiline_arg) #:nodoc:
  broadcast(multiline_arg) do
    multiline_arg.accept(self)
  end
end

#visit_outline_table(outline_table) ⇒ Object



88
89
90
91
92
# File 'lib/cucumber/ast/tree_walker.rb', line 88

def visit_outline_table(outline_table)
  broadcast(outline_table) do
    outline_table.accept(self)
  end
end

#visit_scenario_name(keyword, name, file_colon_line, source_indent) ⇒ Object



94
95
96
# File 'lib/cucumber/ast/tree_walker.rb', line 94

def visit_scenario_name(keyword, name, file_colon_line, source_indent)
  broadcast(keyword, name, file_colon_line, source_indent)
end

#visit_step(step) ⇒ Object



104
105
106
107
108
# File 'lib/cucumber/ast/tree_walker.rb', line 104

def visit_step(step)
  broadcast(step) do
    step.accept(self)
  end
end

#visit_step_name(keyword, step_match, status, source_indent, background, file_colon_line) ⇒ Object

:nodoc:



118
119
120
# File 'lib/cucumber/ast/tree_walker.rb', line 118

def visit_step_name(keyword, step_match, status, source_indent, background, file_colon_line) #:nodoc:
  broadcast(keyword, step_match, status, source_indent, background, file_colon_line)
end

#visit_step_result(keyword, step_match, multiline_arg, status, exception, source_indent, background, file_colon_line) ⇒ Object



110
111
112
113
114
115
116
# File 'lib/cucumber/ast/tree_walker.rb', line 110

def visit_step_result(keyword, step_match, multiline_arg, status, exception, source_indent, background, file_colon_line)
  broadcast(keyword, step_match, multiline_arg, status, exception, source_indent, background, file_colon_line) do
    visit_step_name(keyword, step_match, status, source_indent, background, file_colon_line)
    visit_multiline_arg(multiline_arg) if multiline_arg
    visit_exception(exception, status) if exception
  end
end

#visit_steps(steps) ⇒ Object



98
99
100
101
102
# File 'lib/cucumber/ast/tree_walker.rb', line 98

def visit_steps(steps)
  broadcast(steps) do
    steps.accept(self)
  end
end

#visit_table_cell(table_cell) ⇒ Object



142
143
144
145
146
# File 'lib/cucumber/ast/tree_walker.rb', line 142

def visit_table_cell(table_cell)
  broadcast(table_cell) do
    table_cell.accept(self)
  end
end

#visit_table_cell_value(value, status) ⇒ Object



148
149
150
# File 'lib/cucumber/ast/tree_walker.rb', line 148

def visit_table_cell_value(value, status)
  broadcast(value, status)
end

#visit_table_row(table_row) ⇒ Object



136
137
138
139
140
# File 'lib/cucumber/ast/tree_walker.rb', line 136

def visit_table_row(table_row)
  broadcast(table_row) do
    table_row.accept(self)
  end
end

#visit_tag_name(tag_name) ⇒ Object



47
48
49
# File 'lib/cucumber/ast/tree_walker.rb', line 47

def visit_tag_name(tag_name)
  broadcast(tag_name)
end

#visit_tags(tags) ⇒ Object



41
42
43
44
45
# File 'lib/cucumber/ast/tree_walker.rb', line 41

def visit_tags(tags)
  broadcast(tags) do
    tags.accept(self)
  end
end