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

html - Sizing a high-res image (~8MB) to display entirely in a small div (circular, diameter 100px) -

java - IntelliJ - No such instance method -

identifier - Is it possible for an html5 document to have two ids? -