Class: Cucumber::Ast::Scenario
- Includes:
- HasLocation, HasSteps, Names
- Defined in:
- lib/cucumber/ast/scenario.rb
Overview
:nodoc:
Instance Attribute Summary collapse
-
#feature ⇒ Object
Returns the value of attribute feature.
-
#feature_tags ⇒ Object
readonly
Returns the value of attribute feature_tags.
Attributes included from Names
Attributes included from HasSteps
#description, #gherkin_statement, #raw_steps, #title
Instance Method Summary collapse
- #accept(visitor) ⇒ Object
-
#exception ⇒ Object
Returns the first exception (if any).
- #fail!(exception) ⇒ Object
-
#failed? ⇒ Boolean
Returns true if one or more steps failed.
-
#initialize(language, location, background, comment, tags, feature_tags, keyword, title, description, raw_steps) ⇒ Scenario
constructor
A new instance of Scenario.
-
#passed? ⇒ Boolean
Returns true if all steps passed.
- #skip_invoke! ⇒ Object
-
#status ⇒ Object
Returns the status.
- #steps ⇒ Object
- #to_sexp ⇒ Object
- #to_units(background) ⇒ Object
- #with_visitor(visitor) ⇒ Object
Methods included from HasLocation
#file, #file_colon_line, #line, #location
Methods included from Names
Methods included from HasSteps
#accept_hook?, #attach_steps, #backtrace_line, #first_line_length, #language, #matches_scenario_names?, #max_line_length, #name_line_lengths, #source_indent, #source_tag_names, #source_tags, #text_length
Constructor Details
#initialize(language, location, background, comment, tags, feature_tags, keyword, title, description, raw_steps) ⇒ Scenario
Returns a new instance of Scenario.
17 18 19 20 21 |
# File 'lib/cucumber/ast/scenario.rb', line 17 def initialize(language, location, background, comment, , , keyword, title, description, raw_steps) @language, @location, @background, @comment, @tags, @feature_tags, @keyword, @title, @description, @raw_steps = language, location, background, comment, , , keyword, title, description, raw_steps @exception = @executed = nil attach_steps(@raw_steps) end |
Instance Attribute Details
#feature ⇒ Object
Returns the value of attribute feature.
15 16 17 |
# File 'lib/cucumber/ast/scenario.rb', line 15 def feature @feature end |
#feature_tags ⇒ Object (readonly)
Returns the value of attribute feature_tags.
14 15 16 |
# File 'lib/cucumber/ast/scenario.rb', line 14 def @feature_tags end |
Instance Method Details
#accept(visitor) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/cucumber/ast/scenario.rb', line 23 def accept(visitor) return if Cucumber.wants_to_quit visitor.visit_comment(@comment) unless @comment.empty? visitor.(@tags) visitor.visit_scenario_name(@keyword, name, file_colon_line, source_indent(first_line_length)) skip_invoke! if @background.failed? with_visitor(visitor) do visitor.execute(self, skip_hooks?) end @executed = true end |
#exception ⇒ Object
Returns the first exception (if any)
57 58 59 |
# File 'lib/cucumber/ast/scenario.rb', line 57 def exception @exception || steps.exception end |
#fail!(exception) ⇒ Object
46 47 48 49 |
# File 'lib/cucumber/ast/scenario.rb', line 46 def fail!(exception) @exception = exception @current_visitor.visit_exception(@exception, :failed) end |
#failed? ⇒ Boolean
Returns true if one or more steps failed
42 43 44 |
# File 'lib/cucumber/ast/scenario.rb', line 42 def failed? steps.failed? || !!@exception end |
#passed? ⇒ Boolean
Returns true if all steps passed
52 53 54 |
# File 'lib/cucumber/ast/scenario.rb', line 52 def passed? !failed? end |
#skip_invoke! ⇒ Object
83 84 85 |
# File 'lib/cucumber/ast/scenario.rb', line 83 def skip_invoke! steps.skip_invoke! end |
#status ⇒ Object
Returns the status
62 63 64 65 |
# File 'lib/cucumber/ast/scenario.rb', line 62 def status return :failed if @exception steps.status end |
#steps ⇒ Object
87 88 89 |
# File 'lib/cucumber/ast/scenario.rb', line 87 def steps @steps ||= @background.step_collection(step_invocations) end |
#to_sexp ⇒ Object
67 68 69 70 71 72 73 74 75 |
# File 'lib/cucumber/ast/scenario.rb', line 67 def to_sexp sexp = [:scenario, line, @keyword, name] comment = @comment.to_sexp sexp += [comment] if comment = @tags.to_sexp sexp += if .any? sexp += steps.to_sexp if steps.any? sexp end |
#to_units(background) ⇒ Object
37 38 39 |
# File 'lib/cucumber/ast/scenario.rb', line 37 def to_units(background) [Unit.new(background.step_invocations + step_invocations)] end |
#with_visitor(visitor) ⇒ Object
77 78 79 80 81 |
# File 'lib/cucumber/ast/scenario.rb', line 77 def with_visitor(visitor) @current_visitor = visitor yield @current_visitor = nil end |