Class: Cucumber::Ast::StepCollection
- Includes:
- Enumerable
- Defined in:
- lib/cucumber/ast/step_collection.rb
Overview
Holds an Array of Step or StepDefinition
Instance Method Summary collapse
- #+(step_invocations) ⇒ Object
- #accept(visitor) ⇒ Object
-
#dup(step_invocations = []) ⇒ Object
Duplicates this instance and adds
step_invocations
to the end. - #each(&proc) ⇒ Object
- #empty? ⇒ Boolean
- #exception ⇒ Object
- #failed? ⇒ Boolean
-
#initialize(steps) ⇒ StepCollection
constructor
A new instance of StepCollection.
- #inspect ⇒ Object
- #length ⇒ Object
- #max_line_length(feature_element) ⇒ Object
- #passed? ⇒ Boolean
- #previous_step(step) ⇒ Object
- #skip_invoke! ⇒ Object
- #status ⇒ Object
- #step_invocations(background = false) ⇒ Object
- #step_invocations_from_cells(cells) ⇒ Object
- #to_sexp ⇒ Object
Constructor Details
#initialize(steps) ⇒ StepCollection
Returns a new instance of StepCollection.
7 8 9 10 |
# File 'lib/cucumber/ast/step_collection.rb', line 7 def initialize(steps) @steps = steps @steps.each{|step| step.step_collection = self} end |
Instance Method Details
#+(step_invocations) ⇒ Object
39 40 41 |
# File 'lib/cucumber/ast/step_collection.rb', line 39 def +(step_invocations) dup(step_invocations) end |
#accept(visitor) ⇒ Object
16 17 18 19 20 21 |
# File 'lib/cucumber/ast/step_collection.rb', line 16 def accept(visitor) return if Cucumber.wants_to_quit @steps.each do |step| visitor.visit_step(step) end end |
#dup(step_invocations = []) ⇒ Object
Duplicates this instance and adds step_invocations
to the end
44 45 46 |
# File 'lib/cucumber/ast/step_collection.rb', line 44 def dup(step_invocations = []) StepCollection.new(@steps + step_invocations) end |
#each(&proc) ⇒ Object
48 49 50 |
# File 'lib/cucumber/ast/step_collection.rb', line 48 def each(&proc) @steps.each(&proc) end |
#empty? ⇒ Boolean
57 58 59 |
# File 'lib/cucumber/ast/step_collection.rb', line 57 def empty? @steps.empty? end |
#exception ⇒ Object
66 67 68 |
# File 'lib/cucumber/ast/step_collection.rb', line 66 def exception @exception ||= ((failed = @steps.detect {|step| step.exception}) && failed.exception) end |
#failed? ⇒ Boolean
70 71 72 |
# File 'lib/cucumber/ast/step_collection.rb', line 70 def failed? status == :failed end |
#inspect ⇒ Object
12 13 14 |
# File 'lib/cucumber/ast/step_collection.rb', line 12 def inspect @steps.map { |s| [s.class, s.object_id] }.join(', ') end |
#length ⇒ Object
83 84 85 |
# File 'lib/cucumber/ast/step_collection.rb', line 83 def length @steps.length end |
#max_line_length(feature_element) ⇒ Object
61 62 63 64 |
# File 'lib/cucumber/ast/step_collection.rb', line 61 def max_line_length(feature_element) lengths = (@steps + [feature_element]).map{|e| e.text_length} lengths.max end |
#passed? ⇒ Boolean
74 75 76 |
# File 'lib/cucumber/ast/step_collection.rb', line 74 def passed? status == :passed end |
#previous_step(step) ⇒ Object
52 53 54 55 |
# File 'lib/cucumber/ast/step_collection.rb', line 52 def previous_step(step) i = @steps.index(step) || -1 @steps[i-1] end |
#skip_invoke! ⇒ Object
31 32 33 |
# File 'lib/cucumber/ast/step_collection.rb', line 31 def skip_invoke! @steps.each{|step_invocation| step_invocation.skip_invoke!} end |
#status ⇒ Object
78 79 80 81 |
# File 'lib/cucumber/ast/step_collection.rb', line 78 def status @steps.each{|step_invocation| return step_invocation.status if step_invocation.status != :passed} :passed end |
#step_invocations(background = false) ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/cucumber/ast/step_collection.rb', line 23 def step_invocations(background = false) StepCollection.new(@steps.map{ |step| i = step.step_invocation i.background = background i }) end |
#step_invocations_from_cells(cells) ⇒ Object
35 36 37 |
# File 'lib/cucumber/ast/step_collection.rb', line 35 def step_invocations_from_cells(cells) @steps.map{|step| step.step_invocation_from_cells(cells)} end |
#to_sexp ⇒ Object
87 88 89 |
# File 'lib/cucumber/ast/step_collection.rb', line 87 def to_sexp @steps.map{|step| step.to_sexp} end |