Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: df31ef04cc
Fetching contributors…

Cannot retrieve contributors at this time

51 lines (36 sloc) 1.378 kb
require 'spec_helper'
describe Micropost do
let(:user) { FactoryGirl.create(:user) }
before { @micropost = user.microposts.build(content: "Lorem ipsum") }
subject { @micropost }
it { should respond_to(:content) }
it { should respond_to(:user_id) }
it { should respond_to(:user) }
its(:user) { should == user }
it { should be_valid }
describe "when user_id is not present" do
before { @micropost.user_id = nil }
it { should_not be_valid }
end
describe "with blank content" do
before { @micropost.content = " " }
it { should_not be_valid }
end
describe "with content that is too long" do
before { @micropost.content = "a" * 141 }
it { should_not be_valid }
end
describe "from_users_followed_by" do
let(:user) { FactoryGirl.create(:user) }
let(:other_user) { FactoryGirl.create(:user) }
let(:third_user) { FactoryGirl.create(:user) }
before { user.follow!(other_user) }
let(:own_post) { user.microposts.create!(content: "foo") }
let(:followed_post) { other_user.microposts.create!(content: "bar") }
let(:unfollowed_post) { third_user.microposts.create!(content: "baz") }
subject { Micropost.from_users_followed_by(user) }
it { should include(own_post) }
it { should include(followed_post) }
it { should_not include(unfollowed_post) }
end
end
Jump to Line
Something went wrong with that request. Please try again.