Skip to content

Instantly share code, notes, and snippets.

@we4tech
Created November 28, 2011 13:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save we4tech/1400489 to your computer and use it in GitHub Desktop.
Save we4tech/1400489 to your computer and use it in GitHub Desktop.
spec for faq item model
require 'spec_helper'
describe FaqItem do
context 'validations' do
it 'should validate the presence of question' do
should validate_presence_of(:question)
end
it 'should validate the presence of answer' do
should validate_presence_of(:answer)
end
it 'should validate the presence of visible' do
should validate_presence_of(:visible)
end
end
context 'relations' do
it 'should have one draft'
end
context '#save' do
it 'should save valid faq item' do
faq = FaqItem.new(:question => 'Test question', :answer => 'Test answer')
faq.save.should be_true
faq.reload
faq.question.should == 'Test question'
faq.answer.should == 'Test answer'
faq.visible.should == true
faq.position.should == 0
end
it "shouldn't save invalid faq item" do
faq = FaqItem.new
faq.save.should be_false
faq.errors[:question].should_not be_nil
faq.errors[:answer].should_not be_nil
end
end
context '#update' do
let(:faq_item) { Factory(:faq_item) }
describe 'draft' do
it 'should create draft'
it 'should update on drafted item'
it 'should update on existing draft'
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment