Method: ArgumentSpecification::Argument#should_not

Defined in:
lib/argspec/argument.rb

#should_not(matcher, &block) ⇒ Object

Ensure the argument does not match

Arguments:

matcher: (Matchers::BaseMatcher)
block: (Block)

Example:

>> should_not be_a(Symbol)
=> #<Argument:0x00000000000000 @actual=:test>

Raises:

ArgumentError: When the argument matches

Raises:

  • (ArgumentError)


63
64
65
66
67
68
69
70
71
72
# File 'lib/argspec/argument.rb', line 63

def should_not(matcher, &block)
  return self unless matcher.is_a?(Matchers::BaseMatcher)

  matcher.send(:actual=, @actual)
  matcher.send(:block=, block) if block_given?

  return self unless matcher.matches?

  raise ArgumentError, matcher.failure_message_when_negated
end