I wanted to include module into ExampleGroup to write less code within
examples, but was unable to do so. This seems to be strange, because
in regular Class it works and all methods within that module are also
accessible. See the example:
module MyModule
MyConstant = 1
def my_method
2
end
end
describe “including modules” do
include MyModule
it “works” do
my_method.should == 2
MyModule::MyConstant.should == 1
end
it “doesn’t work” do
MyConstant.should == 1
end
end
Running this simple spec will produce one failure with this message:
1)
NameError in ‘including modules doesn’t work’
uninitialized constant MyConstant
Is this an expected behaviour? Is there some other way to access
constants from another module without specifying module name within
examples?