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

Popular posts from this blog

Python SQLAlchemy:AttributeError: Neither 'Column' object nor 'Comparator' object has an attribute 'schema' -

java - How not to audit a join table and related entities using Hibernate Envers? -

mongodb - CakePHP paginator ignoring order, but only for certain values -