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

Allow rake notes to work with other directories. #25692

Merged
merged 3 commits into from Jul 5, 2016

Conversation

Projects
None yet
7 participants
@johnmeehan
Contributor

johnmeehan commented Jul 5, 2016

rake notes is a very useful tool lets make it more useful.

The SourceAnnotationExtractor currently has no way of extracting notes from directories other than the predefind directories (app, config, db, lib, test).

The trouble is I would like to be able to extract notes from other folders in the project such as the /spec folder ( if using RSpec ).

This pull request will allow you/gems to register other directories with the SourceAnnotationExtractor.

Currently it is possible to register file extensions. So why not directories?

Registers additional directories to be included
SourceAnnotationExtractor::Annotation.register_directories("spec","another")

Tested in test/application/rake/notes_test.rb

Result:

$ rake notes
app/spec/models/article_spec.rb:
  * [2] [TODO] add more specs
  * [3] [FIXME] Spec A is broken
  * [4] [OPTIMIZE] improve this test

John

also discussed here #25576

Additional directories can be added using
SourceAnnotationExtractor::Annotation.register_directories("spec", "other_dir")

Result: rake notes will now extract notes from these directories.

Allow rake notes to work with other directories.
Additional directories can be added using
SourceAnnotationExtractor::Annotation.register_directories("spec", "other_dir")

Result: rake notes will now extract notes from these directories.
@rails-bot

This comment has been minimized.

rails-bot commented Jul 5, 2016

Thanks for the pull request, and welcome! The Rails team is excited to review your changes, and you should hear from @senny (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@maclover7 maclover7 added the railties label Jul 5, 2016

@@ -126,6 +126,18 @@ def teardown
end
end
test 'register additional directories' do
app_file "app/spec/spec_helper.rb", "# TODO: note in spec"

This comment has been minimized.

@robin850

robin850 Jul 5, 2016

Member

The app folder is already present, I think you meant to write "spec/spec_helper.rb, otherwise your test will pass even without the add_to_config call.

Fix test to try `spec/` directory as opposed to `app/spec` which I had
accidently set it to.

Made the change and test still passes.
@johnmeehan

This comment has been minimized.

Contributor

johnmeehan commented Jul 5, 2016

Good catch! I'm pushing a fix now and the tests still pass.

@rafaelfranca

This comment has been minimized.

Member

rafaelfranca commented Jul 5, 2016

Awesome! Thanks.

@rafaelfranca rafaelfranca merged commit aed11fd into rails:master Jul 5, 2016

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

@johnmeehan johnmeehan deleted the johnmeehan:allow-registering-directory-for-rake-notes branch Jul 5, 2016

johnmeehan added a commit to johnmeehan/rspec-rails that referenced this pull request Jul 5, 2016

As of Rails 5.1.0 gems can register a directories with the
Rails SourceAnnotationExtractor which means when we run `rake notes` it will now also
for the first time list out any todos in the `/spec` folder.

This was added in this PR:
rails/rails#25692

Resulting in:

```bash

$ rake notes
app/spec/models/article_spec.rb:
  * [2] [TODO] add more specs
  * [3] [FIXME] Spec A is broken
  * [4] [OPTIMIZE] improve this test

```
@arthurkulchenko

This comment has been minimized.

arthurkulchenko commented Jul 6, 2016

Yay, Thanks!

robin850 added a commit to robin850/rails that referenced this pull request Jul 6, 2016

johnmeehan added a commit to johnmeehan/rspec-rails that referenced this pull request Jul 7, 2016

In this commit:
* just fixed the railtie

As of Rails 5.1.0 gems can register a directories to work with `rake
notes`

In this case we can tell Rails it to now look in the `/spec` folder when
searching for annotations like `# TODO:` `# FIXME` etc.

This was added in this PR:
rails/rails#25692

Resulting in:

```bash

$ rake notes
app/spec/models/article_spec.rb:
  * [2] [TODO] add more specs
  * [3] [FIXME] Spec A is broken
  * [4] [OPTIMIZE] improve this test

```

Thats one less daily annoyance.

John

rafaelfranca added a commit that referenced this pull request Jul 8, 2016

JonRowe added a commit to rspec/rspec-rails that referenced this pull request Jul 9, 2016

Rake notes compatibility in Rails 5.1.0 (#1661)
* As of Rails 5.1.0 gems can register a directories with the
Rails `SourceAnnotationExtractor` which means when we 
run `rake notes` it will now also list out any todos in the
`/spec` folder.

This was added in this PR:
rails/rails#25692

Resulting in:

```bash

$ rake notes
app/spec/models/article_spec.rb:
  * [2] [TODO] add more specs
  * [3] [FIXME] Spec A is broken
  * [4] [OPTIMIZE] improve this test

```

* In this commit:
* just fixed the railtie

As of Rails 5.1.0 gems can register a directories to work with `rake
notes`

In this case we can tell Rails it to now look in the `/spec` folder when
searching for annotations like `# TODO:` `# FIXME` etc.

This was added in this PR:
rails/rails#25692

Resulting in:

```bash

$ rake notes
app/spec/models/article_spec.rb:
  * [2] [TODO] add more specs
  * [3] [FIXME] Spec A is broken
  * [4] [OPTIMIZE] improve this test

```

vijaydev pushed a commit that referenced this pull request Aug 2, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment