Class: Gurk::Parser

Inherits:
Object
  • Object
show all
Defined in:
lib/gurk/parser.rb

Constant Summary collapse

VALID_STEPS =
[
  { "^I have a page called '(.+)'$" => lambda { |k, _| { name: k } } },
  { "^it has a route of '(.+)'$" => lambda { |k, _| { route: k } } },
  { "^it has a (.+) called '(.+)'$" => lambda { |k, v| { k.to_sym => v } } }
]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(sources = Dir.glob("#{Dir.pwd}/features/*.feature")) ⇒ Parser

Returns a new instance of Parser.



16
17
18
19
20
21
22
23
24
# File 'lib/gurk/parser.rb', line 16

def initialize(sources = Dir.glob("#{Dir.pwd}/features/*.feature"))
  @parsed_names = []
  @parsed_data = []
  @sources = sources
  io = StringIO.new
  formatter = Gherkin::Formatter::JSONFormatter.new(io)
  parser = Gherkin::Parser::Parser.new(formatter)
  read_feature_files(io, parser, formatter, sources)
end

Instance Attribute Details

#sourcesObject

Returns the value of attribute sources.



14
15
16
# File 'lib/gurk/parser.rb', line 14

def sources
  @sources
end

Instance Method Details

#parse!Object



26
27
28
29
# File 'lib/gurk/parser.rb', line 26

def parse!
  @parsed_names.each { |name| parse_names(name) }
  parse_locals(@parsed_data)
end