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
on 2013-03-14 17:26
on 2013-03-14 22:18
On 14 March 2013 16:26, Dmitrij B. <lists@ruby-forum.com> wrote: > Its my product.yml: > > one: > title: MyString > description: MyText The clue is in the error message, which says there is a problem with line above and says that yaml must be consistently indented using spaces. It looks from your pasted text that line three two has three spaces and line three has two, so the spacing is not consistent. Colin
on 2013-03-15 10:33
I read about the mistake, but I thought that this is due to the other. Thanks)))
Please log in before posting. Registration is free and takes only a minute.
Existing account
(Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
Log in with Google account | Log in with Yahoo account
No account? Register here.