Created
October 4, 2016 16:11
-
-
Save teeparham/d953a24ded37675d0808adf385ea14a8 to your computer and use it in GitHub Desktop.
Don't put your tests in modules
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 X | |
def x | |
"X" | |
end | |
end | |
module Y | |
class X | |
def x | |
"Y::X" | |
end | |
end | |
end | |
# Let's not put our tests in modules in an effort to write less code | |
# UNEXPECTED | |
module Test | |
p X.new.x | |
# "X" | |
module Y | |
class TheTest | |
p X.new.x | |
# NOT WHAT YOU EXPECTED | |
# "X" | |
end | |
end | |
end | |
# BETTER - be explicit about namespacing | |
class TheTest | |
p X.new.x | |
# "X" | |
p Y::X.new.x | |
# "Y::X" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment