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 rspec-run-last-failed to rerun only failed examples #122

Closed
wants to merge 3 commits into from
Closed

add rspec-run-last-failed to rerun only failed examples #122

wants to merge 3 commits into from

Conversation

ledbettj
Copy link
Contributor

rspec-run-last-failed will re-run the specs that failed during the last invocation. By default this is bound to C-c ,f.

I'm not an elisp pro so I'm sure there's some cleanup that can be done here. Feedback welcome!

@rranelli
Copy link
Contributor

I have not tested it yet, but I think this is an awesome feature 👍

@@ -668,6 +676,10 @@ or a cons (FILE . LINE), to run one example."
(message "No spec files found!")
(rspec-compile (rspec-runner-target spec-files) opts)))

(defvar rspec-last-failed-specs
'()
Copy link
Collaborator

Choose a reason for hiding this comment

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

'() is the same as nil, and no need to put it on a separate line.

rspec-run-last-failed will re-run the specs that failed during the last
invocation.  By default this is bound to C-c ,f.
@ledbettj
Copy link
Contributor Author

Changes:

  • Replaced '() with nil.
  • Added compilation hook locally instead of globally.
  • Removed weird space.
  • Fixed keybinding to be in the right keymap.
  • Moved regexp logic into the rspec-store-failures function.

Thanks for the comments!

(failure-regexp "^rspec \\([0-9A-Za-z@_./:-]+\\.rb:[0-9]+\\)")
(failures (save-match-data
(let ((pos 0) matches)
(while (string-match failure-regexp body pos)
Copy link
Collaborator

Choose a reason for hiding this comment

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

This would be better performed with re-search-forward. You don't copy the buffer text into a string; instead use save-excursion, (goto-char (point-min)), and traverse the buffer till the end while saving the matches,

@ledbettj
Copy link
Contributor Author

Thanks for the comment. I've updated the logic, hopefully correctly.

@ledbettj
Copy link
Contributor Author

Dropped the save-match-data as well.

@dgutov
Copy link
Collaborator

dgutov commented May 21, 2015

Squash-merged. Thanks!

@dgutov dgutov closed this May 21, 2015
@ledbettj
Copy link
Contributor Author

👍 Thanks!

@ledbettj ledbettj deleted the rerun-failed branch May 21, 2015 15:46
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