mardi 13 février 2018

i have issue rspec syntax

job model
class Job < ApplicationRecord
    belongs_to :user
    belongs_to :category
  belongs_to :company
  accepts_nested_attributes_for :company


  has_attached_file :image, styles: {  medium: "800x800>", thumb: "100x100>" }, default_url: "/images/:style/missing.png"
  validates_attachment_content_type :image, content_type: /\Aimage\/.*\z/

  validates :title, presence: true
  validates :title, length: {minimum: 5, maximum: 15}
  validates :description,length: {minimum: 10, maximum: 400}
job_spec.rb
RSpec.describe Job, type: :model do
  it "ensures title presence" do
    # job=Job.new(title:'software engineer').save
    expect(job).to validate_presence_of(:title)

  end


end

i'm new to ruby, actually i want to write unit test using rspec to model. i want to write testing for association as well, but i don't know how to start.can any one help me to sort this out.

Aucun commentaire:

Enregistrer un commentaire