Skip to content

Commit

Permalink
Add boolean cucumber type
Browse files Browse the repository at this point in the history
  • Loading branch information
Cawllec committed Mar 4, 2025
1 parent 441b1cc commit 0a8516e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 17 deletions.
20 changes: 3 additions & 17 deletions lib/features/steps/trace_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,9 @@

# Waits for a given number of spans to be received, which may be spread across one or more trace requests.
#
# TODO: This is functionaly identical to the below minimum-span step, but they're worded ambiguously.
# At the next major release we should restrict this step to an exact amount of spans.
#
# @step_input span_count [Integer] The number of spans to wait for
Then('I wait to receive {int} span(s)') do |span_count|
assert_received_span_count(span_count)
assert_received_span_count(span_count, span_count)
end

# Waits for a minimum number of spans to be received, which may be spread across one or more trace requests.
Expand Down Expand Up @@ -42,21 +39,10 @@
Maze.config.unmanaged_traces_mode = true
end

Then('the trace payload field {string} bool attribute {string} is true') do |field, attribute|
assert_field_attribute_exists(field, attribute, 'boolValue', true)
end

Then('the trace payload field {string} boolean attribute {string} is true') do |field, attribute|
assert_field_attribute_exists(field, attribute, 'boolValue', true)
Then(/the trace payload field {string} bool(ean) attribute {string} is {boolean}/) do |field, attribute, boolean|
assert_field_attribute_exists(field, attribute, 'boolValue', boolean)
end

Then('the trace payload field {string} bool attribute {string} is false') do |field, attribute|
assert_field_attribute_exists(field, attribute, 'boolValue', false)
end

Then('the trace payload field {string} boolean attribute {string} is false') do |field, attribute|
assert_field_attribute_exists(field, attribute, 'boolValue', false)
end

Then('the trace payload field {string} integer attribute {string} equals {int}') do |field, attribute, expected|
assert_field_attribute_exists(field, attribute, 'intValue', expected)
Expand Down
7 changes: 7 additions & 0 deletions lib/features/support/cucumber_types.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,10 @@
type: String,
transformer: ->(s) { s.split(',').map(&:strip).map(&:to_i) }
)

ParameterType(
name: 'boolean',
regexp: /true|false/,
type: String,
transformer: ->(s) { s.eql?('true') }
)

0 comments on commit 0a8516e

Please sign in to comment.