# Default unit tests failing?

**URL:** <https://www.ruby-forum.com/t/default-unit-tests-failing/52012>\
**Category:** Rails\
**Created:** [January 10, 2006, 2:02am UTC](https://www.ruby-forum.com/t/default-unit-tests-failing/52012 "2006-01-10T02:02:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jon](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/3bc359/32.png) [@jon](https://www.ruby-forum.com/u/jon)\
**Post date:** [January 10, 2006, 2:02am UTC](https://www.ruby-forum.com/t/default-unit-tests-failing/52012/1 "2006-01-10T02:02:43Z")

</div>

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](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

---

<div class="post-metadata">

**Author:** ![jon](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/3bc359/32.png) [@jon](https://www.ruby-forum.com/u/jon)\
**Post date:** [January 12, 2006, 12:08am UTC](https://www.ruby-forum.com/t/default-unit-tests-failing/52012/2 "2006-01-12T00:08:45Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![jon](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/3bc359/32.png) [@jon](https://www.ruby-forum.com/u/jon)\
**Post date:** [January 12, 2006, 12:19am UTC](https://www.ruby-forum.com/t/default-unit-tests-failing/52012/3 "2006-01-12T00:19:35Z")

</div>

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](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
