I’m trying to learn rspec, and came across something unexpected with
the following code. A little googling hasn’t turned any answers up so
far…
module TestHelper
CONSTANT = “constant”
end
context “A context” do
include TestHelper
specify “should allow unqualified access to included constants” do
CONSTANT.should_eql “constant”
end
specify “should allow qualified access to all constants” do
TestHelper::CONSTANT.should_eql “constant”
end
end
…I would expect both specifications to pass since I think that’s the
way Ruby itself behaves when using include (you get direct access to
constants in the local scope when included, right?), but the
unqualified specification fails. Is this a bug in rspec, a “feature”
of rspec, a mistake on my part, or something else?
way Ruby itself behaves when using include (you get direct access to
constants in the local scope when included, right?), but the
unqualified specification fails. Is this a bug in rspec, a “feature”
of rspec, a mistake on my part, or something else?
Ah, okay. Thanks a lot for the pointer. I should have searched the
tracker specifically. Next time =]
No problem.
Also - are you aware that there are lists specifically for rspec users
and developers? I try to keep an eye on rspec related messages on the
ruby-talk list, but the rspec lists have the eyes of a lot more people
so you might get better traction on your rspec questions there: