Sha256: c4db0c8a740d3ab2d1835a4f2958d269455310b30f8b9270d7ae7daefe29174c

Contents?: true

Size: 941 Bytes

Versions: 5

Compression:

Stored size: 941 Bytes

Contents

#############################################################
#                      TRANSFORMERS                         #
#############################################################

# Revives factory or factory property from step to real value
# @note any factory is building once per scenario for the same number.
#  if number is ommited, then it is assigned to 0 number.
#  Built factories are stored in Howitzer::Cache and cleared after each
#  scenario automatically
# @example
#  'When I fill first name field with FACTORY_USER1[:first_name] value'
#  #=> build(:user).first_name
#  When 'I fill first name field with {factory} value' do |name|
#     ...
#  end
ParameterType(
  name: 'factory',
  regexp: /(?:factory|FACTORY)_([A-Za-z_]+)(\d*)(?:\[:(.+)\])?/,
  transformer: lambda do |_, factory, num, property|
    res = FactoryBot.given_by_number(factory.downcase, num)
    res = res.send(property) if property
    res
  end
)

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
howitzer-2.6.1 generators/cucumber/templates/transformers.rb
howitzer-2.6.0 generators/cucumber/templates/transformers.rb
howitzer-2.5.0 generators/cucumber/templates/transformers.rb
howitzer-2.4.0 generators/cucumber/templates/transformers.rb
howitzer-2.3.0 generators/cucumber/templates/transformers.rb