David Kahn
2011-Mar-01 23:37 UTC
Did rails or shoulda go insane on the inflection of ''taxes''?
I have a model ''xp_jurisdiction_taxes'' which rails (3) created correctly. Another model ''xp_jurisdiction_states'' has many :xp_jurisdiction_taxes. In my spec I am using a shoulda helper to test the association but get the following error. BTW, greped the whole project just in case and the string ''taxi'' exists nowhere. 1) XpJurisdictionStates Failure/Error: it { should have_many(:xp_jurisdiction_taxes) } NameError: uninitialized constant XpJurisdictionStates::XpJurisdictionTaxis # ./spec/models/xp_jurisdiction_states_spec.rb:4:in `block (2 levels) in <top (required)>'' Not sure if this is a rails or shoulda issue (I am starting to think it is shoulda). Any input? -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
David Kahn
2011-Mar-02 00:15 UTC
Re: Did rails or shoulda go insane on the inflection of ''taxes''?
Correction --- I had originally misnamed the models by plural, however once fixed now, still same problem. I think this is a shoulda issue as I can associate and access the models and associations correctly in the console. On Tue, Mar 1, 2011 at 5:37 PM, David Kahn <dk-rfEMNHKVqOwNic7Bib+Ti1W1rNmOCjRP@public.gmane.org>wrote:> I have a model ''xp_jurisdiction_taxes'' which rails (3) created correctly. > > Another model ''xp_jurisdiction_states'' has many :xp_jurisdiction_taxes. > > In my spec I am using a shoulda helper to test the association but get the > following error. BTW, greped the whole project just in case and the string > ''taxi'' exists nowhere. > > 1) XpJurisdictionStates > Failure/Error: it { should have_many(:xp_jurisdiction_taxes) } > NameError: > uninitialized constant XpJurisdictionState::XpJurisdictionTaxis > # ./spec/models/xp_jurisdiction_states_spec.rb:4:in `block (2 levels) > in <top (required)>'' > > Not sure if this is a rails or shoulda issue (I am starting to think it is > shoulda). Any input? >-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Colin Law
2011-Mar-02 09:44 UTC
Re: Re: Did rails or shoulda go insane on the inflection of ''taxes''?
On 2 March 2011 00:15, David Kahn <dk-rfEMNHKVqOwNic7Bib+Ti1W1rNmOCjRP@public.gmane.org> wrote:> Correction --- I had originally misnamed the models by plural, however once > fixed now, still same problem. I think this is a shoulda issue as I can > associate and access the models and associations correctly in the console.Can you confirm the model, association and table names please? Colin> > > On Tue, Mar 1, 2011 at 5:37 PM, David Kahn <dk-rfEMNHKVqOwNic7Bib+Ti1W1rNmOCjRP@public.gmane.org> > wrote: >> >> I have a model ''xp_jurisdiction_taxes'' which rails (3) created correctly. >> >> Another model ''xp_jurisdiction_states'' has many :xp_jurisdiction_taxes. >> >> In my spec I am using a shoulda helper to test the association but get the >> following error. BTW, greped the whole project just in case and the string >> ''taxi'' exists nowhere. >> >> 1) XpJurisdictionStates >> Failure/Error: it { should have_many(:xp_jurisdiction_taxes) } >> NameError: >> uninitialized constant XpJurisdictionState::XpJurisdictionTaxis >> # ./spec/models/xp_jurisdiction_states_spec.rb:4:in `block (2 levels) >> in <top (required)>'' >> >> Not sure if this is a rails or shoulda issue (I am starting to think it is >> shoulda). Any input? > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. >-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
David Kahn
2011-Mar-02 15:08 UTC
Re: Re: Did rails or shoulda go insane on the inflection of ''taxes''?
On Wed, Mar 2, 2011 at 3:44 AM, Colin Law <clanlaw-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> On 2 March 2011 00:15, David Kahn <dk-rfEMNHKVqOwNic7Bib+Ti1W1rNmOCjRP@public.gmane.org> wrote: > > Correction --- I had originally misnamed the models by plural, however > once > > fixed now, still same problem. I think this is a shoulda issue as I can > > associate and access the models and associations correctly in the > console. > > Can you confirm the model, association and table names please? >Thanks Colin, here are the models and tables. Also to be sure went in to db console and verified the actual table names just in case something went awry. Also at bottom are the three rspec/shoulda errors. I have to be doing something wrong but if I am I don''t see it. class XpJurisdictionState < ActiveRecord::Base has_many :xp_jurisdiction_taxes end class XpJurisdictionTax < ActiveRecord::Base belongs_to :account_subcode belongs_to :xp_jurisdiction_states end create_table "xp_jurisdiction_states", :force => true do |t| t.string "state_code" t.string "state" t.string "billing_item" t.string "billing_memo" t.datetime "created_at" t.datetime "updated_at" end create_table "xp_jurisdiction_taxes", :force => true do |t| t.integer "xp_jurisdiction_state_id" t.integer "account_subcode_id" t.decimal "tax" t.datetime "created_at" t.datetime "updated_at" end public | xp_jurisdiction_states | table | postgres public | xp_jurisdiction_states_id_seq | sequence | postgres public | xp_jurisdiction_taxes | table | postgres public | xp_jurisdiction_taxes_id_seq | sequence | postgres 1) AccountSubcode Failure/Error: it { should have_many(:xp_jurisdiction_taxes) } NameError: uninitialized constant AccountSubcode::XpJurisdictionTaxis # ./spec/models/account_subcode_spec.rb:16:in `block (2 levels) in <top (required)>'' 2) XpJurisdictionState Failure/Error: it { should have_many(:xp_jurisdiction_taxes) } NameError: uninitialized constant XpJurisdictionState::XpJurisdictionTaxis # ./spec/models/xp_jurisdiction_state_spec.rb:4:in `block (2 levels) in <top (required)>'' 3) XpJurisdictionTax Failure/Error: it { should belong_to(:xp_jurisdiction_states) } Expected XpJurisdictionTax to have a belongs_to association called xp_jurisdiction_states (XpJurisdictionTax does not have a xp_jurisdiction_states_id foreign key.)> > Colin > > > > > > > On Tue, Mar 1, 2011 at 5:37 PM, David Kahn <dk-rfEMNHKVqOwNic7Bib+Ti1W1rNmOCjRP@public.gmane.org> > > wrote: > >> > >> I have a model ''xp_jurisdiction_taxes'' which rails (3) created > correctly. > >> > >> Another model ''xp_jurisdiction_states'' has many :xp_jurisdiction_taxes. > >> > >> In my spec I am using a shoulda helper to test the association but get > the > >> following error. BTW, greped the whole project just in case and the > string > >> ''taxi'' exists nowhere. > >> > >> 1) XpJurisdictionStates > >> Failure/Error: it { should have_many(:xp_jurisdiction_taxes) } > >> NameError: > >> uninitialized constant XpJurisdictionState::XpJurisdictionTaxis > >> # ./spec/models/xp_jurisdiction_states_spec.rb:4:in `block (2 > levels) > >> in <top (required)>'' > >> > >> Not sure if this is a rails or shoulda issue (I am starting to think it > is > >> shoulda). Any input? > > > > -- > > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > To unsubscribe from this group, send email to > > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > For more options, visit this group at > > http://groups.google.com/group/rubyonrails-talk?hl=en. > > > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Colin Law
2011-Mar-02 15:41 UTC
Re: Re: Did rails or shoulda go insane on the inflection of ''taxes''?
On 2 March 2011 15:08, David Kahn <dk-rfEMNHKVqOwNic7Bib+Ti1W1rNmOCjRP@public.gmane.org> wrote:> ... > Thanks Colin, here are the models and tables. Also to be sure went in to db > console and verified the actual table names just in case something went > awry. Also at bottom are the three rspec/shoulda errors. I have to be doing > something wrong but if I am I don''t see it. > > class XpJurisdictionState < ActiveRecord::Base > has_many :xp_jurisdiction_taxes > end > > class XpJurisdictionTax < ActiveRecord::Base > belongs_to :account_subcode > belongs_to :xp_jurisdiction_statesthat should be :xp_jurisdiction_state. It belongs to one state so singular.> end > > create_table "xp_jurisdiction_states", :force => true do |t| > t.string "state_code" > t.string "state" > t.string "billing_item" > t.string "billing_memo" > t.datetime "created_at" > t.datetime "updated_at" > end > > create_table "xp_jurisdiction_taxes", :force => true do |t| > t.integer "xp_jurisdiction_state_id" > t.integer "account_subcode_id" > t.decimal "tax" > t.datetime "created_at" > t.datetime "updated_at" > end > > public | xp_jurisdiction_states | table | postgres > public | xp_jurisdiction_states_id_seq | sequence | postgres > public | xp_jurisdiction_taxes | table | postgres > public | xp_jurisdiction_taxes_id_seq | sequence | postgres > > > 1) AccountSubcode > Failure/Error: it { should have_many(:xp_jurisdiction_taxes) } > NameError: > uninitialized constant AccountSubcode::XpJurisdictionTaxisIf you run a console and type "tax".pluralize you will get "taxes" which is correct. However on rails 3.0.5 if I type "taxes".singularize I get taxis which is not what you want. I assume it is using the same rule as would apply for axis and axes. The solution is to specify your own rules for your xp_jurisidiction_tax and taxes and then you should be ok.> # ./spec/models/account_subcode_spec.rb:16:in `block (2 levels) in <top > (required)>'' > > 2) XpJurisdictionState > Failure/Error: it { should have_many(:xp_jurisdiction_taxes) } > NameError: > uninitialized constant XpJurisdictionState::XpJurisdictionTaxis > # ./spec/models/xp_jurisdiction_state_spec.rb:4:in `block (2 levels) in > <top (required)>'' > > 3) XpJurisdictionTax > Failure/Error: it { should belong_to(:xp_jurisdiction_states) }Again should be singular, so that explains that problem I think. Colin> Expected XpJurisdictionTax to have a belongs_to association called > xp_jurisdiction_states (XpJurisdictionTax does not have a > xp_jurisdiction_states_id foreign key.) > > > >> >> Colin >> >> > >> > >> > On Tue, Mar 1, 2011 at 5:37 PM, David Kahn <dk-rfEMNHKVqOwNic7Bib+Ti1W1rNmOCjRP@public.gmane.org> >> > wrote: >> >> >> >> I have a model ''xp_jurisdiction_taxes'' which rails (3) created >> >> correctly. >> >> >> >> Another model ''xp_jurisdiction_states'' has many :xp_jurisdiction_taxes. >> >> >> >> In my spec I am using a shoulda helper to test the association but get >> >> the >> >> following error. BTW, greped the whole project just in case and the >> >> string >> >> ''taxi'' exists nowhere. >> >> >> >> 1) XpJurisdictionStates >> >> Failure/Error: it { should have_many(:xp_jurisdiction_taxes) } >> >> NameError: >> >> uninitialized constant XpJurisdictionState::XpJurisdictionTaxis >> >> # ./spec/models/xp_jurisdiction_states_spec.rb:4:in `block (2 >> >> levels) >> >> in <top (required)>'' >> >> >> >> Not sure if this is a rails or shoulda issue (I am starting to think it >> >> is >> >> shoulda). Any input? >> > >> > -- >> > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> > For more options, visit this group at >> > http://groups.google.com/group/rubyonrails-talk?hl=en. >> > >> >> -- >> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> To unsubscribe from this group, send email to >> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> For more options, visit this group at >> http://groups.google.com/group/rubyonrails-talk?hl=en. >> > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. >-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Phil Crissman
2011-Mar-02 15:51 UTC
Re: Re: Did rails or shoulda go insane on the inflection of ''taxes''?
It looks like a plain old AR inflection error; you can see it in the console:> "tax".pluralize=> "taxes"> "taxes".singularize=> "taxis" Rails stopped accepting inflection-related patches ages ago, but you can add more; google "adding activerecord inflections". The rails docs have a few examples in the table_name method documentation: http://api.rubyonrails.org/classes/ActiveRecord/Base.html#method-c-table_name Phil On Wed, Mar 2, 2011 at 9:08 AM, David Kahn <dk-rfEMNHKVqOwNic7Bib+Ti1W1rNmOCjRP@public.gmane.org>wrote:> > > > On Wed, Mar 2, 2011 at 3:44 AM, Colin Law <clanlaw-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote: > >> On 2 March 2011 00:15, David Kahn <dk-rfEMNHKVqOwNic7Bib+Ti1W1rNmOCjRP@public.gmane.org> wrote: >> > Correction --- I had originally misnamed the models by plural, however >> once >> > fixed now, still same problem. I think this is a shoulda issue as I can >> > associate and access the models and associations correctly in the >> console. >> >> Can you confirm the model, association and table names please? >> > > Thanks Colin, here are the models and tables. Also to be sure went in to db > console and verified the actual table names just in case something went > awry. Also at bottom are the three rspec/shoulda errors. I have to be doing > something wrong but if I am I don''t see it. > > class XpJurisdictionState < ActiveRecord::Base > > has_many :xp_jurisdiction_taxes > end > > class XpJurisdictionTax < ActiveRecord::Base > belongs_to :account_subcode > belongs_to :xp_jurisdiction_states > end > > create_table "xp_jurisdiction_states", :force => true do |t| > t.string "state_code" > t.string "state" > t.string "billing_item" > t.string "billing_memo" > t.datetime "created_at" > t.datetime "updated_at" > end > > create_table "xp_jurisdiction_taxes", :force => true do |t| > t.integer "xp_jurisdiction_state_id" > t.integer "account_subcode_id" > t.decimal "tax" > t.datetime "created_at" > t.datetime "updated_at" > end > > public | xp_jurisdiction_states | table | postgres > public | xp_jurisdiction_states_id_seq | sequence | postgres > public | xp_jurisdiction_taxes | table | postgres > public | xp_jurisdiction_taxes_id_seq | sequence | postgres > > > 1) AccountSubcode > Failure/Error: it { should have_many(:xp_jurisdiction_taxes) } > NameError: > uninitialized constant AccountSubcode::XpJurisdictionTaxis > # ./spec/models/account_subcode_spec.rb:16:in `block (2 levels) in > <top (required)>'' > > 2) XpJurisdictionState > Failure/Error: it { should have_many(:xp_jurisdiction_taxes) } > NameError: > uninitialized constant XpJurisdictionState::XpJurisdictionTaxis > # ./spec/models/xp_jurisdiction_state_spec.rb:4:in `block (2 levels) > in <top (required)>'' > > 3) XpJurisdictionTax > Failure/Error: it { should belong_to(:xp_jurisdiction_states) } > Expected XpJurisdictionTax to have a belongs_to association called > xp_jurisdiction_states (XpJurisdictionTax does not have a > xp_jurisdiction_states_id foreign key.) > > > > >> >> Colin >> >> > >> > >> > On Tue, Mar 1, 2011 at 5:37 PM, David Kahn <dk-rfEMNHKVqOwNic7Bib+Ti1W1rNmOCjRP@public.gmane.org> >> > wrote: >> >> >> >> I have a model ''xp_jurisdiction_taxes'' which rails (3) created >> correctly. >> >> >> >> Another model ''xp_jurisdiction_states'' has many :xp_jurisdiction_taxes. >> >> >> >> In my spec I am using a shoulda helper to test the association but get >> the >> >> following error. BTW, greped the whole project just in case and the >> string >> >> ''taxi'' exists nowhere. >> >> >> >> 1) XpJurisdictionStates >> >> Failure/Error: it { should have_many(:xp_jurisdiction_taxes) } >> >> NameError: >> >> uninitialized constant XpJurisdictionState::XpJurisdictionTaxis >> >> # ./spec/models/xp_jurisdiction_states_spec.rb:4:in `block (2 >> levels) >> >> in <top (required)>'' >> >> >> >> Not sure if this is a rails or shoulda issue (I am starting to think it >> is >> >> shoulda). Any input? >> > >> > -- >> > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> > To unsubscribe from this group, send email to >> > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> > For more options, visit this group at >> > http://groups.google.com/group/rubyonrails-talk?hl=en. >> > >> >> -- >> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> To unsubscribe from this group, send email to >> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> For more options, visit this group at >> http://groups.google.com/group/rubyonrails-talk?hl=en. >> >> > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. >-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
David Kahn
2011-Mar-02 17:54 UTC
Re: Re: Did rails or shoulda go insane on the inflection of ''taxes''?
On Wed, Mar 2, 2011 at 9:41 AM, Colin Law <clanlaw-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> On 2 March 2011 15:08, David Kahn <dk-rfEMNHKVqOwNic7Bib+Ti1W1rNmOCjRP@public.gmane.org> wrote: > > ... > > Thanks Colin, here are the models and tables. Also to be sure went in to > db > > console and verified the actual table names just in case something went > > awry. Also at bottom are the three rspec/shoulda errors. I have to be > doing > > something wrong but if I am I don''t see it. > > > > class XpJurisdictionState < ActiveRecord::Base > > has_many :xp_jurisdiction_taxes > > end > > > > class XpJurisdictionTax < ActiveRecord::Base > > belongs_to :account_subcode > > belongs_to :xp_jurisdiction_states > > that should be :xp_jurisdiction_state. It belongs to one state so > singular. >Thanks (both Colin and Phil), fixed this above (duh). Also added to my inflections: inflect.singular ''taxes'', ''tax'' So in the console: ruby-1.9.2-p136 :002 > ''taxes''.singularize => "tax" and also plural: ruby-1.9.2-p136 :003 > ''tax''.pluralize => "taxes" *BUT* some piece of code is still deciding that I have ''taxis'' and not ''taxes'' --- spec still failing: 1) AccountSubcode Failure/Error: it { should have_many(:xp_jurisdiction_taxes) } NameError: uninitialized constant AccountSubcode::XpJurisdictionTaxis # ./spec/models/account_subcode_spec.rb:16:in `block (2 levels) in <top (required)>'' 2) XpJurisdictionState Failure/Error: it { should have_many(:xp_jurisdiction_taxes) } NameError: uninitialized constant XpJurisdictionState::XpJurisdictionTaxis # ./spec/models/xp_jurisdiction_state_spec.rb:4:in `block (2 levels) in <top (required)>'' So... all the important tests are failing but not my shoulda checks on my model relations. I can just drop these lines in my tests and be ok as other code is essentially checking these via its actions, but is leaving a mystery still open as to why. It seems to me that shoulda is doing something funky in determining what it expects, which on the surface seems strange (I mean, if I say the relation should be :xp_jurisdiction_taxes.... there is nothing to infer... that symbol is the same in the shoulda/rspec and in the class it is testing... Anyhow, if you all have any other input, appreciated. Seems to me next step will be to see if I can trace this through the shoulda source code, although not really in a place timewise right now...> > > end > > > > create_table "xp_jurisdiction_states", :force => true do |t| > > t.string "state_code" > > t.string "state" > > t.string "billing_item" > > t.string "billing_memo" > > t.datetime "created_at" > > t.datetime "updated_at" > > end > > > > create_table "xp_jurisdiction_taxes", :force => true do |t| > > t.integer "xp_jurisdiction_state_id" > > t.integer "account_subcode_id" > > t.decimal "tax" > > t.datetime "created_at" > > t.datetime "updated_at" > > end > > > > public | xp_jurisdiction_states | table | postgres > > public | xp_jurisdiction_states_id_seq | sequence | postgres > > public | xp_jurisdiction_taxes | table | postgres > > public | xp_jurisdiction_taxes_id_seq | sequence | postgres > > > > > > 1) AccountSubcode > > Failure/Error: it { should have_many(:xp_jurisdiction_taxes) } > > NameError: > > uninitialized constant AccountSubcode::XpJurisdictionTaxis > > If you run a console and type > "tax".pluralize you will get "taxes" which is correct. However on > rails 3.0.5 if I type "taxes".singularize I get taxis which is not > what you want. I assume it is using the same rule as would apply for > axis and axes. The solution is to specify your own rules for your > xp_jurisidiction_tax and taxes and then you should be ok. > > > # ./spec/models/account_subcode_spec.rb:16:in `block (2 levels) in > <top > > (required)>'' > > > > 2) XpJurisdictionState > > Failure/Error: it { should have_many(:xp_jurisdiction_taxes) } > > NameError: > > uninitialized constant XpJurisdictionState::XpJurisdictionTaxis > > # ./spec/models/xp_jurisdiction_state_spec.rb:4:in `block (2 levels) > in > > <top (required)>'' > > > > 3) XpJurisdictionTax > > Failure/Error: it { should belong_to(:xp_jurisdiction_states) } > > Again should be singular, so that explains that problem I think. > > Colin > > > Expected XpJurisdictionTax to have a belongs_to association called > > xp_jurisdiction_states (XpJurisdictionTax does not have a > > xp_jurisdiction_states_id foreign key.) > > > > > > > >> > >> Colin > >> > >> > > >> > > >> > On Tue, Mar 1, 2011 at 5:37 PM, David Kahn <dk-rfEMNHKVqOwNic7Bib+Ti1W1rNmOCjRP@public.gmane.org > > > >> > wrote: > >> >> > >> >> I have a model ''xp_jurisdiction_taxes'' which rails (3) created > >> >> correctly. > >> >> > >> >> Another model ''xp_jurisdiction_states'' has many > :xp_jurisdiction_taxes. > >> >> > >> >> In my spec I am using a shoulda helper to test the association but > get > >> >> the > >> >> following error. BTW, greped the whole project just in case and the > >> >> string > >> >> ''taxi'' exists nowhere. > >> >> > >> >> 1) XpJurisdictionStates > >> >> Failure/Error: it { should have_many(:xp_jurisdiction_taxes) } > >> >> NameError: > >> >> uninitialized constant > XpJurisdictionState::XpJurisdictionTaxis > >> >> # ./spec/models/xp_jurisdiction_states_spec.rb:4:in `block (2 > >> >> levels) > >> >> in <top (required)>'' > >> >> > >> >> Not sure if this is a rails or shoulda issue (I am starting to think > it > >> >> is > >> >> shoulda). Any input? > >> > > >> > -- > >> > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > >> > To unsubscribe from this group, send email to > >> > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > >> > For more options, visit this group at > >> > http://groups.google.com/group/rubyonrails-talk?hl=en. > >> > > >> > >> -- > >> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > >> To unsubscribe from this group, send email to > >> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > >> For more options, visit this group at > >> http://groups.google.com/group/rubyonrails-talk?hl=en. > >> > > > > -- > > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > To unsubscribe from this group, send email to > > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > For more options, visit this group at > > http://groups.google.com/group/rubyonrails-talk?hl=en. > > > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Colin Law
2011-Mar-02 19:46 UTC
Re: Re: Did rails or shoulda go insane on the inflection of ''taxes''?
On 2 March 2011 17:54, David Kahn <dk-rfEMNHKVqOwNic7Bib+Ti1W1rNmOCjRP@public.gmane.org> wrote:> ... > *BUT* some piece of code is still deciding that I have ''taxis'' and not > ''taxes'' --- spec still failing: > > 1) AccountSubcode > Failure/Error: it { should have_many(:xp_jurisdiction_taxes) } > NameError: > uninitialized constant AccountSubcode::XpJurisdictionTaxis > # ./spec/models/account_subcode_spec.rb:16:in `block (2 levels) in <top > (required)>''It seems as if shoulda is not picking up the inflections for some reason. I don''t use shoulda, can you output debug during its execution? Is so what happens if you output "xp_jurisdiction_taxes".singularize and "taxes".singularize?> > 2) XpJurisdictionState > Failure/Error: it { should have_many(:xp_jurisdiction_taxes) } > NameError: > uninitialized constant XpJurisdictionState::XpJurisdictionTaxis > # ./spec/models/xp_jurisdiction_state_spec.rb:4:in `block (2 levels) in > <top (required)>'' > > So... all the important tests are failing but not my shoulda checks on myI presume you meant passing rather than failing :) Colin -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
David Kahn
2011-Mar-02 20:18 UTC
Re: Re: Did rails or shoulda go insane on the inflection of ''taxes''?
On Wed, Mar 2, 2011 at 1:46 PM, Colin Law <clanlaw-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> On 2 March 2011 17:54, David Kahn <dk-rfEMNHKVqOwNic7Bib+Ti1W1rNmOCjRP@public.gmane.org> wrote: > > ... > > *BUT* some piece of code is still deciding that I have ''taxis'' and not > > ''taxes'' --- spec still failing: > > > > 1) AccountSubcode > > Failure/Error: it { should have_many(:xp_jurisdiction_taxes) } > > NameError: > > uninitialized constant AccountSubcode::XpJurisdictionTaxis > > # ./spec/models/account_subcode_spec.rb:16:in `block (2 levels) in > <top > > (required)>'' > > It seems as if shoulda is not picking up the inflections for some > reason. I don''t use shoulda, can you output debug during its > execution? Is so what happens if you output > "xp_jurisdiction_taxes".singularize and "taxes".singularize? >Good question... and rails gets it right: ruby-1.9.2-p136 :004 > ''xp_jurisdiction_taxes''.singularize => "xp_jurisdiction_tax" When I have a chance will start looking at the shoulda source...> > > > 2) XpJurisdictionState > > Failure/Error: it { should have_many(:xp_jurisdiction_taxes) } > > NameError: > > uninitialized constant XpJurisdictionState::XpJurisdictionTaxis > > # ./spec/models/xp_jurisdiction_state_spec.rb:4:in `block (2 levels) > in > > <top (required)>'' > > > > So... all the important tests are failing but not my shoulda checks on my > > I presume you meant passing rather than failing :) >Oh, yeah.... everything else *is* working> > Colin > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Colin Law
2011-Mar-02 20:34 UTC
Re: Re: Did rails or shoulda go insane on the inflection of ''taxes''?
On 2 March 2011 20:18, David Kahn <dk-rfEMNHKVqOwNic7Bib+Ti1W1rNmOCjRP@public.gmane.org> wrote:> On Wed, Mar 2, 2011 at 1:46 PM, Colin Law <clanlaw-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote: >> ... >> It seems as if shoulda is not picking up the inflections for some >> reason. I don''t use shoulda, can you output debug during its >> execution? Is so what happens if you output >> "xp_jurisdiction_taxes".singularize and "taxes".singularize? > > Good question... and rails gets it right: > > ruby-1.9.2-p136 :004 > ''xp_jurisdiction_taxes''.singularize > => "xp_jurisdiction_tax"I meant to output that during the test itself if possible, to make sure that the inflections have been picked up at that time. Colin -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
David Kahn
2011-Mar-02 22:40 UTC
Re: Re: Did rails or shoulda go insane on the inflection of ''taxes''?
On Wed, Mar 2, 2011 at 2:34 PM, Colin Law <clanlaw-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> On 2 March 2011 20:18, David Kahn <dk-rfEMNHKVqOwNic7Bib+Ti1W1rNmOCjRP@public.gmane.org> wrote: > > > On Wed, Mar 2, 2011 at 1:46 PM, Colin Law <clanlaw-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> > wrote: > >> ... > >> It seems as if shoulda is not picking up the inflections for some > >> reason. I don''t use shoulda, can you output debug during its > >> execution? Is so what happens if you output > >> "xp_jurisdiction_taxes".singularize and "taxes".singularize? > > > > Good question... and rails gets it right: > > > > ruby-1.9.2-p136 :004 > ''xp_jurisdiction_taxes''.singularize > > => "xp_jurisdiction_tax" > > I meant to output that during the test itself if possible, to make > sure that the inflections have been picked up at that time. >Good idea, sorry.... so "puts ''xp_jurisdiction_taxes''.singularize" while inside a spec (cant put it directly inside the shoulda call though) gives us: xp_jurisdiction_tax> > Colin > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Colin Law
2011-Mar-03 08:17 UTC
Re: Re: Did rails or shoulda go insane on the inflection of ''taxes''?
On 2 March 2011 22:40, David Kahn <dk-rfEMNHKVqOwNic7Bib+Ti1W1rNmOCjRP@public.gmane.org> wrote:> ... > Good idea, sorry.... so "puts ''xp_jurisdiction_taxes''.singularize" while > inside a spec (cant put it directly inside the shoulda call though) gives > us: > > xp_jurisdiction_taxIn that case it looks as if you are right about it being a shoulda issue, not using the inflections correctly. Colin -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.