Binding.pry and introspection

Must have techniques for figuring out what’s going on with the implicit self

Where is the bug here:

      describe ".react_on_rails_pro?" do
        subject { described_class.react_on_rails_pro? }
        it do
          binding.pry
          is_expected.to_eq(false)
        end
      end

You get the error message:

NoMethodError: undefined method `to_eq' for #<RSpec::Expectations::ExpectationTarget:0x00007ff1be9a0210>
Did you mean?  to_s
  1. Add a binding.pry above where you’re wondering what self is.
  2. These commands once in pry console:
    a. ls self ==> see what messages you can implicitly send self.
    b. self.class.ancestors ==> see what definitions are defining what messages self can take.
  3. Let’s see what can be called on is_expected: ls self.is_expected
  4. Now, it’s really obvious that there should be a space and not an underscore between to and eq

Some more useful ones…

Given the above breakpoint:

$ eq and ? eq

We can see monkeypatches!

If a class like NilClass is monkey patched

Using the -a option