cucumber-rails
cucumber-rails copied to clipboard
Simplify the default, generated Cucumber config
🤔 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 https://github.com/cucumber/cucumber-ruby/issues/1651 which showcased the simplicity I was after, notably profile inheritance.
Thank you for your consideration. I'll happily write the PR if needed.
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