class ChefSpec::ExpectException
Public Class Methods
new(formatter_exception, formatter_message = nil)
click to toggle source
# 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
Public Instance Methods
expected?()
click to toggle source
# File lib/chefspec/expect_exception.rb, line 27 def expected? return false if @matcher.nil? exception_matched? && message_matched? end
Private Instance Methods
exception_matched?()
click to toggle source
# File lib/chefspec/expect_exception.rb, line 35 def exception_matched? @formatter_exception == @matcher.last_error_for_chefspec || @matcher.last_error_for_chefspec === @formatter_exception end
message_matched?()
click to toggle source
# File lib/chefspec/expect_exception.rb, line 40 def message_matched? case @formatter_message when nil true when Regexp @matcher.expected_message =~ @formatter_message else @matcher.expected_message == @formatter_message end end