views:

202

answers:

2

Is there any way to have RSpec continue processing specifications after an exception is raised?

This is what my spec task looks like:

SPEC_PATTERN = "spec/**/*_spec.rb"
Spec::Rake::SpecTask.new() do |t|
  t.spec_files = FileList[SPEC_PATTERN]
  t.verbose = true
  t.spec_opts = ["--format", "html:spec/spec_report.html"]
  t.fail_on_error = false

  t.rcov = true
  t.rcov_dir = 'coverage'
  t.rcov_opts = ['--exclude', 'spec']
end
+1  A: 

what about using "should raise_exception"?
http://rspec.rubyforge.org/rspec/1.3.0/classes/Spec/Matchers.html#M000183

rubiii
It *shouldn't* raise an exception. The problem is that I have a failing test that currently raises an exception, and the RSpec task immediately exits - which means that I don't get to see what all passed and what all failed. In Test::Unit I would get a list of all passing/failing tests, where test that throws is considered a failure. Is there any way to get that functionality in RSpec?
Charles
+1  A: 

Hi Charles - rspec does capture exceptions and report them as failures, in much the same way test/unit does. If you're seeing the task exiting it's because the exception is either outside of the code that rspec is handling, or it might be a syntax error.

HTH, David

David Chelimsky
Excellent, I'll double check my tests and see if I'm doing something silly. I'll let you what I find.
Charles
Are we sure about this? I am experiencing this behavior too. I am using:rspec (2.0.0, 1.3.1)rspec-core (2.0.0)rspec-expectations (2.0.0)rspec-mocks (2.0.0)rspec-rails (1.3.3, 1.3.1)
Amala