New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cucumber/gherkin/ruby 13.0.0 Gherkin::Parser instantiates Gherkin::AstBuilder with wrong arguments #1074
Comments
Thanks @BillyRuffian the signatures are clearly wrong here. Would you be able to provide a full stack trace? That would help us better understand how this bug could have gone unnoticed while running Cucumber's own tests. |
From what I can tell, we're instantiating the parser here: Since we're passing a correctly instantiated instance of This is why a full stack trace would be helpful. Where is the code that calls |
Hi @aslakhellesoy, I'm creating a parser instance in this gem https://github.com/BillyRuffian/chutney/blob/master/lib/chutney.rb#L94 which we use to lint feature files so it's outside of running the cucumber framework per se. |
This looks similar to what's happening in #1063 |
@BillyRuffian aha I see! You could try this then: id_generator = Cucumber::Messages::IdGenerator::UUID.new
Parser.new(AstBuilder.new(id_generator)) I'm not a big fan of default arguments, so my preference would be to remove it. That would require a new major release. # Remove the default argument
def initialize(ast_builder) Alternatively we could keep it and do it correctly: # Keep the default argument
def initialize(ast_builder = AstBuilder.new(Cucumber::Messages::IdGenerator::UUID.new)) Despite my dislike for default arguments I think we should keep it here. The reason being that it only requires a patch release, and therefore wouldn't require a whole new cucumber release. |
@aslakhellesoy yep I'm with you and it'll be a quick patch on my side and the alternative's default arg is pretty vile. Nonetheless, the public API should work as advertised so I'm still lobbying for a patch :) |
Summary
https://github.com/cucumber/cucumber/blob/master/gherkin/ruby/lib/gherkin/parser.rb#L59 Parser's initialize with no arguments passed creates a new AST Buider with no args.
https://github.com/cucumber/cucumber/blob/master/gherkin/ruby/lib/gherkin/ast_builder.rb#L6 AST Builder takes a mandatory argument.
Expected Behavior
Expected an initialized Parser object.
Current Behavior
Possible Solution
AST Builder's initializer should take an option argument with a default id generator.
Steps to Reproduce (for bugs)
Context & Motivation
Using the parser to scan feature files for compliance. We've down-graded to Cucumber 3.2.
The text was updated successfully, but these errors were encountered: