[rspec-users] Calling script/spec from directories other than RAILS_ROOT
dchelimsky at gmail.com
Mon Aug 16 00:45:16 EDT 2010
On Wed, Aug 11, 2010 at 11:56 AM, samullen <samullen at gmail.com> wrote:
> I've written a simple shell function which, depending on where it is
> called, will ascend the directory tree until it finds ./script/spec
> or, failing that, the spec first found in $PATH. What I'm running into
> is that although my tests pass when I call script/spec from
> RAILS_ROOT, they do not pass when it's called from any other location.
> This happens regardless of whether I use my function or call spec
> from RAILS_ROOT -
> script/spec spec/controllers/actors_controller_spec.rb # Passes
> from /home/fooman/rails_project/spec/controllers -
> /home/fooman/rails_project/script/spec actors_controller_spec.rb #
> FAILS because it can't find 'request'
> What do I need to do to run spec for a rails project in a directory
> other than RAILS_ROOT?
1. add :type => controller, :type => view, etc so RSpec knows what
kind of example group to load
1.a. if you're using rspec-2, you'll have to include the correct module instead
2. use absolute paths to require spec_helper
Personally, I'd just keep running the specs from the project root.
> Thank you,
> Samuel Mullen
> rspec-users mailing list
> rspec-users at rubyforge.org
More information about the rspec-users