require 'spec_helper' require 'factory_girl' require 'factories' describe SharpSocial::Mixins::Actor do before(:each) do #SharpSocial::Actor.destroy_all User.delete_all Activity.delete_all @user1 = FactoryGirl.create(:user, name: "user one") @user2 = FactoryGirl.create(:user, name: "user two") @user3 = FactoryGirl.create(:user, name: "user three") end it "can follow others" do expect(@user1.is_following @user2).to be_false expect(@user1.is_following? @user3).to be_false @user1.follow @user2 expect(@user1.is_following? @user2).to be_true @user1.follow! @user3 expect(@user1.is_following @user3).to be_true end it "can unfollow others" do @user1.follow @user2 expect(@user1.is_following? @user2).to be_true @user1.unfollow @user2 expect(@user1.is_following? @user2).to be_false @user1.unfollow! @user3 expect(@user1.is_following @user3).to be_false end it "can be followed by others" do @user1.follow! @user2 expect(@user2.is_followed? @user1).to be_true expect(@user1.is_following? @user2).to be_true @user2.follow @user3 expect(@user2.is_following @user3).to be_true expect(@user3.is_followed @user2).to be_true end it "will be friends when users follow each other" do @user1.follow! @user2 @user2.follow @user1 expect(@user1.is_friend? @user2).to be_true expect(@user2.is_friend @user1).to be_true end it "should follow others once" do @user1.follow! @user2 @user1.follow! @user2 expect(@user1.followings_count == 1).to be true expect(@user2.followers_count == 1).to be true end it "can create some activities" do @user1.create_activity title: "post title", body: "post body" @user2.create_activity! title: "post title", body: "post body" expect(@user1.activities.count).to be > 0 expect(@user2.activities.count).to eq 1 expect(@user3.activities.count).to eq 0 end it "can see activities of followings" do @user3.follow! @user2 @user3.follow! @user1 @user1.create_activity title: "post title", body: "post body" @user2.create_activity! title: "post title", body: "post body" expect(@user3.followings_activities.count).to eq 2 @user3.followings_activities.each do |activity| expect(activity.content[:title.to_s]).to include("title") expect(activity.content[:body.to_s]).to include("body") end end end