Class: BasicObject

Defined in:
lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-mocks-3.12.2/lib/rspec/mocks/syntax.rb,
lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/pry-0.14.2/lib/pry/core_extensions.rb,
lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-expectations-3.12.2/lib/rspec/expectations/syntax.rb

Overview

The legacy ‘:should` syntax adds the following methods directly to `BasicObject` so that they are available off of any object. Note, however, that this syntax does not always play nice with delegate/proxy objects. We recommend you use the non-monkeypatching `:expect` syntax instead.

Instance Method Summary collapse

Instance Method Details

#__binding__Binding

Return a binding object for the receiver.

The ‘self` of the binding is set to the current object, and it contains no local variables.

The default definee (yugui.jp/articles/846) is set such that new methods defined will be added to the singleton class of the BasicObject.

Returns:

  • (Binding)


125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/pry-0.14.2/lib/pry/core_extensions.rb', line 125

def __binding__
  # BasicObjects don't have respond_to?, so we just define the method
  # every time. As they also don't have `.freeze`, this call won't
  # fail as it can for normal Objects.
  (class << self; self; end).class_eval(<<-METHOD, __FILE__, __LINE__ + 1)
    # Get a binding with 'self' set to self, and no locals.
    #
    # The default definee is determined by the context in which the
    # definition is eval'd.
    #
    # Please don't call this method directly, see {__binding__}.
    #
    # @return [Binding]
    def __pry__
      ::Kernel.binding
    end
  METHOD
  __pry__
end

#should(matcher, message) ⇒ Boolean

Note:

This is only available when you have enabled the ‘:should` syntax.

Passes if ‘matcher` returns true. Available on every `Object`.

Examples:

actual.should eq expected
actual.should match /expression/

Parameters:

  • matcher (Matcher)
  • message (String)

    optional message to display when the expectation fails

Returns:

  • (Boolean)

    true if the expectation succeeds (else raises)

See Also:



# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-expectations-3.12.2/lib/rspec/expectations/syntax.rb', line 109

#should_not(matcher, message) ⇒ Boolean

Note:

This is only available when you have enabled the ‘:should` syntax.

Passes if ‘matcher` returns false. Available on every `Object`.

Examples:

actual.should_not eq expected

Parameters:

  • matcher (Matcher)
  • message (String)

    optional message to display when the expectation fails

Returns:

  • (Boolean)

    false if the negative expectation succeeds (else raises)

See Also:



# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-expectations-3.12.2/lib/rspec/expectations/syntax.rb', line 121