Class: StepDefinitionsViewer::Parser
- Inherits:
-
Object
- Object
- StepDefinitionsViewer::Parser
- Defined in:
- lib/step_definitions_viewer.rb
Class Method Summary collapse
Class Method Details
.output(filename) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/step_definitions_viewer.rb', line 22 def self.output(filename) result = parse(filename) puts "Given".red result["Given"].each do |step| puts " #{step}" end puts puts "When".green result["When"].each do |step| puts " #{step}" end puts puts "Then".blue result["Then"].each do |step| puts " #{step}" end end |
.parse(filename) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/step_definitions_viewer.rb', line 6 def self.parse(filename) contents = IO.read(filename) scanned_contents = contents.scan(/(Given|When|Then) \/\^(.*)\$\//) result = {"Given" => [], "When" => [], "Then" => []} scanned_contents.each do |step| result.keys.each do |state| if step[0] == state result[state] << step[1] end end end result end |