ruby on rails - How to write unit tests to this specific ActiveRecord class? -


i'd write unit tests in rspec class:

class item < activerecord::base   has_many :cart_items   has_many :carts, through: :cart_items    validates :price, presence: true   validates :name, presence: true end 

i'm not sure should test here ... can give tips ?

using shoulda-matchers gem, can this

describe item   {should validate_presence_of :price}   {should validate_presence_of :name}   {should have_many(:cart_items)}   {should have_many(:carts).through(:cart_items)} end 

Comments

Popular posts from this blog

php - regexp cyrillic filename not matches -

c# - OpenXML hanging while writing elements -

sql - Select Query has unexpected multiple records (MS Access) -