Weird error when running my unit tests

How can this be possible:

I have two tests:

def find_all_active_and_inactive
assert_equal Concept.find_all_active_and_inactive.size,


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

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:
    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?

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs