Skip to content

Documentation does not mention that {float} also matches {int} and supports scientific notationΒ #352

@twometresteve

Description

@twometresteve

πŸ‘“ What did you see?

    When I print the type of 1                                             # features/test.feature:3
      Ambiguous match of "I print the type of 1":

      steps/scripting_steps.rb:1:in `nil'
      steps/scripting_steps.rb:5:in `nil'

      You can run again with --guess to make Cucumber be more smart about it
       (Cucumber::Ambiguous)
      features/test.feature:3:in `I print the type of 1'

βœ… What did you expect to see?

Because there is no decimal point on the number provided, Cucumber should use the {int} step definition.

  Scenario: Demonstrate that floats and ints are not handled as documented # features/test.feature:2
1 is an int
    When I print the type of 1                                             # steps/scripting_steps.rb:1

πŸ“¦ Which tool/library version are you using?

ruby-cucumber v10.0 (earlier versions also behave the same).
Ruby v3.2.3 (and others)

πŸ”¬ How could we reproduce it?

  1. gem install cucumber
  2. Contents of features/test.feature:
Feature: Ambiguous parameter
  Scenario: Demonstrate that floats and int params are not handled as documented
    When I print the type of 1
  1. Contents of steps/steps.rb:
When('I print the type of {int}') do |number|
  puts "#{number} is an int"
end

When('I print the type of {float}') do |number|
  puts "#{number} is a float"
end
  1. Run the command cucumber -r steps

πŸ“š Any additional context?

This behaviour seems at odds with the cucumber-expressions documentation:

Image

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions