Class: Cucumber::Glue::Snippet::Generator

Inherits:
Object
  • Object
show all
Defined in:
lib/cucumber/glue/snippet.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cucumber_expression_generator) ⇒ Generator

Returns a new instance of Generator.



14
15
16
# File 'lib/cucumber/glue/snippet.rb', line 14

def initialize(cucumber_expression_generator)
  @cucumber_expression_generator = cucumber_expression_generator
end

Class Method Details

.register_on(configuration) ⇒ Object



10
11
12
# File 'lib/cucumber/glue/snippet.rb', line 10

def self.register_on(configuration)
  configuration.snippet_generators << new
end

Instance Method Details

#call(code_keyword, step_name, multiline_arg, snippet_type) ⇒ Object



18
19
20
21
# File 'lib/cucumber/glue/snippet.rb', line 18

def call(code_keyword, step_name, multiline_arg, snippet_type)
  snippet_class = typed_snippet_class(snippet_type)
  snippet_class.new(@cucumber_expression_generator, code_keyword, step_name, multiline_arg).to_s
end

#typed_snippet_class(type) ⇒ Object



23
24
25
# File 'lib/cucumber/glue/snippet.rb', line 23

def typed_snippet_class(type)
  SNIPPET_TYPES.fetch(type || :cucumber_expression)
end