I''ve got a strange issue. My default unit tests are failing for two
models. I
haven''t changed _anything_ in the test. Here''s an example:
Output:
1) Error:
test_truth(ShippingCostTypeTest):
NoMethodError: You have a nil object when you didn''t expect it!
You might have expected an instance of Array.
The error occured while evaluating nil.find
/usr/lib/ruby/gems/1.8/gems/activerecord-1.13.2/
lib/active_record/fixtures.rb:456:in
`shipping_cost_types''
test/unit/shipping_cost_type_test.rb:8:in `test_truth''
Fixture:
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
by_amount:
id: 1
name: amount
code: AMT
by_quantity:
id: 2
name: Quantity
code: QTY
Model:
class ShippingCostType < ActiveRecord::Base
end
-----
So, as you can tell, I''m _mighty_ perplexed.
Can anyone offer me some help?
Thanks much,
-jon
Jon wrote:> I''ve got a strange issue. My default unit tests are failing for two > models. I > haven''t changed _anything_ in the test. Here''s an example: > > Output: > 1) Error: > test_truth(ShippingCostTypeTest): > NoMethodError: You have a nil object when you didn''t expect it! > You might have expected an instance of Array. > The error occured while evaluating nil.find > > /usr/lib/ruby/gems/1.8/gems/activerecord-1.13.2/ > lib/active_record/fixtures.rb:456:in > `shipping_cost_types'' > test/unit/shipping_cost_type_test.rb:8:in `test_truth'' >I''m having exactly the same problem/error message when trying to run a basic test. The dev machine is running Windows XP Pro, Ruby 1.82.15, Rails 1.0. -- Posted via http://www.ruby-forum.com/.
Jon, here''s how I got I working on mine. I added a setup method: def setup @game = Game.find(1) end Then changed the default test_truth method to def test_truth assert_kind_of Game, @game end Of course switch out the variables to, I guess, @shipping_cost_type and such for your test. Jon wrote:> I''ve got a strange issue. My default unit tests are failing for two > models. I > haven''t changed _anything_ in the test. Here''s an example: > > Output: > 1) Error: > test_truth(ShippingCostTypeTest): > NoMethodError: You have a nil object when you didn''t expect it! > You might have expected an instance of Array. > The error occured while evaluating nil.find > > /usr/lib/ruby/gems/1.8/gems/activerecord-1.13.2/ > lib/active_record/fixtures.rb:456:in > `shipping_cost_types'' > test/unit/shipping_cost_type_test.rb:8:in `test_truth'' > > > > Fixture: > # Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html > by_amount: > id: 1 > name: amount > code: AMT > by_quantity: > id: 2 > name: Quantity > code: QTY > > Model: > > class ShippingCostType < ActiveRecord::Base > end > > ----- > > So, as you can tell, I''m _mighty_ perplexed. > > Can anyone offer me some help? > > Thanks much, > -jon-- Posted via http://www.ruby-forum.com/.