Permalink
Browse files

make serverside client reply to channel it posted to

  • Loading branch information...
1 parent 1e4f1a6 commit f5b109633812a134d0cc5f285257a45425bf63b0 @esposito esposito committed May 19, 2012
Showing with 6 additions and 5 deletions.
  1. +1 −1 faye/client.rb
  2. +5 −3 spec/faye/client_spec.rb
  3. +0 −1 spec/javascripts/logic/sync_spec.coffee
View
@@ -11,7 +11,7 @@ def subscribe
end
def on_server_message(message)
- @client.publish('/sync/posts', :message => 'test')
+ @client.publish("/sync/#{message["channel"]}", {'test' => 'message'})
end
def publish
@@ -30,9 +30,11 @@
end
describe '#on_server_message' do
- it 'calls publish on the client attribute' do
- client.should_receive(:publish)
- subject.on_server_message(stub)
+ it 'publishes on the channel declared in the message' do
+ message = stub
+ message.stub(:[]) {|key| key}
+ client.should_receive(:publish).with('/sync/channel', an_instance_of(Hash))
+ subject.on_server_message(message)
end
end
@@ -34,7 +34,6 @@ describe 'Sync', ->
it 'publishes the channel and a list of locks to the server', ->
@collection.prepareSync()
- console.log @collection.channel
expect(@publishStub).toHaveBeenCalledWith
channel: 'testcollection'
locks: ['some_id']

0 comments on commit f5b1096

Please sign in to comment.