If I get this right, Unit Testing is all about testing if our app handles
our data the way it should. In other words it's all about testing the
model? (ex. does our app *rejects product titles with fewer than 10 chars *as
it should?)

So the way to do unit tests are always to use assertions? Or there are
other ways too?

I'm playing with the code from "Agile Development with Rails" where we
create an online store, and this is a test for my product title that I
wrote. Can you tell me if it's the best way to do it or maybe there's a
quicker and better solution?

test "title length must be greater than 10" do
product = Product.new(
description: "yyy",
image_url: "zzz.jpg",
price: "23"

product.title = "test" # length < 10
assert product.invalid?

product.title = "asdweqrtwe" # length = 10
assert product.valid?

product.title = "asdfertgfda" # length > 10
assert product.valid?
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/QRL91c6LK5EJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to [email protected].
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouprubyonrails-talk @
postedJan 17, '12 at 10:27a
activeJan 17, '12 at 10:27a

1 user in discussion

Agis A.: 1 post



site design / logo © 2023 Grokbase