I run test:
test:units
lass ProductTest < ActiveSupport::TestCase
test "product attributes not be empty" do product = Product.new assert product.invalid? assert product.errors[:title].any? assert product.errors[:description].any? assert product.errors[:price].any? assert product.errors[:image_url].any?
end
test "price musst be positive" do product = Product.new( title: "mybook", description: "yyy", image_url: "img.jpg") product.price = -1
assert product.invalid? assert_equal "musst be greater than or equal to 0.01", product.errors[:price].join(';')
product.price = 0 assert product.invalid? assert_equal "musst be greater than or equal to 0.01", product.errors[:price].join(';')
product.price = 1 assert product.invalid?
end end
Show error: 1) Error: test_product_attributes_not_be_empty(ProductTest): ActiveRecord::Fixture::FormatError: a YAML error occurred parsing /home/dima/RubyOnRails/Projects/depot/test/fixtures/products.yml. Please note that YAML must be consistently indented using spaces. Tabs are not allowed. The exact error was: Psych::SyntaxError: (<unknown>): did not find expected key while parsing a block mapping at line 3 column 1
I dont undestand what they mean?
Its my product.yml:
one: title: MyString description: MyText image_url: MyString price: 9.99
two: title: MyString description: MyText image_url: MyString price: 9.99