Sha256: d86af766b749c3e4ac8495c236769cf36aeebb11c68bf876342f52a5ed1548ec

Contents?: true

Size: 1.25 KB

Versions: 3

Compression:

Stored size: 1.25 KB

Contents

##
# @file assignment.rb
# Assignment related steps.

##
# Assign the provided parameter.
#
# @param name - The identifier to which the value will be bound.
# @param value - The value to bind to the identifier.
When(/^`([^`]*)` is assigned `([^`]*)`$/) do |name, value|
  bind(name, value)
end

##
# Assign a random string (UUID).
#
# @param name - The identifier to which a random string will be bound.
When(/^`([^`]*)` is assigned a random string$/) do |name|
  bind(name, SecureRandom.uuid)
end

##
# Assign a current timestamp.
#
# @param name - The identifier to which the current timestamp will be bound.
When(/^`([^`]*)` is assigned a timestamp$/) do |name|
  bind(name, DateTime.now)
end

##
# Assign a value extracted from a response attribute.
#
# @param name - The identifier to which the extracted value will be bound.
# @param attribute - The response member from which the value will be extracted.
# @param plural - When the path is provided,
# @param path - The path within the member to extract.
# whether to extract a single match or a collection of all matching.
When(/^`([^`]*)` is assigned the response #{RESPONSE_ATTRIBUTES}(?: child(ren)? `([^`]*)`)?$/) do
  |name, attribute, plural, path|
  bind(name, dig_from_response(attribute, path, !plural.nil?))
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
brine-dsl-0.9.0 lib/brine/step_definitions/assignment.rb
brine-dsl-0.8.1 lib/brine/step_definitions/assignment.rb
brine-dsl-0.8.0 lib/brine/step_definitions/assignment.rb