From 0a8516ec621f24c1a78c9d98de543279d5eedd21 Mon Sep 17 00:00:00 2001 From: Alex Moinet Date: Tue, 4 Mar 2025 11:37:09 +0000 Subject: [PATCH] Add boolean cucumber type --- lib/features/steps/trace_steps.rb | 20 +++----------------- lib/features/support/cucumber_types.rb | 7 +++++++ 2 files changed, 10 insertions(+), 17 deletions(-) diff --git a/lib/features/steps/trace_steps.rb b/lib/features/steps/trace_steps.rb index 0725632e2..0c717ca6c 100644 --- a/lib/features/steps/trace_steps.rb +++ b/lib/features/steps/trace_steps.rb @@ -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. @@ -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) diff --git a/lib/features/support/cucumber_types.rb b/lib/features/support/cucumber_types.rb index 960f41fb2..0d68dee1f 100644 --- a/lib/features/support/cucumber_types.rb +++ b/lib/features/support/cucumber_types.rb @@ -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') } +) \ No newline at end of file