Class: StepCollector
- Inherits:
-
Object
- Object
- StepCollector
- Defined in:
- lib/step_collector.rb
Constant Summary collapse
- @@scenarios =
[]
Instance Method Summary collapse
- #add(step, p = {}) ⇒ Object
- #add_scenario(scenario, p = {}) ⇒ Object
- #prettified(table, indent = 4) ⇒ Object
- #reset ⇒ Object
- #steps ⇒ Object
Instance Method Details
#add(step, p = {}) ⇒ Object
10 11 12 13 14 15 |
# File 'lib/step_collector.rb', line 10 def add(step, p={}) table = p[:table] indent = p[:indent] || 4 spaces = " " * indent @@scenarios.last << spaces + step + prettified(table).to_s end |
#add_scenario(scenario, p = {}) ⇒ Object
4 5 6 7 8 |
# File 'lib/step_collector.rb', line 4 def add_scenario(scenario, p={}) indent = p[:indent] || 2 spaces = "\n" + " " * indent @@scenarios << [ spaces + scenario ] end |
#prettified(table, indent = 4) ⇒ Object
25 26 27 28 |
# File 'lib/step_collector.rb', line 25 def prettified(table, indent=4) return nil unless table table.to_s(:color => false, :indent => indent + 2).gsub(/\| +/, "| ").gsub(/\s+$/, '') end |
#reset ⇒ Object
21 22 23 |
# File 'lib/step_collector.rb', line 21 def reset @@scenarios = [] end |
#steps ⇒ Object
17 18 19 |
# File 'lib/step_collector.rb', line 17 def steps @@scenarios.select { |scenario| scenario.size > 1 }.flatten end |