Hi All
I’m reading stuff from ‘Agile Web development With Ruby on Rails’ (p
141)
Anyway, they say that there is a variable that contains all the data
from the fixture!
Example:
fixtures :address
def setup
@address = Address.find(1)
end
def test_create
data = @addresses[“first”] # this is line 11
assert_kind_of Address, @address
assert_equal data[“id”], @address.id
… etc…
end
So assumed is that all data from the fixture is loaded into the hash
@addresses. But Running this test I get an error on @addresses:
Loaded suite address_test
Started
E…
Finished in 0.125989 seconds.
- Error:
test_create(AddressTest):
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.[]
address_test.rb:11:in `test_create’
3 tests, 4 assertions, 0 failures, 1 errors
So it seems there is no @addresses
Any suggestions why this hash is empty ?
Thnx a lot
LuCa
ps my fixture looke something like
first:
id: 1
…