[rspec-users] Help: Attempts to run specs quitting midstream

Matt Griffith lists at ruby-forum.com
Tue Nov 18 12:06:40 EST 2008

Evan Dorn wrote:
> I am having a very frustrating problem running specs on my current
> project.  When I run tests en masse with "rake spec" or with autotest,
> it frequently quits without completing all the tests.   It also
> sometimes runs the tests in multiple batches, giving more than one
> result line for a single batch of tests.

I was having a similar problem. My specs would quit running after a 
third of them ran. When I ran my specs using ./script/spec spec I'd get 
a different count and my specs would run as two batches.

I decided to run each of my specs separately using something like:

ruby script/spec "spec/controllers/name_of_a_specific_spec.rb"

That showed that some of my specs were in fact failing. If I tried to 
run ./script/specs with any options I'd get a report of:

0 examples, 0 failures

Then I decided to run each directory under spec/* separately so I could 
try to narrow down which specs were causing the problem. I ran:

./script/spec spec/controllers
./script/spec spec/models
./script/spec spec/views

When I ran views I got the same "0 examples, 0 failures" message so I 
ran each folder separately:

./script/spec spec/views/view_1
./script/spec spec/views/view_2

That let me narrow it down to specific views that were causing the 
problem. Then I ran each spec separately.

My problem was caused by using 
template.should_receive(:current_user).and_return(@user). Commenting 
that out fixed RSpec for me. I can now run it using rake spec or even 
rake spec:rcov and it works the same as running ./script/spec spec.

Hope that helps. I'm still not sure why RSpec is failing this way.

Matt Griffith
Posted via http://www.ruby-forum.com/.

More information about the rspec-users mailing list