Created
November 28, 2011 13:55
-
-
Save we4tech/1400478 to your computer and use it in GitHub Desktop.
spec for faq item model
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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