Skip to content

Instantly share code, notes, and snippets.

@tubbo
Created December 19, 2010 22:25
Show Gist options
  • Save tubbo/747760 to your computer and use it in GitHub Desktop.
Save tubbo/747760 to your computer and use it in GitHub Desktop.
RSpec tests for Post
require 'spec_helper'
describe Post do
context "A post (in general)" do
setup do
@post=Post.new({
:id => 1,
:created_at => Time.now
})
end
it "should be invalid without a title" do
@post.should_not_be_valid
@post.title='A title!'
@post.should_be_valid
end
it 'should be invalid without a body' do
@post.should_not_be_valid
@post.body='A body!'
@post.should_be_valid
end
# specify "should be invalid without a title" do
# @post.should_not_be_valid
# @post.title='A title!'
# @post.should_be_valid
# end
#
# specify "should be invalid without a body" do
# @post.title='A title!'
# @post.should_not_be_valid
# @post.body='A body!'
# @post.should_be_valid
# end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment