Module: Spec::Expectations::ObjectExpectations

Module | Spec::Expectations::ObjectExpectations
In: | lib/spec/expectations/extensions/object.rb

rspec adds should and should_not to every Object (and, implicitly, every Class).

### Methods

should should_not

### Public Instance methods

should(matcher)
should == expected
should === expected
should =~ expected

      receiver.should(matcher)
        => Passes if matcher.matches?(receiver)

      receiver.should == expected #any value
        => Passes if (receiver == expected)

      receiver.should === expected #any value
        => Passes if (receiver === expected)

      receiver.should =~ regexp
        => Passes if (receiver =~ regexp)

See Spec::Matchers for more information about matchers

## Warning

NOTE that this does NOT support receiver.should != expected. Instead, use receiver.should_not == expected

[Source]

        # File lib/spec/expectations/extensions/object.rb, line 30
    30:       def should(matcher = :default_parameter, &block)
    31:         if :default_parameter == matcher
    32:           Spec::Matchers::PositiveOperatorMatcher.new(self)
    33:         else
    34:           ExpectationMatcherHandler.handle_matcher(self, matcher, &block)
    35:         end
    36:       end

should_not(matcher)
should_not == expected
should_not === expected
should_not =~ expected

      receiver.should_not(matcher)
        => Passes unless matcher.matches?(receiver)

      receiver.should_not == expected
        => Passes unless (receiver == expected)

      receiver.should_not === expected
        => Passes unless (receiver === expected)

      receiver.should_not =~ regexp
        => Passes unless (receiver =~ regexp)

See Spec::Matchers for more information about matchers

[Source]

        # File lib/spec/expectations/extensions/object.rb, line 57
    57:       def should_not(matcher = :default_parameter, &block)
    58:         if :default_parameter == matcher
    59:           Spec::Matchers::NegativeOperatorMatcher.new(self)
    60:         else
    61:           NegativeExpectationMatcherHandler.handle_matcher(self, matcher, &block)
    62:         end
    63:       end

[Validate]