Class: Expect::Undefined
- Inherits:
-
ExpectBase
- Object
- ExpectBase
- Expect::Undefined
- Defined in:
- lib/expect.rb
Overview
Checks if actual does not respond to a method
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from ExpectBase
Instance Method Summary collapse
-
#initialize(actual, method) ⇒ Undefined
constructor
A new instance of Undefined.
-
#run ⇒ AssertPass, AssertFailure
Runs the validator and returns an AssertResult.
Constructor Details
#initialize(actual, method) ⇒ Undefined
Returns a new instance of Undefined.
134 135 136 137 |
# File 'lib/expect.rb', line 134 def initialize(actual, method) super(actual: actual) @method = method end |
Instance Method Details
#run ⇒ AssertPass, AssertFailure
Runs the validator and returns an AssertResult
141 142 143 144 145 146 |
# File 'lib/expect.rb', line 141 def run return AssertPass.new unless @actual.methods.include?(@method) @actual = @actual.nil? ? '<nil>' : @actual AssertFailure.new("Undefined failed: Expected #{@actual} to not respond to #{@method}.") end |