I have a bunch of classes that are polymorphs, with has_many_polymorphs
(they are all ‘labellable’, which is similar to being ‘taggable’ in the
acts_as_taggable scheme). I have a couple of modules,
LabellableInstanceMethods and LabellableClassMethods in a file called
labellable_methods.rb.
The classes all get labelled with ‘properties’, and i set out to write
the
Property class first, using bdd of course. This all went fine.
However,
when i came to start testing that the labelling was working properly, i
added the following code:
Now, whenever i run the spec file, it bombs out as soon as it hits a
reference to the Property class (at the start of my main describe
block),
saying
“/home/jars/rails/lesson_planner/branches/max/vendor/rails/activerecord/lib/…/…/activesupport/lib/active_support/dependencies.rb:249:in
`load_missing_constant’: Expected
/home/jars/rails/lesson_planner/branches/max/app/models/property.rb to
define Property (LoadError)”
If i play around with the labelling system in the console, it seems to
work
fine: ie, the above code works ‘normally’, but is totally breaking the
spec
file.
Does anyone have any ideas about this? It’s driving me crazy and
stopping
me speccing other aspects of my labelling system.
when i came to start testing that the labelling was working properly, i
Now, whenever i run the spec file, it bombs out as soon as it hits a
reference to the Property class (at the start of my main describe block),
saying
“/home/jars/rails/lesson_planner/branches/max/vendor/rails/activerecord/lib/…/…/activesupport/lib/active_support/dependencies.rb:249:in
`load_missing_constant’: Expected
/home/jars/rails/lesson_planner/branches/max/app/models/property.rb to
define Property (LoadError)”
This error is coming from Rails. Keep in mind that RSpec wrap Rails’
built-in test infrastructure. Can you try writing the same examples in
test/unit and see if they work?