Skip to content

Find Ruby step definitions when defined by a step() method#297

Open
henrahmagix wants to merge 1 commit into
cucumber:mainfrom
henrahmagix:patch-1
Open

Find Ruby step definitions when defined by a step() method#297
henrahmagix wants to merge 1 commit into
cucumber:mainfrom
henrahmagix:patch-1

Conversation

@henrahmagix

Copy link
Copy Markdown

Turnip defines steps with the method step, it doesn't (currently) support Given/When/Then/etc. Also those method names aren't Ruby-like because they start with a capital letter, so even aliasing them doesn't feel great, though it is a workaround.

It'd be lovely if the Cucumber language service could find these step '...' do; end definitions =)

🤔 What's changed?

step has been added to the list of method names matched by the defineStepDefinitionQueries in the Ruby language.

⚡️ What's your motivation?

This allows the Cucumber LSP to find step definitions in a repo using https://github.com/jnicklas/turnip, e.g.

module FeatureSteps
  step "I am logged in" do
    login(@user)
  end
  # ...
end
image

🏷️ What kind of change is this?

  • ⚡ New feature (non-breaking change which adds new behaviour)

♻️ Anything particular you want feedback on?

It'd be lovely if this expression could be passed in by configuration, so we can easily match our own definitions in our own usages ☺️

📋 Checklist:

  • I agree to respect and uphold the Cucumber Community Code of Conduct
  • I've changed the behaviour of the code
    • I have added/updated tests to cover my changes.
  • My change requires a change to the documentation.
    • I have updated the documentation accordingly.
  • Users should know about my change
    • I have added an entry to the "Unreleased" section of the CHANGELOG, linking to this pull request.

Sorry, I just made this through GitHub's fork-and-edit. Is it worth adding to the tests, when it's an addition of a method name to a regexp? Also I'm not sure if this should be documented.

I'm happy to do all that if it's necessary; so far this is fixing just my own situation, I don't know how prevalent VS Code + Cucumber extension + Ruby repo + Turnip gem usage is, and therefore how important it is to document this.

Perhaps I could work on a refactor to get this pattern into configuration, if y'all would accept that? That would definitely be important to document and test. Might be a bit of work to acquaint myself with the language-service repo and the language-server repo, like which provides configuration and how it gets passed through, and how to provide the current pattern as a default from the vscode repo =)

Thanks in advance, snance,
Henry

Turnip defines steps with the method `step`, it doesn't (currently) support Given/When/Then/etc. Also those method names aren't Ruby-like because they start with a capital letter, so even aliasing them doesn't _feel_ great, though it is a workaround.

It'd be lovely if the Cucumber language service could find these `step '...' do; end` definitions =)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant