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.



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

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



46
47
48
# File 'lib/cucumber/glue/snippet.rb', line 46

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

Instance Method Details

#stepObject



42
43
44
# File 'lib/cucumber/glue/snippet.rb', line 42

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

#to_sObject



38
39
40
# File 'lib/cucumber/glue/snippet.rb', line 38

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