-
-
Save anonymous/ed7fced52dbde5cd36f9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class A | |
include ::RSpec::Matchers | |
def foo | |
expect('1'.to_i).to eq 1 | |
end | |
end | |
puts A.new.foo #=> | |
=begin | |
If we comment out include ::RSpec::Matchers we get an undefined error for expect. | |
So ::RSpec::Matchers, somehow, contains expect | |
And yet ::RSpec::Matchers.methods.include? :expect #=> false | |
And there's all kinds of weirdness going on here. | |
I expected this to work to not throw an error: | |
include ::RSpec::Matchers | |
expect('1'.to_i).to eq 1 | |
Instead the expect HAS to be inside an instance method of a class otherwise expect is undefined. | |
Could someone explain? Hopefully when somebody explains how ::RSpec::Matchers doesn't contain 'expect' but | |
provides 'expect' it will clear the latter questions up. | |
=end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment