[rspec-users] Shared Examples + “initialized constant” warnings

Gerrit Kaiser gerrit+rspec-devel at gerritkaiser.de
Fri Feb 8 00:41:07 EST 2008


Hi List,
I'm using rspec's shared example groups in a rails project (rails  
2.02, rspec(on_rails) 1.1.3) and I'm getting lots of errors of the  
following kind when(before) running the specs:

(RAILS_ROOT)/vendor/plugins/rspec/lib/spec/extensions/main.rb:78:  
warning: already initialized constant ContentExamples
(RAILS_ROOT)/vendor/plugins/rspec/lib/spec/extensions/main.rb:78:  
warning: already initialized constant EditViewExamples

The shared example groups are defined in files like spec/shared/ 
foo_examples.rb
and declared as
share_as :FooExamples do…end
(and then included in other example groups with "include FooExamples")
They're loaded in spec_helper.rb with the following:
Dir.glob(File.join(File.dirname(__FILE__), 'shared', '*.rb')).each do | 
shared_example|
   require shared_example
end


I'm guessing that's what needs to change. Has anyone else seen these  
warnings? I find them quite annoying and would like to get rid of  
them. Any pointers would be much appreciated.
Thanks,
Gerrit


More information about the rspec-users mailing list