I do something like the following in my models: class NoDeleteCompanyError < RuntimeError; end class Company < ActiveRecord::Base # model code end When I try to do: assert_rais(NoDeleteCompanyError) { some_block } It says that NoDeleteCompanyError is an uninitialized constant. To fix this I just do fixtures :companies. Is there anyway to default load all models when testing so I dont have to do this? Thanks. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
> > class NoDeleteCompanyError < RuntimeError; end > > class Company < ActiveRecord::Base > # model code > end > > > When I try to do: > > assert_rais(NoDeleteCompanyError) { some_block } > > It says that NoDeleteCompanyError is an uninitialized constant. > > To fix this I just do fixtures :companies. > > Is there anyway to default load all models when testing so I dont have > to do this?Probably ;) But another way would be to put your NoDeleteCompanyError into no_delete_company_error.rb in your models directory... --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Philip Hallstrom wrote:>> assert_rais(NoDeleteCompanyError) { some_block } >> >> It says that NoDeleteCompanyError is an uninitialized constant. >> >> To fix this I just do fixtures :companies. >> >> Is there anyway to default load all models when testing so I dont have >> to do this? > > Probably ;) But another way would be to put your NoDeleteCompanyError > into no_delete_company_error.rb in your models directory...Or it will probably work if you put the exception class inside your model class Model class MyException < RuntimeError; end end Also, check out the all_fixtures pluign I wrote: http://beautifulpixel.com/all_fixtures/index.html It makes fixture management quite painless. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Alex Wayne wrote:> Philip Hallstrom wrote: >>> assert_rais(NoDeleteCompanyError) { some_block } >>> >>> It says that NoDeleteCompanyError is an uninitialized constant. >>> >>> To fix this I just do fixtures :companies. >>> >>> Is there anyway to default load all models when testing so I dont have >>> to do this? >> >> Probably ;) But another way would be to put your NoDeleteCompanyError >> into no_delete_company_error.rb in your models directory... > > Or it will probably work if you put the exception class inside your > model > > class Model > class MyException < RuntimeError; end > end > > Also, check out the all_fixtures pluign I wrote: > http://beautifulpixel.com/all_fixtures/index.html > > It makes fixture management quite painless.The problem I have with that is that I cant catch that specific class outside of that model because it gives me an unititalized constant error. That''s why I put it outside the class. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Ben Johnson wrote:> The problem I have with that is that I cant catch that specific class > outside of that model because it gives me an unititalized constant > error. That''s why I put it outside the class.Try it inside the class, and use Company::NoDeleteCompanyError to identify the Exception class. assert_raise(Company::NoDeleteCompanyError) do some_block end -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---