Skip to content
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

Simplify the default, generated Cucumber config #563

Open
freesteph opened this issue Aug 26, 2023 · 1 comment
Open

Simplify the default, generated Cucumber config #563

freesteph opened this issue Aug 26, 2023 · 1 comment

Comments

@freesteph
Copy link

🤔 What's the problem you're trying to solve?

I find the default config generated by cucumber-rails very terse and hard to understand:

<%
rerun = File.file?('rerun.txt') ? IO.read('rerun.txt') : ""
rerun = rerun.strip.gsub /\s/, ' '
rerun_opts = rerun.empty? ? "--format #{ENV['CUCUMBER_FORMAT'] || 'progress'} features" : "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} #{rerun}"
std_opts = "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} --strict --tags 'not @wip'"
%>
default: <%= std_opts %> features
wip: --tags @wip:3 --wip features
rerun: <%= rerun_opts %> --format rerun --out rerun.txt --strict --tags 'not @wip'

✨ What's your proposed solution?

I think having a simpler YAML would benefit the majority of users, and the few that need more complex configs will easily figure it out. Here's a naive proposal:

<%# You can also use ERB in this file %>
default:
  - --publish-quiet
  - --strict
  - --color

wip:
  - --profile=default
  - --tags=@wip

We lose the re-run logic but I think that should probably be part of cucumber-ruby, rather than a serious amount of logic living in the config.

We also lose the CUCUMBER_FORMAT format logic, but I'm not sure how useful that is? It can be reintroduced with:

<%# You can also use ERB in this file %>
default:
  - --publish-quiet
  - --strict
  - --color
  - --format=<%= ENV['CUCUMBER_FORMAT'] || 'pretty' %>

wip:
  - --profile=default
  - --tags=@wip

and I guess it demonstrates using ERB better than the toplevel comment? I don't mind either.

⛏ Have you considered any alternatives or workarounds?

I have browsed around to see what people did with their config and found cucumber/cucumber-ruby#1651 which showcased the simplicity I was after, notably profile inheritance.

Thank you for your consideration. I'll happily write the PR if needed.

@luke-hill
Copy link
Contributor

luke-hill commented Aug 29, 2023

Whilst you are right, there is a secondary issue to consider....

Which is for a while (I believe not on github), we've advocated from trying to move away from cucumber.yml to something more ruby like. Ideally a standardised .rb file. The primary reason is the .yml file has a "faux" erb templating parse mechanism, which isn't understood by IDEs (It throws errors up the wazoo), and also isn't particularly well documented. It is also unique to cucumber-ruby.

If you're willing to do some minor tweaks to it, then I would gladly welcome it / review it. Currently my plan is to get a version9 cut in the coming weeks, and then I've got at least half a dozen refactor PR's. Predominantly to do with the dependencies to get out. This should see some form of patch/minor influx of releases to get caught up.

Until the above is done, I wouldn't be willing to look at this personally.

Hope that helps / gives some more clarity.

NB: Be careful of using "some" YML standards in the cucumber.yml file. They will potentially fail. Again as mentioned, it's sort of half-yml half-erb

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

No branches or pull requests

2 participants