Okay this has been lingering in my head for quite a while now. In ruby on rails unit testing there is an exclamation mark with the assert method. Here is an example
test "No empty values to be inserted" do
product = Produce.new
assert !product.save
end
Let me know the function of the exclamation mark. Quick replies appreciated. Thanks.
!
is Logical negation.
!product.save
returns false. !product.save
returns true. Therefore, assert !product.save
means that product.save must return falsy for the test to pass.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.