28 Apr 2014, 14:52
Generic-user-small

Ivan Bezrodnov (1 post)

Hi. This is part of my tests:

test “product price must be positive” do product = Product.new( title: “My book title”, description: “yyy”, image_url: “zzz.img”)

product.price = -1
assert product.invalid?
assert_equal ["must be greater than or equal to 0.01"], product.errors[:price]

product.price = 0
assert product.invalid?
assert_equal ["must be greater than or equal to 0.01"], product.errors[:price]

product.price = 1
assert product.valid? end

and my validation:

validates :price, numericality: { greater_than_or_equal_to: 0.01 }

but after rake test i have this message “Failed assertion, no message given” (assert product.valid?)

why? =(

  You must be logged in to comment