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

API for tag definitions is terribly hacky #78

Closed
hauleth opened this issue Feb 28, 2019 · 3 comments
Closed

API for tag definitions is terribly hacky #78

hauleth opened this issue Feb 28, 2019 · 3 comments

Comments

@hauleth
Copy link
Contributor

hauleth commented Feb 28, 2019

It uses terrible hack to allow syntax in form:

tag @foo do
  # …
end

Instead it should set tag value as a field in a context that is passed to the setup and force user to match on tags there. It would provide much nicer API and would de-cruft the implementation form hacks.

@revati
Copy link
Collaborator

revati commented Feb 28, 2019

Didnt quite catch. How is it hackey?

And what is your solution code wise?

@hauleth
Copy link
Contributor Author

hauleth commented Feb 28, 2019

setup ctx do
  if :foo in ctx.tags do
    # …
  end
end

The "hacky" part is that it does something different from what (I believe) most Elixir developers would expect it to do, which mean that:

@foo "bar"

tag @foo do
  # …
end

Would define setup function for scenarios tagged with @foo not with @bar.

@revati
Copy link
Collaborator

revati commented Feb 28, 2019

I use them, but API is odd, for me more natural way would be

setup_tag :tag, _state do
  ...
end

So then it would be like so

  • setup_all -> setup for test suite as a whole
  • setup -> setup for each scenario (maybe even have alias setup_scenario)
  • setup_tag -> setup some specific scenarios, where tag is provided. (provides ability to import those setups from other model)

I personally don't like the idea with ifs in setup, but it doesn't mean that such functionality should work out of the box as well, but shouldn't be considered as an idiomatic way of cucumber.

Doesn't it work already? As setup should get tags. Currently tag callbacks are executed within setup so it can somehow determine if that particular callback is applicable.

Please look into #74

@revati revati closed this as completed Feb 28, 2019
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