Module: Kernel

Defined in:
lib/rspec/expectations/extensions/kernel.rb

Instance Method Summary collapse

Instance Method Details

#should(matcher = nil, message = nil, &block) ⇒ Boolean

Passes if matcher returns true. Available on every Object.

Examples:

actual.should eq(expected)
actual.should be > 4

Parameters:

  • matcher (Matcher) (defaults to: nil)
  • message (String) (defaults to: nil)

    optional message to display when the expectation fails

Returns:

  • (Boolean)

    true if the expectation succeeds (else raises)

See Also:



11
12
13
# File 'lib/rspec/expectations/extensions/kernel.rb', line 11

def should(matcher=nil, message=nil, &block)
  RSpec::Expectations::PositiveExpectationHandler.handle_matcher(self, matcher, message, &block)
end

#should_not(matcher = nil, message = nil, &block) ⇒ Boolean

Passes if matcher returns false. Available on every Object.

Examples:

actual.should_not eq(expected)

Parameters:

  • matcher (Matcher) (defaults to: nil)
  • message (String) (defaults to: nil)

    optional message to display when the expectation fails

Returns:

  • (Boolean)

    false if the negative expectation succeeds (else raises)

See Also:



23
24
25
# File 'lib/rspec/expectations/extensions/kernel.rb', line 23

def should_not(matcher=nil, message=nil, &block)
  RSpec::Expectations::NegativeExpectationHandler.handle_matcher(self, matcher, message, &block)
end