samullen
2010-Aug-11 16:56 UTC
[rspec-users] Calling script/spec from directories other than RAILS_ROOT
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 directly. Examples: 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? Thank you, Samuel Mullen
David Chelimsky
2010-Aug-16 04:45 UTC
[rspec-users] Calling script/spec from directories other than RAILS_ROOT
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 > directly. > > Examples: > 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. HTH, David> > Thank you, > Samuel Mullen > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >