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 support for multiple examples per code object #3

Merged
merged 2 commits into from
Sep 20, 2016

Conversation

quartzmo
Copy link
Contributor

This PR adds support for writing specific before/after hooks when there are multiple examples per code object (example from google-cloud-ruby) by increasing the detail in the identifier passed to register_hooks.

Some notes:

  1. The new identifier is the spec method name generated by Minitest::Spec. This makes it very simple to match hooks to failing tests, all you need to do is copy the name from the Minitest output.
  2. Because hooks are matched by testing include? on the hook name, backwards-compatibility is maintained for less-specific hook names (all Cucumber tests pass.)
  3. As was the case before, less-specific hook names will also be matched, so hook order is important.

I'm happy to make any edits/changes, just let me know!

/cc @blowmage

@quartzmo
Copy link
Contributor Author

The failing Cucumber test is due to a change in Minitest: "Add encoding information when test fails." minitest/minitest#620. Let me know if you want me to update the Cucumber expectation in this PR.

Copy link
Owner

@p0deje p0deje left a comment

Choose a reason for hiding this comment

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

The new identifier is the spec method name generated by Minitest::Spec. This makes it very simple to match hooks to failing tests, all you need to do is copy the name from the Minitest output.

Maybe it's better to just use example name in this case?

@flag = true
end

YARD::Doctest.before('#flag#test_0001_Second example for flag') do
Copy link
Owner

Choose a reason for hiding this comment

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

What do you think if we use a different notation, e.g. #flag@Second example for flag? I feel like #test_0001_ in is implementation detail provided by Minitest.

I'm good to merge this anyways if you don't like the proposed changes.

@p0deje
Copy link
Owner

p0deje commented Sep 19, 2016

The failing Cucumber test is due to a change in Minitest: "Add encoding information when test fails." minitest/minitest#620. Let me know if you want me to update the Cucumber expectation in this PR.

That would be great!

@p0deje
Copy link
Owner

p0deje commented Sep 19, 2016

Thanks for the PR! I'm definitely ready to merge it, but I'll wait until you answer to my comments above.

@quartzmo
Copy link
Contributor Author

Great suggestion for the notation, it is much cleaner. (Should I also add an example to the README?)

I'll update the PR later today with both changes.

@p0deje
Copy link
Owner

p0deje commented Sep 20, 2016

I'll add new hooks to README, create CHANGELOG and release new version today. Thanks again for PR!

@p0deje p0deje merged commit b3614c3 into p0deje:master Sep 20, 2016
@p0deje
Copy link
Owner

p0deje commented Sep 20, 2016

Released in 0.1.6

@blowmage
Copy link

👏🏻

@quartzmo
Copy link
Contributor Author

@p0deje Thank you!

googleapis/google-cloud-ruby#901 is the beginning of our effort to test all of the google-cloud doc examples (current count: 772) with yard-doctest. Thank you very much for creating and maintaining it!

@p0deje
Copy link
Owner

p0deje commented Sep 21, 2016

@quartzmo Thank you for using it! It's really cool to build something that is used by Google.

@quartzmo quartzmo deleted the multiple-examples branch October 12, 2016 15:59
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.

3 participants