Skip to content

Instantly share code, notes, and snippets.

@goggin13
Created February 5, 2013 21:32
Show Gist options
  • Save goggin13/4717890 to your computer and use it in GitHub Desktop.
Save goggin13/4717890 to your computer and use it in GitHub Desktop.
This RSpec file should live at `spec/models/micro_post_spec.rb`. Your first assignment is to create the new MicroPost model, and to write the validations to make this spec pass.
require 'spec_helper'
describe MicroPost do
before do
@micro_post = MicroPost.new(user_id: 1,
content: "hello world")
end
describe "with valid attributes" do
it "should be valid" do
@micro_post.should be_valid
end
end
describe "without a user_id" do
before do
@micro_post.user_id = nil
end
it "should not be valid" do
@micro_post.should_not be_valid
end
end
describe "without any content" do
before do
@micro_post.content = ""
end
it "should not be valid" do
@micro_post.should_not be_valid
end
end
describe "with too short content" do
before do
@micro_post.content = "hi"
end
it "should not be valid" do
@micro_post.should_not be_valid
end
end
describe "with too long content" do
before do
@micro_post.content = "a" * 141
end
it "should not be valid" do
@micro_post.should_not be_valid
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment