Class: Gherkin::Listener::Event

Inherits:
Array
  • Object
show all
Defined in:
lib/gherkin/listener/event.rb

Instance Method Summary collapse

Instance Method Details

#eventObject



4
5
6
# File 'lib/gherkin/listener/event.rb', line 4

def event
  self[0]
end

#keywordObject



8
9
10
# File 'lib/gherkin/listener/event.rb', line 8

def keyword
  self[1]
end

#line_match?(lines) ⇒ Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/gherkin/listener/event.rb', line 12

def line_match?(lines)
  lines.include?(line)
end

#name_match?(name_regexen) ⇒ Boolean

Returns:

  • (Boolean)


16
17
18
19
# File 'lib/gherkin/listener/event.rb', line 16

def name_match?(name_regexen)
  return false unless [:feature, :background, :scenario, :scenario_outline, :examples].include?(event)
  name_regexen.detect{|name_regex| name =~ name_regex}
end

#replay(listener) ⇒ Object



21
22
23
24
25
26
27
28
# File 'lib/gherkin/listener/event.rb', line 21

def replay(listener)
  begin
    listener.__send__(event, *args)
  rescue ArgumentError => e
    e.message << "\nListener: #{listener.class}, args: #{args.inspect}"
    raise e
  end
end