Created
August 9, 2014 12:11
-
-
Save Ragmaanir/2d038cf78a84cf37f461 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
module X | |
C = 1 | |
end | |
describe 'Test' do | |
include X | |
it '...' do | |
p C | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
RSpec doesn't do anything magical, it follows normal ruby scoping and constant look up. Including a module does not include it's constants in Ruby. It includes only the public instance methods. If you need module constants to be available, the spec either needs to be in the module, or use the fully qualified namespace, i.e.
X::C
.I would not suggest wrapping arbitrary specs inside a module just to access the constant. That idiom really only makes sense when unit testing something inside the module. Then it allows for constant references that mirror the code and the specs.