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

Add nested steps note to step-definitions #89

Merged
merged 7 commits into from
Dec 27, 2017
Merged

Add nested steps note to step-definitions #89

merged 7 commits into from
Dec 27, 2017

Conversation

mxygem
Copy link
Member

@mxygem mxygem commented Dec 16, 2017

I'm not certain if this is the best place for it, but it makes sense to me! I'm open to feedback and assistance in duplicating my examples in js and java.

p.s. I've got a longer, more article/blog type document written also, but it doesn't fit in the documentation type, style.

@mxygem
Copy link
Member Author

mxygem commented Dec 16, 2017

Checks that failed were the wayback urls timing out, nothing that I did. :)

9:48:39 AM: - public/about/related-tools/index.html
9:48:39 AM:   *  External link http://web.archive.org/web/20091004184554/http://redshades.rha7.com failed: got a time out (response code 0)
9:48:40 AM: - public/implementations/ruby/minitest/index.html
9:48:40 AM:   *  External link https://web.archive.org/web/20120701103558/http://cheat.errtheblog.com/s/minitest/1 failed: got a time out (response code 0)
9:48:40 AM: - public/wiki/cucumber-backgrounder/index.html
9:48:40 AM:   *  External link http://web.archive.org/web/20130424133851/http://aslakhellesoy.com/post/11055981222/the-training-wheels-came-off failed: got a time out (response code 0)
9:48:40 AM: /opt/build/cache/bundle/ruby/2.4.0/gems/html-proofer-3.7.4/lib/html-proofer/runner.rb:167:in `print_failed_tests': HTML-Proofer found 3 failures! (RuntimeError)

Copy link
Member

@mlvandijk mlvandijk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @jaysonesmith - this is a nice addition! The content is good, but maybe see if you could edit the paragraphs to have shorter, clearer sentences? That would make it even better!


### Nested Steps

In an effort to keep your code DRY, you may be tempted to utilize Cucumber's feature of calling step definitions from other steps: **DON'T**. While this may seem like a useful feature to utilize, it creates bad code smells and can make things like readability difficult and stack traces terrible. Instead, in places where you're calling steps from other steps, use those as opportunities to refactor your code to create helper methods to use instead.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe explain "DRY" (for non-developers)?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAIK nested steps are only possible in Ruby, so mark this text block with {{% text "ruby" %}} {{% /text %}}
Also, java & js examples will not be needed ;)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something to consider: As this is (also) a Best practice / Anti-pattern, maybe it should be in best-practices rather than step-definitions? On the other hand, this would probably the place where people read about how to write step definitions, so this might actually be the best place.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also here, see if you can make the sentences shorter & clearer by splitting them or removing words (i.e. duplicate "instead" in last sentence).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • I'll rephrase and do a link to the wiki article on DRY. :)
  • While not a part of the official Cucumber repo, the implementation of Cucumber in Go also allows for nested steps. Perhaps when trying to inform folks about this, I can just point them to the Ruby version of it instead.
  • I'm open to adding a note to the best-practice page too. I'll do a different PR for that once we get this settled.
  • Thanks for catching the duplicate instead! Ugh. I'll work on rephrasing, thanks!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great! Currently the polyglot pages have tabs for Java/Javascript/Ruby. Not sure what to do about the other language implementations, as they don't have a place in the nw menu structure anymore...?

```
{{% /text %}}

This refactoring has multiple benefits, but core to this topic is that it would then allow you to access this code more easily throughout all of your steps as needed, instead of having to call a step to do it. You get much more flexibility, readabilitiy, and usability with helper methods. Lastly, they won't be deprecated in the future!
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sentences shorter to make them easier to read on a screen; split them into multiple sentences if needed. Here, you might also use a bullit list?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Noted!

@mlvandijk
Copy link
Member

@jaysonesmith Also: sometimes HTMLProofer fails on external links, if they don't respond fast enough. If you feel like it, hit "Retry" until they pass.. If you really feel like it, see if you can figure out how to configure it to skip them (#30 - we decided on won't fix earlier, but it's getting kind of annoying...)

@mlvandijk
Copy link
Member

The following links are failing on HTMLProoofer:
9:23:02 AM: * External link http://watirmelon.com/2011/01/21/my-simple-cucumber-watir-page-object-pattern-framework failed: 404 No error

I've checked one of them and am getting:"Oops! That page can’t be found."
So these links need to be updated/removed(?)

@mlvandijk
Copy link
Member

Removed dead links to fix the build and rebased your branch onto master.

@mlvandijk mlvandijk merged commit b4c2f06 into master Dec 27, 2017
@mlvandijk mlvandijk deleted the nested-steps branch December 27, 2017 20:45
@mxygem
Copy link
Member Author

mxygem commented Jan 2, 2018

Thanks @mlvandijk !

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.

None yet

2 participants