While putting DRYing some tests, I am trying to initialize a hash as
follows:
business = Business.new(0)
But this returns an error in testing. Specifically:
1) Error:
test_should_have_nils_not_zeroes_except_for_sales_tax_rate(BusinessTest):
TypeError: can't dup Fixnum
/test/unit/business_test.rb:41:in `new'
/test/unit/business_test.rb:41:in
`test_should_have_nils_not_zeroes_except_for_sales_tax_rate'
However, this works fine:
business = Business.new { |h,k| h[k] = 0 }
The hash business is an ActiveRecord class.
Any thoughts on what the heck is going on? Are the two situations
different because ActiveRecord needs to create the hash first and the
block assignment lets that happen and then assigns values?
Bill
--
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 [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---