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
Post a Comment