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
- Add a
binding.pry
above where you’re wondering whatself
is. - These commands once in pry console:
a.ls self
==> see what messages you can implicitly sendself
.
b.self.class.ancestors
==> see what definitions are defining what messagesself
can take. - Let’s see what can be called on
is_expected
:ls self.is_expected
- Now, it’s really obvious that there should be a space and not an underscore between
to
andeq
Some more useful ones…
Given the above breakpoint:
$ eq
and ? eq
We can see monkeypatches!
If a class like NilClass is monkey patched