Created
February 5, 2013 21:32
-
-
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.
This file contains 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 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