Skip to content

Simplify the default, generated Cucumber config #563

@freesteph

Description

@freesteph

🤔 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions