module RSpec::Given::HaveFailed

Public Instance Methods

have_failed([exception_class [, message_pattern]]) click to toggle source
have_failed([exception_class [, message_pattern]]) { |ex| ... }

Simular to raise_error(…), but reads a bit better when using a failure result from a when clause.

Typical Usage:

When(:result) { fail "OUCH" }
Then { expect(result).to have_failed(StandardError, /OUCH/) }

When(:result) { good_code }
Then { expect(result).to_not have_failed }
   # File lib/given/rspec/have_failed.rb
31 def have_failed(error=Exception, message=nil, &block)
32   HaveFailedMatcher.new(error, message, &block)
33 end
Also aliased as: have_raised
Alias for: have_failed