I m working on rails project and i m new on rails and I want to test my model relationships and methods in model using rspec. How could I do this my model relationships are like this
class Idea < ActiveRecord::Base
belongs_to :person
belongs_to :company
has_many :votes
validates_presence_of :title, :description
def published?
if self.status == "published"
return true
else
return false
end
end
def image_present
if self.image_url
return self.image_url
else
return "/images/image_not_found.jpg"
end
end
def voted
self.votes.present?
end
end
My idea_spec.rb file is
require 'spec_helper'
describe Idea do
it "should have title" do
Idea.new(:title=>'hello',:description=>'some_desc').should be_valid
end
it "should have description" do
Idea.new(:title=>'hello',:description=>'some_desc').should be_valid
end
end