File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11require_relative '../app/models/following_policy'
22
33describe FollowingPolicy do
4- before ( :each ) do
4+ before ( :each ) do
55 @followee = double 'followee'
66 @follower = double 'follower'
77 end
8-
8+
99 it 'can follow another' do
1010 @follower . should_receive ( :following? ) . with ( @followee ) . and_return ( false )
1111 policy = FollowingPolicy . new ( @follower )
1212 policy . can_follow? ( @followee ) . should be_true
1313 end
14-
14+
1515 it "cannot follow self" do
1616 policy = FollowingPolicy . new ( @follower )
1717 policy . following_self? ( @follower ) . should be_true
1818 policy . can_follow? ( @follower ) . should be_false
1919 end
20-
20+
2121 it "cannot follow twice" do
2222 @follower . should_receive ( :following? ) . twice . with ( @followee ) . and_return ( true )
2323 policy = FollowingPolicy . new ( @follower )
2424 policy . already_following? ( @followee ) . should be_true
2525 policy . can_follow? ( @followee ) . should be_false
2626 end
27-
27+
2828end
Original file line number Diff line number Diff line change 1+ require 'spec_helper'
2+
3+ describe User do
4+
5+ let ( :bob ) { Fabricate ( :user ) }
6+ let ( :mozart ) { Fabricate ( :user ) }
7+
8+ it 'can be created validly' do
9+ bob . should be_valid
10+ mozart . should be_valid
11+ end
12+
13+ it 'Users can follow and unfollow' do
14+ bob . follow! ( mozart )
15+ bob . following? ( mozart ) . should be_true
16+ bob . unfollow! ( mozart )
17+ bob . reload
18+ bob . following? ( mozart ) . should be_false
19+ end
20+ end
You can’t perform that action at this time.
0 commit comments