Class: ChefSpec::ExpectException

Inherits:
Object
  • Object
show all
Defined in:
lib/chefspec/expect_exception.rb

Instance Method Summary collapse

Constructor Details

#initialize(formatter_exception, formatter_message = nil) ⇒ ExpectException

Returns a new instance of ExpectException.



21
22
23
24
25
# File 'lib/chefspec/expect_exception.rb', line 21

def initialize(formatter_exception, formatter_message = nil)
  @formatter_exception = formatter_exception
  @formatter_message   = formatter_message
  @matcher             = RSpec::Matchers::BuiltIn::RaiseError.last_run
end

Instance Method Details

#expected?Boolean

Returns:

  • (Boolean)


27
28
29
30
31
# File 'lib/chefspec/expect_exception.rb', line 27

def expected?
  return false if @matcher.nil?

  exception_matched? && message_matched?
end