Happy New Year everyone!!

I'm having a painful upgrade from Rails 2.3.11 to Rails 3.1.3 and one of
the problems is with the following....

Under Ruby 1.8.7 - Rails 2.3.11 - Rspec 1:

I have model_macros.rb under spec/spec_helpers and it runs beautifully.

Dir[File.expand_path(File.join(File.dirname(__FILE__), 'spec_helpers',
'**', '*.rb'))].each { require f }
config.extend(ModelMacros, :type => :model)

Exactly the same code under Ruby 1.9.2 - Rails 3.1.3 - Rspec 2 gives me ...
uninitialized constant ModelMacros (NameError)

Dir[Rails.root.join("spec/spec_helpers/**/*.rb")].each {|f| require f}
config.extend(ModelMacros, :type => :model)

.... which makes sense as it's missing the namespace (but how did it run
under 2.3.11. Is Ruby 1.8.7 more lenient? - I doubt it)

So I added the namespace and I got rid of that error

config.extend(SpecHelpers::ModelMacros, :type => :model)

But sadly the methods that are called from within the model specs are
unable to be found...... Exception encountered: #<NoMethodError: undefined
method `it_should_require_attributes'

This is only solved by including extend SpecHelpers::ModelMacros in the
model spec file. Not what I want.

Is there something I am missing while migrating all my code? Is there some
really basic Ruby thing I have forgotten to do to get this module included?

I also tried config.include(SpecHelpers::ModelMacros, :type => :model) but
to no avail.

Any help would be great, thank you.

-ants
_______________________________________________
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users

Reply via email to