ruby on rails - How to use RSpec to test if the category of an item is a valid category in the category table? -
I have an item model in which each item should have a range that is a valid category.
In my item.rb, I have
is_on: category
and in my category.rb, I have
related_to: Item
Is that correct? And how do I verify that my item is a valid category using RSPC?
Please help and thank you!
)
I will have two tests:
let's (: valid_category) { Stub_model (category ,: valid? = & Gt; true)} (let's invalid: category) {stub_model (category (not valid; = & gt; false)} two (params) except the {{}}} class # valid parameter {Item.new should specify (params.merge (: category = & gt; valid_category)) new (params.merge (: category = & gt; invalid_category)). Should_not be_valid}
Comments
Post a Comment