Class: Cucumber::Glue::Snippet::CucumberExpression

Inherits:
BaseSnippet show all
Defined in:
lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-8.0.0/lib/cucumber/glue/snippet.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseSnippet

cli_option_string, #initialize, #step

Constructor Details

This class inherits a constructor from Cucumber::Glue::Snippet::BaseSnippet

Class Method Details

.descriptionObject



112
113
114
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-8.0.0/lib/cucumber/glue/snippet.rb', line 112

def self.description
  'Cucumber Expressions'
end

Instance Method Details

#parameters(expr) ⇒ Object



106
107
108
109
110
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-8.0.0/lib/cucumber/glue/snippet.rb', line 106

def parameters(expr)
  parameter_names = expr.parameter_names
  multiline_argument.append_block_parameter_to(parameter_names)
  parameter_names.empty? ? '' : " |#{parameter_names.join(', ')}|"
end

#to_sObject



92
93
94
95
96
97
98
99
100
101
102
103
104
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-8.0.0/lib/cucumber/glue/snippet.rb', line 92

def to_s
  header = generated_expressions.each_with_index.map do |expr, i|
    prefix = i.zero? ? '' : '# '
    "#{prefix}#{code_keyword}('#{expr.source}') do#{parameters(expr)}"
  end.join("\n")

  body = String.new # rubocop:disable Style/EmptyLiteral
  multiline_argument.append_comment_to(body)
  body << "  pending # Write code here that turns the phrase above into concrete actions\n"
  body << 'end'

  "#{header}\n#{body}"
end

#typed_patternObject



88
89
90
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-8.0.0/lib/cucumber/glue/snippet.rb', line 88

def typed_pattern
  "(\"#{generated_expressions[0].source}\")"
end