spec/followable_spec.rb in partisan-0.2 vs spec/followable_spec.rb in partisan-0.2.1
- old
+ new
@@ -68,7 +68,64 @@
describe :update_follow_counter do
it { expect(band.followers_count).to eq 1 }
end
end
-end
+ describe :Callbacks do
+ before do
+ class Buffer
+ def self.tmp_value=(tmp_value)
+ @tmp_value = tmp_value
+ end
+
+ def self.tmp_value
+ @tmp_value
+ end
+ end
+ end
+
+ describe :before_being_followed do
+ before do
+ followable 'Band' do
+ before_being_followed { Buffer.tmp_value = self.about_to_be_followed_by }
+ end
+ end
+
+ it { expect{ user.follow(band) }.to change{ Buffer.tmp_value }.to(user) }
+ end
+
+ describe :after_being_followed do
+ before do
+ followable 'Band' do
+ after_being_followed { Buffer.tmp_value = self.just_followed_by }
+ end
+ end
+
+ it { expect{ user.follow(band) }.to change{ Buffer.tmp_value }.to(user) }
+ end
+
+ describe :before_being_unfollowed do
+ before do
+ followable 'Band' do
+ before_being_unfollowed { Buffer.tmp_value = self.about_to_be_unfollowed_by }
+ end
+
+ user.follow(band)
+ end
+
+ it { expect{ user.unfollow(band) }.to change{ Buffer.tmp_value }.to(user) }
+ end
+
+ describe :after_being_unfollowed do
+ before do
+ followable 'Band' do
+ after_being_unfollowed { Buffer.tmp_value = self.just_unfollowed_by }
+ end
+
+ user.follow(band)
+ end
+
+ it { expect{ user.unfollow(band) }.to change{ Buffer.tmp_value }.to(user) }
+ end
+ end
+end