cucumber-ruby
cucumber-ruby copied to clipboard
Scenario outline Table Value is Getting Cloned on Each Run
Describe the bug
Scenario Outline table value gets appended to the previous iteration value when the table values are same using << operator
To Reproduce Feature file -
Feature: Testing City Names
Scenario Outline:
And I live in '<city>' City
And I am not from '<city>'
Examples:
| city |
| Sacramento |
| Sacramento |
Step Definition file -
And 'I live in {string} City' do |city|
city << ' City'
puts "#{city}"
end
And /^I am not from '(.+)'$/ do |city|
city << ' city'
puts "#{city}"
end
gemfile -
source 'https://rubygems.org'
gem 'cucumber', '~> 6.1.0'
Expected behavior Should be loop 1
I live in Sacramento City
I am not from Sacramento city
loop 2
I live in Sacramento City
I am not from Sacramento city
Context & Motivation
This fails Cucumber feature plans in our automation suite. To fix it right now we are updating << with += but would be great to have << working to append strings.
Screenshots

Your Environment
- Versions used: Cucumber 6.1.0 and Ruby 2.6.4
- Operating System and version: Windows 10 64bit
Additional context
When Cucumber is downgraded to 6.0.0 << does not clone/append strings and works fine
When I use Cucumber Expressions in step definition I can't reproduce the issue it's only when I use regular expression.
And when table values are not same this issue cannot be reproduced
This feels related to #1532, but I might be wrong.
IMO either we need to freeze the argument (so you get an error trying to call << on it) or we need to copy it for each step match.
@pgundlupetvenkatesh thanks for such a concise and clear bug report! Are you interested in helping to fix this?
You can book a pairing session with me at https://calendly.com/mattwynne or you can come and find us in https://cucumber.io/community#slack in the #committers if you want to chat.
@mattwynne you 're welcome. I am pretty occupied with work right now so maybe some other time.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in two months if no further activity occurs.