The previous essays are written in accordance with the examples in the book, but, this time in the test model, according to the example of the book How the code can not go, so on the other way, this becomes a question.
According to the book, at the beginning of the PRODUCTS_TEST.RB, the test data is loaded into a hash based on the defined yml file, so that we can access a product object by the name of the use case in Yml file, for example:
def test_read_with_hash
assert_kind_of Product, @product
vc_book = @products ["Version_control_book"]
Assert_equal vc_book["id", @product. ID
assert_equal vc_book["title"], @product. Title
assert_equal vc_book[ "description"], @product. Description
assert_equal vc_book["Image_url"], @product. Image_url assert_equal
VC _book[' price ', @product. Price
assert_equal vc_book["date_available"], @product. date_available_before_type_ Cast End
However, depending on the error that always prompts Vc_book to be null when the test is run:
3) Error:
Test_read_with_hash (producttest):
nomethoderror:you have a nil object when you didn ' t expect it!
You are might have expected an Array of instance.
The error occurred while evaluating nil. []
test/unit/product_test.rb:41:in ' Test_read_with_hash '
What's going on? Even if the contents of the PRODUCT_TEST.RB to replace all the complete code in the book is still not, is not the version of the problem?