Method: Object#refute!
- Defined in:
- lib/mini_sanity/assert.rb
#refute!(pattern = MiniSanity::TRUTHY, hint: nil) ⇒ self #refute!(pattern = MiniSanity::TRUTHY, hint: nil) {|itself| ... } ⇒ self
Checks that a given pattern
does not match the Object (or a derivative value), and returns the Object. Raises an exception if the pattern matches.
If a block is given, the Object is yielded to the block, and the derivative value returned by the block is checked instead.
147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 |
# File 'lib/mini_sanity/assert.rb', line 147 def refute!(pattern = MiniSanity::TRUTHY, hint: nil, &block) result = block ? block.call(self) : self if pattern === result raise MiniSanity::Error.new("Refute failed", { "Value" => self.inspect, "Derived value (from #{MiniSanity::Error.describe_block(&block) || "block"})" => (result.inspect if block), "Refute matches" => pattern.inspect, "Hint" => hint, }) end self end |