Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Fixing the issues I encountered #24

merged 5 commits into from

3 participants



Tried your rspec-mode, liked it!

Through, I had some issues the first time that I hopefully clear out with these commits.

@pezra pezra merged commit 061e9f3 into pezra:master

Those changes all look very nice. Thanks.


I'm not sure why, but I had to revert this commit in order for rspec-mode to find the project root.

The project I'm testing against is Rails 3.2 with both a Gemfile and Rakefile in the root. No matter where I run the rspec-verify-* functions, they always fail with the message "Could not determine the project root."

I am using rpsec-mode version 20120320 from melpa. If I can help with debugging this, let me know how. I don't have a lot of experience writing emacs packages so I'm at a loss about trying to debug something like this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 38 additions and 3 deletions.
  1. +33 −0
  2. +5 −3 rspec-mode.el
@@ -0,0 +1,33 @@
+# Emacs Rspec Mode
+Rspec mode provides some convenience functions related to dealing with RSpec.
+## Installation
+I recommend installing via ELPA, but manual installation is simple as well:
+ (add-to-list 'load-path "/path/to/rspec-mode")
+ (require 'rspec-mode)
+## Usage
+If `rspec-mode` is installed properly, it will be started
+automatically when `ruby-mode` is started.
+See `rspec-mode.el` for further usage.
+## Gotchas
+### Zsh and RVM
+If you use `ZSH` and `RVM`, you may encounter problems running the
+specs. It may be so that an older version of Ruby, than the one you
+specified in `.rvmrc`, is used. This is because `ZSH` runs a small
+script each time a shell is created, which modifies the `$PATH`. The
+problem is that it prepends some default paths, such as `/usr/bin`,
+which contains another `ruby` binary.
+What you can do to solve this is to use `BASH` for running the
+specs. This piece of code does the job:
+ (defadvice rspec-compile (around rspec-compile-around)
+ "Use BASH shell for running the specs because of ZSH issues."
+ (let ((shell-file-name "/bin/bash"))
+ ad-do-it))
+ (ad-activate 'rspec-compile)
8 rspec-mode.el
@@ -121,7 +121,7 @@
:type 'string
:group 'rspec-mode)
-(defcustom rspec-spec-command "spec"
+(defcustom rspec-spec-command "rspec"
"The command for spec"
:type 'string
:group 'rspec-mode)
@@ -438,8 +438,10 @@
(defun rspec-project-root (&optional directory)
"Finds the root directory of the project by walking the directory tree until it finds a rake file."
(let ((directory (file-name-as-directory (or directory default-directory))))
- (cond ((rspec-root-directory-p directory) nil)
- ((file-exists-p (concat directory "Rakefile")) directory)
+ (cond ((rspec-root-directory-p directory)
+ (error "Could not determine the project root."))
+ ((file-exists-p (expand-file-name "Rakefile" directory)) directory)
+ ((file-exists-p (expand-file-name "Gemfile" directory)) directory)
(t (rspec-project-root (file-name-directory (directory-file-name directory)))))))
(defmacro rspec-from-direcory (directory body-form)
Something went wrong with that request. Please try again.