Skip to content

Instantly share code, notes, and snippets.

@teeparham
Created October 4, 2016 16:11
Show Gist options
  • Save teeparham/d953a24ded37675d0808adf385ea14a8 to your computer and use it in GitHub Desktop.
Save teeparham/d953a24ded37675d0808adf385ea14a8 to your computer and use it in GitHub Desktop.
Don't put your tests in modules
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