Weird error when running my unit tests


#1

How can this be possible:

I have two tests:

def find_all_active_and_inactive
assert_equal Concept.find_all_active_and_inactive.size,
@concepts.size
end

and

def test_find_all_inactive
assert_equal Concept.find_all_inactive.size, (@concepts.size -
Concept.find_all.size)
end

Concept.find_all returns 2 concepts (I overwrote the method to return
only the active concepts)
Concept.find_all_inactive returns 1 concept
Concept.find_all_active_and_inactive returns 3 concepts

And @concepts.size returns 3

When I run the first test, there is no error.

When I run the second test, I get this error:

  1. Error:
    test_find_all_inactive(ConceptTest):
    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.size
    concept_test.rb:36:in `test_find_all_inactive’

I dont understand! Why is @concepts.size working in the first test and
not in the second?