Max Williams
2008-Mar-05 10:40 UTC
[rspec-users] has_many_polymorphs is breaking my spec file
Hey folks 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: POLYMORPHIC_TABLENAMES = [:instructional_objects, :resources, :lessons, :courses] #this is breaking tests currently has_many_polymorphs :labellables, :from => POLYMORPHIC_TABLENAMES, :through => :labellings, :dependent => :destroy 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. thanks max -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20080305/aa9ececa/attachment.html
David Chelimsky
2008-Mar-05 13:37 UTC
[rspec-users] has_many_polymorphs is breaking my spec file
On Wed, Mar 5, 2008 at 4:40 AM, Max Williams <toastkid.williams at gmail.com> wrote:> Hey folks > > 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: > > POLYMORPHIC_TABLENAMES = [:instructional_objects, :resources, :lessons, > :courses] > #this is breaking tests currently > has_many_polymorphs :labellables, > :from => POLYMORPHIC_TABLENAMES, > :through => :labellings, > :dependent => :destroy > > 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?> > 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. > > thanks > max > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >
Max Williams
2008-Mar-05 13:53 UTC
[rspec-users] has_many_polymorphs is breaking my spec file
Hmm, the results are exactly the same, down to the error message. And, as before, if i remove the has_many_polymorphs declaration there''s no problem. So its not rspec''s fault. But i''m still no closer to finding out what it is about my has_many_polymorphs declaration that the tests don''t like. :( On 05/03/2008, David Chelimsky <dchelimsky at gmail.com> wrote:> > On Wed, Mar 5, 2008 at 4:40 AM, Max Williams > <toastkid.williams at gmail.com> wrote: > > Hey folks > > > > 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: > > > > POLYMORPHIC_TABLENAMES = [:instructional_objects, :resources, > :lessons, > > :courses] > > #this is breaking tests currently > > has_many_polymorphs :labellables, > > :from => POLYMORPHIC_TABLENAMES, > > :through => :labellings, > > :dependent => :destroy > > > > 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? > > > > > > 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. > > > > thanks > > max > > > > > > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20080305/517b1527/attachment.html
David Chelimsky
2008-Mar-05 14:01 UTC
[rspec-users] has_many_polymorphs is breaking my spec file
On Wed, Mar 5, 2008 at 7:53 AM, Max Williams <toastkid.williams at gmail.com> wrote:> Hmm, the results are exactly the same, down to the error message. And, as > before, if i remove the has_many_polymorphs declaration there''s no problem. > > So its not rspec''s fault. But i''m still no closer to finding out what it is > about my has_many_polymorphs declaration that the tests don''t like. :(Have you posted to the rails list?> > > > On 05/03/2008, David Chelimsky <dchelimsky at gmail.com> wrote: > > On Wed, Mar 5, 2008 at 4:40 AM, Max Williams > > <toastkid.williams at gmail.com> wrote: > > > Hey folks > > > > > > 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: > > > > > > POLYMORPHIC_TABLENAMES = [:instructional_objects, :resources, > :lessons, > > > :courses] > > > #this is breaking tests currently > > > has_many_polymorphs :labellables, > > > :from => POLYMORPHIC_TABLENAMES, > > > :through => :labellings, > > > :dependent => :destroy > > > > > > 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? > > > > > > > > > > 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. > > > > > > thanks > > > max > > > > > > > > > > > _______________________________________________ > > > rspec-users mailing list > > > rspec-users at rubyforge.org > > > http://rubyforge.org/mailman/listinfo/rspec-users > > > > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >
Max Williams
2008-Mar-05 14:17 UTC
[rspec-users] has_many_polymorphs is breaking my spec file
no, just the ruby forum. I''ll try the rails list next. thanks On 05/03/2008, David Chelimsky <dchelimsky at gmail.com> wrote:> > On Wed, Mar 5, 2008 at 7:53 AM, Max Williams > > <toastkid.williams at gmail.com> wrote: > > > Hmm, the results are exactly the same, down to the error message. And, > as > > before, if i remove the has_many_polymorphs declaration there''s no > problem. > > > > So its not rspec''s fault. But i''m still no closer to finding out what > it is > > about my has_many_polymorphs declaration that the tests don''t like. :( > > > Have you posted to the rails list? > > > > > > > > > > On 05/03/2008, David Chelimsky <dchelimsky at gmail.com> wrote: > > > On Wed, Mar 5, 2008 at 4:40 AM, Max Williams > > > <toastkid.williams at gmail.com> wrote: > > > > Hey folks > > > > > > > > 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: > > > > > > > > POLYMORPHIC_TABLENAMES = [:instructional_objects, :resources, > > :lessons, > > > > :courses] > > > > #this is breaking tests currently > > > > has_many_polymorphs :labellables, > > > > :from => POLYMORPHIC_TABLENAMES, > > > > :through => :labellings, > > > > :dependent => :destroy > > > > > > > > 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? > > > > > > > > > > > > > > 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. > > > > > > > > thanks > > > > max > > > > > > > > > > > > > > > _______________________________________________ > > > > rspec-users mailing list > > > > rspec-users at rubyforge.org > > > > http://rubyforge.org/mailman/listinfo/rspec-users > > > > > > > _______________________________________________ > > > rspec-users mailing list > > > rspec-users at rubyforge.org > > > http://rubyforge.org/mailman/listinfo/rspec-users > > > > > > > > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20080305/7ea9a9ed/attachment.html