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 line number in methods defined by "it" #634

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

tenderlove
Copy link

This commit adds the line number of the method defined by "it" blocks in
minitest/spec. Our tests at work are "spec" style (they use the DSL to
define tests), and we add a line number to the method name that gets
defined. The reason I like this is because I can write a test, then run
that single test without trying to guess how the test framework defines
the method, I just do:

$ ruby test_file.rb -n /L56/

This also makes running the single test from Vim quite easy because the
editor can just grab the line number and pass it as a parameter to the
test runner.

This patch only adds the line number if the Ruby version being used
supports source_location on the Proc object, so this should work on
all versions of Ruby.

This commit adds the line number of the method defined by "it" blocks in
minitest/spec.  Our tests at work are "spec" style (they use the DSL to
define tests), and we add a line number to the method name that gets
defined.  The reason I like this is because I can write a test, then run
that single test without trying to guess how the test framework defines
the method, I just do:

```
$ ruby test_file.rb -n /L56/
```

This also makes running the single test from Vim quite easy because the
editor can just grab the line number and pass it as a parameter to the
test runner.

This patch only adds the line number if the Ruby version being used
supports `source_location` on the `Proc` object, so this should work on
all versions of Ruby.
@zamith
Copy link

zamith commented Aug 4, 2016

Have you considered using m? Not a fan of using an executable other than ruby to run the tests?

@tenderlove
Copy link
Author

@zamith I am quite happy with my existing dev setup, thanks.

@zenspider zenspider self-assigned this Aug 27, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants