run tests on files changed since last commit

208 views
Skip to first unread message

Alon Dahari

unread,
Apr 10, 2017, 3:18:28 AM4/10/17
to rspec
Hi,
I have a pre-commit hook on my project to run my rspec tests and prevent commit on failures.
As the project grows, running the tests is getting slower.
Is there a way to run only tests that touch files changed since last commit (staged files)?

Thanks!

Myron Marston

unread,
Apr 10, 2017, 3:20:25 AM4/10/17
to rs...@googlegroups.com
RSpec does not provide anything like this (it is agnostic about what source control system you are using, if any).

You could write a script to query git for the list of files that have changed since last commit, and pass the spec files in that list to the `rspec` command.

HTH,
Myron

--
You received this message because you are subscribed to the Google Groups "rspec" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rspec+unsubscribe@googlegroups.com.
To post to this group, send email to rs...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rspec/50c0145b-36d4-431a-a6d5-4d7faf8e87a9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jon Rowe

unread,
Apr 10, 2017, 4:51:17 AM4/10/17
to rs...@googlegroups.com
I use an alias to do something similar which runs `git ls-files -mo --exclude-standard | exists | grep _spec\.rb$ | xargs bundle exec rspec` you could give that a try

Jon Rowe
---------------------------

To unsubscribe from this group and stop receiving emails from it, send an email to rspec+un...@googlegroups.com.

To post to this group, send email to rs...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages