Class: Easytest::Matcher::RaiseNothing

Inherits:
Base
  • Object
show all
Defined in:
lib/easytest/matcher/raise_nothing.rb

Instance Attribute Summary

Attributes inherited from Base

#actual, #expected, #negate

Instance Method Summary collapse

Methods inherited from Base

#match!

Constructor Details

#initialize(actual:) ⇒ RaiseNothing

Returns a new instance of RaiseNothing.



4
5
6
# File 'lib/easytest/matcher/raise_nothing.rb', line 4

def initialize(actual:)
  super(actual: actual, expected: nil)
end

Instance Method Details

#match?Boolean

Returns:

  • (Boolean)


8
9
10
11
12
13
14
15
16
# File 'lib/easytest/matcher/raise_nothing.rb', line 8

def match?
  begin
    actual.call
    true
  rescue => error
    @raised_error = error
    false
  end
end

#messageObject



22
23
24
# File 'lib/easytest/matcher/raise_nothing.rb', line 22

def message
  "raise nothing"
end

#raise_match_errorObject

Raises:



18
19
20
# File 'lib/easytest/matcher/raise_nothing.rb', line 18

def raise_match_error
  raise MatchError.new(message: build_error_message, actual: @raised_error, expected: expected)
end