Sha256: 240db37392643573288ab3581e6d3195f67827a0fb1d636a92e5a6b625192384
Contents?: true
Size: 1.51 KB
Versions: 2
Compression:
Stored size: 1.51 KB
Contents
require 'spec_helper' describe ChalkDust do before(:each) { ChalkDust::Connection.delete_all } describe 'subscribing' do it '.subscribe connects two objects' do user = User.create! post = Post.create! ChalkDust.subscribe(user, :to => post) connection = ChalkDust::Connection.first connection.subscriber.should == user connection.publisher.should == post end it '.self_subscribe connects object to itself' do user = User.create! ChalkDust.self_subscribe(user) connection = ChalkDust::Connection.first connection.subscriber.should == user connection.publisher.should == user end describe 'options' do it ':undirected subscribes in both directions' do bob = User.create! alice = User.create! ChalkDust.subscribe(bob, :to => alice, :undirected => true) ChalkDust::Connection.count.should == 2 connection_1 = ChalkDust::Connection.first connection_1.subscriber.should == bob connection_1.publisher.should == alice connection_2 = ChalkDust::Connection.last connection_2.subscriber.should == alice connection_2.publisher.should == bob end end end describe 'fetching subscriptions' do it '.subscriptions_of returns subscribers to given object' do user = User.create! post = Post.create! ChalkDust::Connection.create!(:subscriber => user, :publisher => post) ChalkDust.subscribers_of(post).should == [user] end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
chalk_dust-0.0.2 | spec/lib/chalk_dust/subscribing_spec.rb |
chalk_dust-0.0.1 | spec/lib/chalk_dust/subscribing_spec.rb |