Class: Cucumber::Glue::Snippet::BaseSnippet

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

Direct Known Subclasses

Classic, CucumberExpression, Percent, Regexp

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cucumber_expression_generator, code_keyword, step_name, multiline_argument) ⇒ BaseSnippet

Returns a new instance of BaseSnippet.



28
29
30
31
32
33
34
# File 'lib/cucumber/glue/snippet.rb', line 28

def initialize(cucumber_expression_generator, code_keyword, step_name, multiline_argument)
  @number_of_arguments = 0
  @code_keyword = code_keyword
  @pattern = replace_and_count_capturing_groups(step_name)
  @generated_expressions = cucumber_expression_generator.generate_expressions(step_name)
  @multiline_argument = MultilineArgumentSnippet.new(multiline_argument)
end

Class Method Details

.cli_option_string(type, cucumber_expression_generator) ⇒ Object



44
45
46
# File 'lib/cucumber/glue/snippet.rb', line 44

def self.cli_option_string(type, cucumber_expression_generator)
  format('%<type>-7s: %<description>-28s e.g. %<example>s', type: type, description: description, example: example(cucumber_expression_generator))
end

Instance Method Details

#stepObject



40
41
42
# File 'lib/cucumber/glue/snippet.rb', line 40

def step
  "#{code_keyword}#{typed_pattern}"
end

#to_sObject



36
37
38
# File 'lib/cucumber/glue/snippet.rb', line 36

def to_s
  "#{step} #{do_block}"
end